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 37235ad8b..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,
@@ -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',
@@ -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",
@@ -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',
@@ -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 => {
@@ -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 => {
@@ -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 => {
@@ -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 => {
diff --git a/t/open311/endpoint/xml/bartec/servicerequests_get_0001.xml b/t/open311/endpoint/xml/bartec/servicerequests_get_0001.xml
index 37d9fb55e..356af370e 100644
--- a/t/open311/endpoint/xml/bartec/servicerequests_get_0001.xml
+++ b/t/open311/endpoint/xml/bartec/servicerequests_get_0001.xml
@@ -1,5 +1,11 @@
- 0001
+
+ 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