Skip to content

Commit

Permalink
[Bexley][WW] WIP worksheets for container collections & deliveries
Browse files Browse the repository at this point in the history
  • Loading branch information
nephila-nacrea committed Sep 11, 2024
1 parent f50869e commit 49dffe0
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 35 deletions.
88 changes: 61 additions & 27 deletions perllib/Integrations/Whitespace.pm
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ sub CreateWorksheet {
die "No service_item_name provided";
}

# EXAMPLE FOR conf/council-bexley_whitespace.yml
# service_mapping:
# PG-240:
# service_item_id: 802 # Plastics & glass 240 ltr wheeled bin
# service_id: 319 # Missed Collection Plastics & Glass
# delivery_service_id: 331 # Deliver Plastics & Glass 240 ltr Bin
# collection_service_id: 339 # Collect Plastics & Glass 240 ltr Bin

my $service_mapping = $self->config->{service_mapping};
my $service_params = $service_mapping->{$params->{service_item_name}};

Expand All @@ -100,36 +108,62 @@ sub CreateWorksheet {
die "No service mapping found for $params->{service_item_name}";
}

my $worksheet = ixhash(
Uprn => $params->{uprn},
ServiceId => $service_params->{service_id},
my %common_params = (
Uprn => $params->{uprn},
WorksheetReference => $params->{worksheet_reference},
WorksheetMessage => $params->{worksheet_message},
ServiceItemInputs => ixhash(
'wsap:Input.CreateWorksheetInput.ServiceItemInput' => [
ixhash(
'wsap:ServiceItemId' => $service_params->{service_item_id},
'wsap:ServiceItemName' => '',
'wsap:ServiceItemQuantity' => 1,
)
]
),
ServicePropertyInputs => [
{
'wsap:Input.CreateWorksheetInput.ServicePropertyInput' => ixhash(
'wsap:ServicePropertyId' => 79,
'wsap:ServicePropertyValue' => $params->{assisted_yn},
),
},
{
'wsap:Input.CreateWorksheetInput.ServicePropertyInput' => ixhash(
'wsap:ServicePropertyId' => 80,
'wsap:ServicePropertyValue' => $params->{location_of_containers},
),
},
],
WorksheetMessage => $params->{worksheet_message},
);

my $worksheet;
if ( $params->{service_code} eq 'request_new_container' ) {

# TODO Worksheet for collection as well

$worksheet = ixhash(
%common_params,
ServiceId => $service_params->{delivery_service_id},
ServiceItemInputs => ixhash(
'wsap:Input.CreateWorksheetInput.ServiceItemInput' => [
ixhash(
'wsap:ServiceItemId' => $service_params->{service_item_id},
'wsap:ServiceItemName' => '',
'wsap:ServiceItemQuantity' => 1,
)
]
),
# TODO ServicePropertyInputs?
);
} else {
# Missed collection
$worksheet = ixhash(
%common_params,
ServiceId => $service_params->{service_id},
ServiceItemInputs => ixhash(
'wsap:Input.CreateWorksheetInput.ServiceItemInput' => [
ixhash(
'wsap:ServiceItemId' => $service_params->{service_item_id},
'wsap:ServiceItemName' => '',
'wsap:ServiceItemQuantity' => 1,
)
]
),
ServicePropertyInputs => [
{
'wsap:Input.CreateWorksheetInput.ServicePropertyInput' => ixhash(
'wsap:ServicePropertyId' => 79,
'wsap:ServicePropertyValue' => $params->{assisted_yn},
),
},
{
'wsap:Input.CreateWorksheetInput.ServicePropertyInput' => ixhash(
'wsap:ServicePropertyId' => 80,
'wsap:ServicePropertyValue' => $params->{location_of_containers},
),
},
],
);
}

my $res = $self->call('CreateWorksheet', worksheetInput => $worksheet);
$self->logger->debug("CreateWorksheet response: " . encode_json($res));

Expand Down
33 changes: 25 additions & 8 deletions perllib/Open311/Endpoint/Integration/Whitespace.pm
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,29 @@ sub post_service_request {

my $integration = $self->get_integration;

my $worksheet_id = $integration->CreateWorksheet({
uprn => $args->{attributes}->{uprn},
service_item_name => $args->{attributes}->{service_item_name},
worksheet_reference => $args->{attributes}->{fixmystreet_id},
worksheet_message => $self->_worksheet_message($args),
assisted_yn => $args->{attributes}->{assisted_yn},
location_of_containers => $args->{attributes}->{location_of_containers},
});
my %worksheet_params;
if ( $args->{service_code} eq 'request_new_container' ) {
%worksheet_params = (
uprn => $args->{attributes}->{uprn},
service_item_name => $args->{attributes}->{service_item_name},
worksheet_reference => $args->{attributes}->{fixmystreet_id},
worksheet_message => '# TODO',
service_code => $args->{service_code},
);
} else {
# Missed collection
%worksheet_params = (
uprn => $args->{attributes}->{uprn},
service_item_name => $args->{attributes}->{service_item_name},
worksheet_reference => $args->{attributes}->{fixmystreet_id},
worksheet_message => $self->_worksheet_message($args),
assisted_yn => $args->{attributes}->{assisted_yn},
location_of_containers =>
$args->{attributes}->{location_of_containers},
);
}

my $worksheet_id = $integration->CreateWorksheet( \%worksheet_params );

my $request = $self->new_request(
service_request_id => $worksheet_id,
Expand All @@ -94,6 +109,8 @@ sub post_service_request {
return $request;
}

# TODO Is this the sub we use, or the identically named sub in
# Open311/Endpoint/Integration/UK/Bexley/Whitespace.pm?
sub _worksheet_message {
my ($self, $args) = @_;

Expand Down

0 comments on commit 49dffe0

Please sign in to comment.