Skip to content

Commit 286b972

Browse files
committed
[Symology] Update when only default ServiceCode.
The category configuration is only needed if the category has a specific ServiceCode. So if no category has a specific ServiceCode, we can assume we can pass through updates regardless of if the category matches one or not. This lets us send through updates on now-deleted category reports.
1 parent 9e4a674 commit 286b972

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

perllib/Open311/Endpoint/Integration/Symology.pm

+7-1
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,15 @@ sub post_service_request {
231231
sub process_service_request_update_args {
232232
my ($self, $args) = @_;
233233

234+
my $services = $self->category_mapping;
235+
my $any_request_service_code;
236+
foreach (keys %$services) {
237+
$any_request_service_code ||= $services->{$_}{parameters}{ServiceCode};
238+
}
239+
234240
my $service_code = $args->{service_code};
235241
my $codes = $self->category_mapping->{$service_code};
236-
die "Could not find category mapping for $service_code\n" unless $codes;
242+
die "Could not find category mapping for $service_code\n" if !$codes && $any_request_service_code;
237243

238244
my $closed = $args->{status} =~ /FIXED|DUPLICATE|NOT_COUNCILS_RESPONSIBILITY|NO_FURTHER_ACTION|INTERNAL_REFERRAL|CLOSED/;
239245

t/open311/endpoint/bexley_symology.t

+20
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,26 @@ subtest "POST with bad rules fails" => sub {
432432
or diag $res->content;
433433
};
434434

435+
subtest "POST update on gone category" => sub {
436+
my $res = $endpoint->run_test_request(
437+
POST => '/servicerequestupdates.json',
438+
jurisdiction_id => 'bexley',
439+
api_key => 'test',
440+
updated_datetime => '2019-03-01T12:00:00Z',
441+
service_code => 'GONE',
442+
service_request_id => 1001,
443+
status => 'OPEN',
444+
description => "This is the update",
445+
update_id => 456,
446+
);
447+
ok !$res->is_success, 'invalid request'
448+
or diag $res->content;
449+
is_deeply decode_json($res->content), [ {
450+
"description" => "Could not find category mapping for GONE\n",
451+
"code" => 500,
452+
} ], 'correct json returned';
453+
};
454+
435455
subtest "POST update OK" => sub {
436456
my $res = $endpoint->run_test_request(
437457
POST => '/servicerequestupdates.json',

t/open311/endpoint/brent.t

+23
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,29 @@ subtest "POST Echo update on closed report OK" => sub {
740740
} ], 'correct json returned';
741741
};
742742

743+
subtest "POST update on gone category OK, as only default ServiceCode" => sub {
744+
my $res = $endpoint->run_test_request(
745+
POST => '/servicerequestupdates.json',
746+
jurisdiction_id => 'brent',
747+
api_key => 'test',
748+
updated_datetime => '2019-03-01T12:00:00Z',
749+
service_code => 'Symology-GONE',
750+
service_request_id => "Symology-1001",
751+
status => 'OPEN',
752+
first_name => 'Bob',
753+
last_name => 'Mould',
754+
description => "This is the update",
755+
service_request_id_ext => 5678,
756+
update_id => 456,
757+
media_url => 'http://example.org/photo/1.jpeg',
758+
);
759+
ok $res->is_success, 'valid request'
760+
or diag $res->content;
761+
is_deeply decode_json($res->content), [ {
762+
'update_id' => 'Symology-456',
763+
} ], 'correct json returned';
764+
};
765+
743766
subtest "POST update OK" => sub {
744767
my $res = $endpoint->run_test_request(
745768
POST => '/servicerequestupdates.json',

0 commit comments

Comments
 (0)