From 2129f939b0b85e716fb79de3b27e11c2282b0b9d Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 13 Nov 2024 16:12:58 +0000 Subject: [PATCH 1/2] [Bartec] Use separate ID/ServiceCode in test. --- t/open311/endpoint/bartec.t | 14 +++++++------- .../xml/bartec/servicerequests_get_0001.xml | 5 ++++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/t/open311/endpoint/bartec.t b/t/open311/endpoint/bartec.t index 37235ad8b..4417bf80c 100644 --- a/t/open311/endpoint/bartec.t +++ b/t/open311/endpoint/bartec.t @@ -551,7 +551,7 @@ subtest "check send basic report" => sub { my $note_sent = SOAP::Deserializer->deserialize( $sent{ServiceRequest_Note_Create} ); is_deeply $note_sent->body->{ServiceRequest_Note_Create}, { token => 'ABC=', - ServiceRequestID => '0001', + ServiceRequestID => '1234', NoteTypeID => 11, Note => "a title\n\na description", Comment => 'Note added by FixMyStreet', @@ -651,7 +651,7 @@ subtest "check send report with extended info & ampersands " => sub { my $note_sent = SOAP::Deserializer->deserialize( $sent{ServiceRequest_Note_Create} ); is_deeply $note_sent->body->{ServiceRequest_Note_Create}, { token => 'ABC=', - ServiceRequestID => '0001', + ServiceRequestID => '1234', NoteTypeID => 11, Note => "a title\n\na description & some text", Comment => "Logged by staff\@example.org\n\nNote added by FixMyStreet", @@ -762,7 +762,7 @@ subtest "check send report with assets" => sub { my $note_sent = SOAP::Deserializer->deserialize( $sent{ServiceRequest_Note_Create} ); is_deeply $note_sent->body->{ServiceRequest_Note_Create}, { token => 'ABC=', - ServiceRequestID => '0001', + ServiceRequestID => '1234', NoteTypeID => 11, Note => "a title\n\na description\n\nAsset id: 8080\nAsset detail: this is an asset", Comment => 'Note added by FixMyStreet', @@ -838,7 +838,7 @@ subtest "check send report with a photo" => sub { is_deeply $sr_doc->body->{ServiceRequest_Document_Create}, { token => 'ABC=', Public => 'true', - ServiceRequestID => '0001', + ServiceRequestID => '1234', DateTaken => '2020-06-17T17:28:30+01:00', Comment => 'Photo uploaded from FixMyStreet', AttachedDocument => { @@ -918,7 +918,7 @@ subtest "check send bulky report with a photo" => sub { is_deeply $sr_doc->body->{ServiceRequest_Document_Create}, { token => 'ABC=', Public => 'true', - ServiceRequestID => '0001', + ServiceRequestID => '1234', DateTaken => '2020-06-17T17:28:30+01:00', Comment => 'Bulky waste photo', AttachedDocument => { @@ -1044,7 +1044,7 @@ subtest "check send report with a photo as an upload" => sub { is_deeply $sr_doc->body->{ServiceRequest_Document_Create}, { token => 'ABC=', Public => 'true', - ServiceRequestID => '0001', + ServiceRequestID => '1234', DateTaken => '2020-06-17T17:28:30+01:00', Comment => 'Photo uploaded from FixMyStreet', AttachedDocument => { @@ -1134,7 +1134,7 @@ subtest "check send bulky report with a photo as an upload" => sub { is_deeply $sr_doc->body->{ServiceRequest_Document_Create}, { token => 'ABC=', Public => 'true', - ServiceRequestID => '0001', + ServiceRequestID => '1234', DateTaken => '2020-06-17T17:28:30+01:00', Comment => 'Bulky waste photo', AttachedDocument => { diff --git a/t/open311/endpoint/xml/bartec/servicerequests_get_0001.xml b/t/open311/endpoint/xml/bartec/servicerequests_get_0001.xml index 37d9fb55e..9819f1fd4 100644 --- a/t/open311/endpoint/xml/bartec/servicerequests_get_0001.xml +++ b/t/open311/endpoint/xml/bartec/servicerequests_get_0001.xml @@ -1,5 +1,8 @@ - 0001 + + 1234 + 0001 + From 3a82999ace49472fdbdc62a543b356afcc57fb25 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 13 Nov 2024 16:13:50 +0000 Subject: [PATCH 2/2] [Bartec] Set open status on bulky collections. --- perllib/Integrations/Bartec.pm | 24 +++++++++++++++++++ .../Open311/Endpoint/Integration/Bartec.pm | 8 +++++++ t/open311/endpoint/bartec.t | 17 +++++++++++++ .../xml/bartec/servicerequests_get_0001.xml | 3 +++ .../xml/bartec/servicerequests_status_get.xml | 11 +++++++++ 5 files changed, 63 insertions(+) diff --git a/perllib/Integrations/Bartec.pm b/perllib/Integrations/Bartec.pm index a0bdaabb7..7b9ac9a3c 100644 --- a/perllib/Integrations/Bartec.pm +++ b/perllib/Integrations/Bartec.pm @@ -206,6 +206,17 @@ sub _methods { namespace => 'http://bartec-systems.com/', parameters => [], }, + 'ServiceRequest_Status_Set' => { + endpoint => $self->collective_endpoint, + soapaction => 'http://bartec-systems.com/ServiceRequest_Status_Set', + namespace => 'http://bartec-systems.com/', + parameters => [ + SOAP::Data->new(name => 'token', type => 'string'), + SOAP::Data->new(name => 'ServiceCode', type => 'string'), + SOAP::Data->new(name => 'StatusID', type => 'int'), + SOAP::Data->new(name => 'Comments', type => 'string'), + ], + }, 'ServiceRequest_Document_Create' => { endpoint => $self->collective_endpoint, soapaction => 'http://bartec-systems.com/ServiceRequest_Document_Create', @@ -462,6 +473,19 @@ sub ServiceRequest_Create { return $self->_wrapper('ServiceRequest_Create', 1, $elem); } +sub ServiceRequest_Status_Set { + my ($self, $sr, $status) = @_; + + my $service_code = $sr->{ServiceRequest}{ServiceCode}; + my $service_type_id = $sr->{ServiceRequest}{ServiceType}{ID}; + + my $statuses = $self->ServiceRequests_Statuses_Get; + # e.g. 2388 for OPEN Bulky Collection + my ($open_status) = grep { $_->{Status} eq $status && $_->{ServiceTypeID} eq $service_type_id } @{ $statuses->{ServiceStatus} }; + + return $self->_wrapper('ServiceRequest_Status_Set', 0, $service_code, $open_status->{ID}, ''); +} + sub ServiceRequest_Document_Create { my ($self, $args) = @_; diff --git a/perllib/Open311/Endpoint/Integration/Bartec.pm b/perllib/Open311/Endpoint/Integration/Bartec.pm index 92ee4f5f4..1a0df6042 100644 --- a/perllib/Open311/Endpoint/Integration/Bartec.pm +++ b/perllib/Open311/Endpoint/Integration/Bartec.pm @@ -206,6 +206,14 @@ sub post_service_request { return $request; }; + if ($service->service_name eq 'Bulky collection') { + try { + $integ->ServiceRequest_Status_Set($sr, 'OPEN'); + } catch { + $self->logger->warn("failed to open bulky collection " . $res->{ServiceCode} . " (FMS ID " . $args->{attributes}->{fixmystreet_id} . ")"); + }; + } + try { $self->_attach_note( $args, $sr ); } catch { diff --git a/t/open311/endpoint/bartec.t b/t/open311/endpoint/bartec.t index 4417bf80c..33dab591a 100644 --- a/t/open311/endpoint/bartec.t +++ b/t/open311/endpoint/bartec.t @@ -100,6 +100,7 @@ my %responses = ( ', ServiceRequests_Types_Get => path(__FILE__)->parent(1)->realpath->child('xml/bartec/servicerequests_types_get.xml')->slurp, ServiceRequest_Create => \&ServiceRequest_Create, + ServiceRequest_Status_Set => '', ServiceRequests_Statuses_Get => path(__FILE__)->parent(1)->realpath->child('xml/bartec/servicerequests_status_get.xml')->slurp, Premises_Get => \&Premises_Get, ServiceRequests_History_Get => \&ServiceRequests_History_Get, @@ -914,6 +915,14 @@ subtest "check send bulky report with a photo" => sub { ServiceCode => '0001', }, "correct request for servicerequests_get"; + my $status_set = SOAP::Deserializer->deserialize( $sent{ServiceRequest_Status_Set} ); + is_deeply $status_set->body->{ServiceRequest_Status_Set}, { + token => 'ABC=', + ServiceCode => '0001', + StatusID => '2388', + Comments => '', + }, "correct request for servicerequests_get"; + my $sr_doc = SOAP::Deserializer->deserialize( $sent{ServiceRequest_Document_Create} ); is_deeply $sr_doc->body->{ServiceRequest_Document_Create}, { token => 'ABC=', @@ -1130,6 +1139,14 @@ subtest "check send bulky report with a photo as an upload" => sub { ServiceCode => '0001', }, "correct request for servicerequests_get"; + my $status_set = SOAP::Deserializer->deserialize( $sent{ServiceRequest_Status_Set} ); + is_deeply $status_set->body->{ServiceRequest_Status_Set}, { + token => 'ABC=', + ServiceCode => '0001', + StatusID => '2388', + Comments => '', + }, "correct request for servicerequests_get"; + my $sr_doc = SOAP::Deserializer->deserialize( $sent{ServiceRequest_Document_Create} ); is_deeply $sr_doc->body->{ServiceRequest_Document_Create}, { token => 'ABC=', diff --git a/t/open311/endpoint/xml/bartec/servicerequests_get_0001.xml b/t/open311/endpoint/xml/bartec/servicerequests_get_0001.xml index 9819f1fd4..356af370e 100644 --- a/t/open311/endpoint/xml/bartec/servicerequests_get_0001.xml +++ b/t/open311/endpoint/xml/bartec/servicerequests_get_0001.xml @@ -3,6 +3,9 @@ 1234 0001 + + 238 + diff --git a/t/open311/endpoint/xml/bartec/servicerequests_status_get.xml b/t/open311/endpoint/xml/bartec/servicerequests_status_get.xml index 65a9ec91a..fbb078eb2 100644 --- a/t/open311/endpoint/xml/bartec/servicerequests_status_get.xml +++ b/t/open311/endpoint/xml/bartec/servicerequests_status_get.xml @@ -110,6 +110,17 @@ + + 2388 + OPEN + 2 + 238 + + bartec + 2019-02-22T16:11:11.953 + + + 0