From 879ec41fd41b72c56088e2641fa59314fa5ff397 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 12 Sep 2023 13:52:42 +0100 Subject: [PATCH] [SLWP] Submit cancellation action upon update. --- perllib/Open311/Endpoint/Role/SLWP.pm | 5 +++++ t/open311/endpoint/kingston.t | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/perllib/Open311/Endpoint/Role/SLWP.pm b/perllib/Open311/Endpoint/Role/SLWP.pm index e0afb8d8c..1b83a68cb 100644 --- a/perllib/Open311/Endpoint/Role/SLWP.pm +++ b/perllib/Open311/Endpoint/Role/SLWP.pm @@ -41,6 +41,11 @@ around post_service_request_update => sub { $args->{description} = ''; # Blank out so nothing sent to Echo now } + if ($args->{description} eq 'Booking cancelled by customer') { + $args->{actiontype_id} = 8; + $args->{datatype_id} = 0; + } + my $result = $class->$orig($args); return $result; diff --git a/t/open311/endpoint/kingston.t b/t/open311/endpoint/kingston.t index 69146f172..313a29cf2 100644 --- a/t/open311/endpoint/kingston.t +++ b/t/open311/endpoint/kingston.t @@ -160,4 +160,25 @@ subtest "POST a successful payment" => sub { } ], 'correct json returned'; }; +subtest "POST a cancellation" => sub { + my $res = $endpoint->run_test_request( + POST => '/servicerequestupdates.json', + api_key => 'test', + updated_datetime => '2023-09-01T19:00:00+01:00', + service_request_id => '123cancel', + update_id => 456, + status => 'OPEN', + description => 'Booking cancelled by customer', + first_name => 'Bob', + last_name => 'Mould', + ); + ok $res->is_success, 'valid request' + or diag $res->content; + + is_deeply decode_json($res->content), + [ { + "update_id" => 'ABC', + } ], 'correct json returned'; +}; + done_testing;