From ab27f463288f889d6c65b15e4c681275dbc2b1ce Mon Sep 17 00:00:00 2001 From: Victoria Mihell-Hale Date: Tue, 3 Sep 2024 20:31:52 +0100 Subject: [PATCH] [Northumberland] Send updates to extra_details to Alloy --- .../Integration/UK/NorthumberlandAlloy.pm | 18 ++++++++++++++---- perllib/Open311/Endpoint/Role/mySociety.pm | 1 + t/open311/endpoint/northumberland_alloy.t | 19 ++++++++++++++----- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/perllib/Open311/Endpoint/Integration/UK/NorthumberlandAlloy.pm b/perllib/Open311/Endpoint/Integration/UK/NorthumberlandAlloy.pm index 69724acf3..7c6c64273 100644 --- a/perllib/Open311/Endpoint/Integration/UK/NorthumberlandAlloy.pm +++ b/perllib/Open311/Endpoint/Integration/UK/NorthumberlandAlloy.pm @@ -88,15 +88,25 @@ sub process_attributes { Adds an update for the status attribute given by C, using the mapping C. +Adds an update for 'extra_details' field ('FMS Extra Details' on Alloy end). + =cut sub update_additional_attributes { my ($self, $args) = @_; - return [{ - attributeCode => $self->config->{update_status_attribute_id}, - value => [ $self->config->{update_status_mapping}->{lc ($args->{status})} ] - }]; + return [ + { attributeCode => $self->config->{update_status_attribute_id}, + value => [ + $self->config->{update_status_mapping} + ->{ lc( $args->{status} ) } + ], + }, + { attributeCode => + $self->config->{inspection_attribute_mapping}{extra_details}, + value => $args->{extra_details}, + }, + ]; } =head2 get_assigned_to_users diff --git a/perllib/Open311/Endpoint/Role/mySociety.pm b/perllib/Open311/Endpoint/Role/mySociety.pm index cd2fe18fb..4fe8f3a53 100644 --- a/perllib/Open311/Endpoint/Role/mySociety.pm +++ b/perllib/Open311/Endpoint/Role/mySociety.pm @@ -185,6 +185,7 @@ sub POST_Service_Request_Update_input_schema { public_anonymity_required => Open311::Endpoint::Schema->enum('//str', 'TRUE', 'FALSE'), email_alerts_requested => Open311::Endpoint::Schema->enum('//str', 'TRUE', 'FALSE'), service_code => $self->get_identifier_type('service_code'), + extra_details => '//str', } }; diff --git a/t/open311/endpoint/northumberland_alloy.t b/t/open311/endpoint/northumberland_alloy.t index 9b0933dec..cbb80596f 100644 --- a/t/open311/endpoint/northumberland_alloy.t +++ b/t/open311/endpoint/northumberland_alloy.t @@ -435,7 +435,13 @@ subtest "check fetch updates" => sub { ], 'correct json returned'; }; -subtest "update status on problem" => sub { +subtest "send updates for problem" => sub { + my $extra_details = <run_test_request( POST => '/servicerequestupdates.json', jurisdiction_id => 'dummy', @@ -443,6 +449,7 @@ subtest "update status on problem" => sub { service_code => 'Damaged_/_Missing_/_Facing_Wrong_Way', description => 'update', status => 'FIXED', + extra_details => $extra_details, service_request_id => '642062376be3a0036bbbb64b', update_id => '1', updated_datetime => '2023-05-15T14:55:55+00:00', @@ -457,15 +464,17 @@ subtest "update status on problem" => sub { my $expected_status_attribute_code = 'attributes_customerRequestMainFMSStatus_63fcb297c9ec9c036ec35dfb'; my $expected_status_attribute_value = '63fcb00c753aed036a5e43a2'; - my $status_match_found = 0; + my $expected_extra_details_attribute_code = 'attributes_customerRequestFMSExtraDetails_646e07533726d8036a7a4022'; + my $expected_extra_details_attribute_value = $extra_details; + foreach (@{ $attributes }) { if ($_->{attributeCode} eq $expected_status_attribute_code) { ok ref($_->{value}) eq 'ARRAY' && $_->{value}[0] eq $expected_status_attribute_value, "value sent in status attribute update is correct"; - $status_match_found = 1; - last; + } + if ($_->{attributeCode} eq $expected_extra_details_attribute_code) { + ok $_->{value} eq $expected_extra_details_attribute_value, "value sent in extra_details attribute update is correct"; } } - ok $status_match_found, "status attribute update was sent"; }; done_testing;