Skip to content

Commit

Permalink
[SLWP] Submit cancellation action upon update.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Jan 18, 2024
1 parent 71307e6 commit 879ec41
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions perllib/Open311/Endpoint/Role/SLWP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 21 additions & 0 deletions t/open311/endpoint/kingston.t
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 879ec41

Please sign in to comment.