Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bexley][Whitespace] Use custom message for worksheet #333

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions perllib/Open311/Endpoint/Integration/UK/Bexley/Whitespace.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,11 @@ around BUILDARGS => sub {
return $class->$orig(%args);
};

sub _worksheet_message {
my ($self, $args) = @_;

return "Assisted collection? $args->{attributes}->{assisted_yn}\n\n" .
"Location of containers: $args->{attributes}->{location_of_containers}\n";
}

__PACKAGE__->run_if_script;
8 changes: 7 additions & 1 deletion perllib/Open311/Endpoint/Integration/Whitespace.pm
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ sub post_service_request {
uprn => $args->{attributes}->{uprn},
service_item_name => $args->{attributes}->{service_item_name},
worksheet_reference => $args->{attributes}->{fixmystreet_id},
worksheet_message => $args->{description},
worksheet_message => $self->_worksheet_message($args),
assisted_yn => $args->{attributes}->{assisted_yn},
location_of_containers => $args->{attributes}->{location_of_containers},
});
Expand All @@ -94,4 +94,10 @@ sub post_service_request {
return $request;
}

sub _worksheet_message {
my ($self, $args) = @_;

return $args->{description};
}

1;
31 changes: 31 additions & 0 deletions t/open311/endpoint/bexley.t
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,35 @@ subtest "POST update OK" => sub {
} ], 'correct json returned';
};

subtest "Whitespace worksheets use Bexley's custom message" => sub {
my $ws = Test::MockModule->new('Integrations::Whitespace');
$ws->mock(CreateWorksheet => sub {
my ($self, $args) = @_;
is $args->{worksheet_message}, "Assisted collection? Yes\n\nLocation of containers: location of containers\n";
return 1001;
});
my $res = $endpoint->run_test_request(
POST => '/requests.json',
api_key => 'test',
service_code => 'Whitespace-WS1',
first_name => 'Bob',
last_name => 'Mould',
description => "This is the details",
lat => 51,
long => -1,
'attribute[uprn]' => 1000001,
'attribute[service_item_name]' => 'service item name',
'attribute[fixmystreet_id]' => 'fixmystreet id',
'attribute[assisted_yn]' => 'Yes',
'attribute[location_of_containers]' => 'location of containers',
);
ok $res->is_success, 'valid request'
or diag $res->content;

is_deeply decode_json($res->content),
[ {
"service_request_id" => "Whitespace-1001"
} ], 'correct json returned';
};

done_testing;
Loading