Skip to content

Commit

Permalink
[Bartec] Set open status on bulky collections.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Nov 13, 2024
1 parent 2129f93 commit e5f4dbe
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
23 changes: 23 additions & 0 deletions perllib/Integrations/Bartec.pm
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,16 @@ 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'),
],
},
'ServiceRequest_Document_Create' => {
endpoint => $self->collective_endpoint,
soapaction => 'http://bartec-systems.com/ServiceRequest_Document_Create',
Expand Down Expand Up @@ -462,6 +472,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
15 changes: 15 additions & 0 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 @@ -914,6 +915,13 @@ 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',
}, "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=',
Expand Down Expand Up @@ -1130,6 +1138,13 @@ 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',
}, "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=',
Expand Down
3 changes: 3 additions & 0 deletions t/open311/endpoint/xml/bartec/servicerequests_get_0001.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<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 e5f4dbe

Please sign in to comment.