Skip to content

Commit

Permalink
Merge branch 'bartec-open-bulky-requests' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Nov 15, 2024
2 parents 2a00fc6 + 3a82999 commit 73772be
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 8 deletions.
24 changes: 24 additions & 0 deletions perllib/Integrations/Bartec.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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) = @_;

Expand Down
8 changes: 8 additions & 0 deletions perllib/Open311/Endpoint/Integration/Bartec.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
31 changes: 24 additions & 7 deletions t/open311/endpoint/bartec.t
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ my %responses = (
</AuthenticateResponse>',
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,
Expand Down Expand Up @@ -551,7 +552,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',
Expand Down Expand Up @@ -651,7 +652,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",
Expand Down Expand Up @@ -762,7 +763,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',
Expand Down Expand Up @@ -838,7 +839,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 => {
Expand Down Expand Up @@ -914,11 +915,19 @@ 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=',
Public => 'true',
ServiceRequestID => '0001',
ServiceRequestID => '1234',
DateTaken => '2020-06-17T17:28:30+01:00',
Comment => 'Bulky waste photo',
AttachedDocument => {
Expand Down Expand Up @@ -1044,7 +1053,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 => {
Expand Down Expand Up @@ -1130,11 +1139,19 @@ 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=',
Public => 'true',
ServiceRequestID => '0001',
ServiceRequestID => '1234',
DateTaken => '2020-06-17T17:28:30+01:00',
Comment => 'Bulky waste photo',
AttachedDocument => {
Expand Down
8 changes: 7 additions & 1 deletion t/open311/endpoint/xml/bartec/servicerequests_get_0001.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<ServiceRequests_GetResponse>
<ServiceRequests_GetResult>
<ServiceRequest><id>0001</id></ServiceRequest>
<ServiceRequest>
<id>1234</id>
<ServiceCode>0001</ServiceCode>
<ServiceType>
<ID>238</ID>
</ServiceType>
</ServiceRequest>
</ServiceRequests_GetResult>
</ServiceRequests_GetResponse>
11 changes: 11 additions & 0 deletions t/open311/endpoint/xml/bartec/servicerequests_status_get.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@
<Comments/>
</RecordStamp>
</ServiceStatus>
<ServiceStatus>
<ID xmlns="http://www.bartec-systems.com">2388</ID>
<Status xmlns="http://www.bartec-systems.com">OPEN</Status>
<SequenceNumber xmlns="http://www.bartec-systems.com">2</SequenceNumber>
<ServiceTypeID xmlns="http://www.bartec-systems.com">238</ServiceTypeID>
<RecordStamp xmlns="http://www.bartec-systems.com">
<AddedBy>bartec</AddedBy>
<DateAdded>2019-02-22T16:11:11.953</DateAdded>
<Comments/>
</RecordStamp>
</ServiceStatus>
<Errors>
<Result xmlns="http://www.bartec-systems.com">0</Result>
<Message xmlns="http://www.bartec-systems.com"/>
Expand Down

0 comments on commit 73772be

Please sign in to comment.