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 Oct 10, 2023
1 parent 3d42be1 commit 3d61060
Show file tree
Hide file tree
Showing 2 changed files with 28 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 @@ -30,6 +30,11 @@ around post_service_request_update => sub {
$args->{datatype_id} = 0;
}

if ($args->{description} eq 'Booking cancelled by customer') {
$args->{actiontype_id} = 8;
$args->{datatype_id} = 0;
}

my $result = $class->$orig($args);

if ($args->{description} =~ /Payment confirmed, reference (.*), amount (.*)/) {
Expand Down
23 changes: 23 additions & 0 deletions t/open311/endpoint/kingston.t
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ $soap_lite->mock(call => sub {
my $actiontype_id = $params[0]->value;
if ($ref eq '123pay') {
is $actiontype_id, 348;
} elsif ($ref eq '123cancel') {
is $actiontype_id, 8;
}
return SOAP::Result->new(result => { EventActionGuid => 'ABC' });
} else {
Expand Down Expand Up @@ -162,4 +164,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 3d61060

Please sign in to comment.