From ce1b3ec61fdaa954c26e55b8ce8cd1ad619b3538 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 29 Jun 2020 15:00:55 +0100 Subject: [Bromley] Add waste service lookup. This creates an integration to view bin collection days, and placeholders for the start of a non-map property-based reporting flow. --- perllib/Integrations/Echo.pm | 278 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 278 insertions(+) create mode 100644 perllib/Integrations/Echo.pm (limited to 'perllib/Integrations/Echo.pm') diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm new file mode 100644 index 000000000..3bcbfc69b --- /dev/null +++ b/perllib/Integrations/Echo.pm @@ -0,0 +1,278 @@ +package Integrations::Echo; + +use strict; +use warnings; +use Moo; +use Tie::IxHash; + +has attr => ( is => 'ro', default => 'http://www.twistedfish.com/xmlns/echo/api/v1' ); +has action => ( is => 'lazy', default => sub { $_[0]->attr . "/Service/" } ); +has username => ( is => 'ro' ); +has password => ( is => 'ro' ); +has url => ( is => 'ro' ); + +has sample_data => ( is => 'ro', default => 0 ); + +has endpoint => ( + is => 'lazy', + default => sub { + my $self = shift; + $ENV{PERL_LWP_SSL_CA_PATH} = '/etc/ssl/certs'; + SOAP::Lite->soapversion(1.2); + my $soap = SOAP::Lite->on_action( sub { $self->action . $_[1]; } )->proxy($self->url); + $soap->serializer->register_ns("http://schemas.microsoft.com/2003/10/Serialization/Arrays", 'msArray'), + return $soap; + }, +); + +has security => ( + is => 'lazy', + default => sub { + my $self = shift; + SOAP::Header->name("Security")->attr({ + 'mustUnderstand' => 'true', + 'xmlns' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' + })->value( + \SOAP::Header->name( + "UsernameToken" => \SOAP::Header->value( + SOAP::Header->name('Username', $self->username), + SOAP::Header->name('Password', $self->password), + ) + ) + ); + }, +); + +sub action_hdr { + my ($self, $method) = @_; + SOAP::Header->name("Action")->attr({ + 'xmlns' => 'http://www.w3.org/2005/08/addressing', + })->value( + $self->action . $method + ); +} + +sub call { + my ($self, $method, @params) = @_; + + require SOAP::Lite; + @params = make_soap_structure(@params); + my $res = $self->endpoint->call( + SOAP::Data->name($method)->attr({ xmlns => $self->attr }), + $self->security, + $self->action_hdr($method), + @params + ); + $res = $res->result; + return $res; +} + +# Given a list of task handles as two-value array refs (as returned in e.g. the +# LastInstance part of GetServiceUnitsForObject), returns a list of the +# corresponding tasks. +sub GetTasks { + my $self = shift; + + my @refs; + foreach my $ref (@_) { + tie(my %a, 'Tie::IxHash', + Key => 'Handle', + Type => "Task", + Value => [ + { 'msArray:anyType' => $ref->[0] }, + { 'msArray:anyType' => $ref->[1] }, + ], + ); + push @refs, \%a; + } + + return [ + { Ref => { Value => { anyType => [ 123, 456 ] } }, CompletedDate => undef }, + { Ref => { Value => { anyType => [ 234, 567 ] } }, CompletedDate => { DateTime => '2020-05-27T10:00:00Z' } }, + { Ref => { Value => { anyType => [ 345, 678 ] } }, CompletedDate => undef }, + { Ref => { Value => { anyType => [ 456, 789 ] } }, CompletedDate => undef }, + ] if $self->sample_data; + + # This creates XML of the form ......... + # uncoverable statement + my $res = $self->call('GetTasks', + taskRefs => [ + map { { ObjectRef => $_ } } @refs + ], + options => { + IncludePoints => 'false', + }, + ); + # uncoverable statement + return force_arrayref($res, 'Task'); +} + +sub _uprn_ref { + require SOAP::Lite; + my $uprn = shift; + tie(my %obj, 'Tie::IxHash', + Key => 'Uprn', + Type => 'PointAddress', + Value => [ + { 'msArray:anyType' => SOAP::Data->value($uprn)->type('string') }, + ], + ); + return \%obj; +} + +sub GetPointAddress { + my $self = shift; + my $uprn = shift; + my $obj = _uprn_ref($uprn); + return { + Id => '12345', + PointType => 'PointAddress', + PointAddressType => { Name => 'House' }, + Coordinates => { GeoPoint => { Latitude => 51.401546, Longitude => 0.015415 } }, + Description => '2 Example Street, Bromley, BR1 1AA', + } if $self->sample_data; + $self->call('GetPointAddress', ref => $obj); +} + +# Given a postcode, returns an arrayref of addresses +sub FindPoints { + my $self = shift; + my $pc = shift; + tie(my %obj, 'Tie::IxHash', + PointType => 'PointAddress', + Postcode => $pc, + ); + return [ + { Description => '1 Example Street, Bromley, BR1 1AA', SharedRef => { Value => { anyType => 1000000001 } } }, + { Description => '2 Example Street, Bromley, BR1 1AA', SharedRef => { Value => { anyType => 1000000002 } } }, + { Description => '3 Example Street, Bromley, BR1 1AA', SharedRef => { Value => { anyType => 1000000003 } } }, + { Description => '4 Example Street, Bromley, BR1 1AA', SharedRef => { Value => { anyType => 1000000004 } } }, + { Description => '5 Example Street, Bromley, BR1 1AA', SharedRef => { Value => { anyType => 1000000005 } } }, + ] if $self->sample_data; + my $res = $self->call('FindPoints', query => \%obj); + return force_arrayref($res, 'PointInfo'); +} + +sub GetServiceUnitsForObject { + my $self = shift; + my $uprn = shift; + my $obj = _uprn_ref($uprn); + my $from = DateTime->now->set_time_zone(FixMyStreet->local_time_zone); + return [ { + Id => 1001, + ServiceId => 101, + ServiceName => 'Refuse collection', + ServiceTasks => { ServiceTask => { + Id => 401, + ScheduleDescription => 'every Wednesday', + ServiceTaskSchedules => { ServiceTaskSchedule => { + EndDate => { DateTime => '2050-01-01T00:00:00Z' }, + NextInstance => { + CurrentScheduledDate => { DateTime => '2020-06-03T00:00:00Z' }, + OriginalScheduledDate => { DateTime => '2020-06-03T00:00:00Z' }, + }, + LastInstance => { + CurrentScheduledDate => { DateTime => '2020-05-27T00:00:00Z' }, + }, + } }, + } }, + }, { + Id => 1002, + ServiceId => 537, + ServiceName => 'Paper recycling collection', + ServiceTasks => { ServiceTask => { + Id => 402, + ScheduleDescription => 'every other Wednesday', + ServiceTaskSchedules => { ServiceTaskSchedule => { + EndDate => { DateTime => '2050-01-01T00:00:00Z' }, + NextInstance => { + CurrentScheduledDate => { DateTime => '2020-06-10T00:00:00Z' }, + OriginalScheduledDate => { DateTime => '2020-06-10T00:00:00Z' }, + }, + LastInstance => { + CurrentScheduledDate => { DateTime => '2020-05-27T00:00:00Z' }, + }, + } }, + } }, + }, { + Id => 1003, + ServiceId => 535, + ServiceName => 'Domestic Container Mix Collection', + ServiceTasks => { ServiceTask => { + Id => 403, + ScheduleDescription => 'every other Wednesday', + ServiceTaskSchedules => { ServiceTaskSchedule => { + EndDate => { DateTime => '2050-01-01T00:00:00Z' }, + NextInstance => { + CurrentScheduledDate => { DateTime => '2020-06-03T00:00:00Z' }, + OriginalScheduledDate => { DateTime => '2020-06-03T00:00:00Z' }, + }, + LastInstance => { + CurrentScheduledDate => { DateTime => '2020-05-20T00:00:00Z' }, + }, + } }, + } }, + }, { + Id => 1004, + ServiceId => 542, + ServiceName => 'Food waste collection', + ServiceTasks => { ServiceTask => { + Id => 404, + ScheduleDescription => 'every other Monday', + ServiceTaskSchedules => { ServiceTaskSchedule => [ { + EndDate => { DateTime => '2020-01-01T00:00:00Z' }, + LastInstance => { + CurrentScheduledDate => { DateTime => '2019-12-31T00:00:00Z' }, + }, + }, { + EndDate => { DateTime => '2050-01-01T00:00:00Z' }, + NextInstance => { + CurrentScheduledDate => { DateTime => '2020-06-02T00:00:00Z' }, + OriginalScheduledDate => { DateTime => '2020-06-01T00:00:00Z' }, + }, + LastInstance => { + CurrentScheduledDate => { DateTime => '2020-05-18T00:00:00Z' }, + }, + } ] }, + } }, + } ] if $self->sample_data; + # uncoverable statement + my $res = $self->call('GetServiceUnitsForObject', + objectRef => $obj, + query => ixhash( + From => dt_to_hash($from), + IncludeTaskInstances => 'true', + ), + ); + # uncoverable statement + return force_arrayref($res, 'ServiceUnit'); +} + +sub force_arrayref { + my ($res, $key) = @_; + return [] unless $res; + my $data = $res->{$key}; + return [] unless $data; + $data = [ $data ] unless ref $data eq 'ARRAY'; + return $data; +} + +sub make_soap_structure { + my @out; + for (my $i=0; $i<@_; $i+=2) { + my $name = $_[$i] =~ /:/ ? $_[$i] : $_[$i]; + my $v = $_[$i+1]; + my $val = $v; + my $d = SOAP::Data->name($name); + if (ref $v eq 'HASH') { + $val = \SOAP::Data->value(make_soap_structure(%$v)); + } elsif (ref $v eq 'ARRAY') { + my @map = map { make_soap_structure(%$_) } @$v; + $val = \SOAP::Data->value(SOAP::Data->name('dummy' => @map)); + } + push @out, $d->value($val); + } + return @out; +} + +1; -- cgit v1.2.3 From bc19b9e00f3d59a2f0694f2fcc3aab54fef35e9e Mon Sep 17 00:00:00 2001 From: M Somerville Date: Mon, 19 Oct 2020 11:05:04 +0100 Subject: [Bromley] ICal generation. --- perllib/Integrations/Echo.pm | 58 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'perllib/Integrations/Echo.pm') diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm index 3bcbfc69b..7dc2e6948 100644 --- a/perllib/Integrations/Echo.pm +++ b/perllib/Integrations/Echo.pm @@ -2,8 +2,10 @@ package Integrations::Echo; use strict; use warnings; +use DateTime; use Moo; use Tie::IxHash; +use FixMyStreet; has attr => ( is => 'ro', default => 'http://www.twistedfish.com/xmlns/echo/api/v1' ); has action => ( is => 'lazy', default => sub { $_[0]->attr . "/Service/" } ); @@ -21,6 +23,7 @@ has endpoint => ( SOAP::Lite->soapversion(1.2); my $soap = SOAP::Lite->on_action( sub { $self->action . $_[1]; } )->proxy($self->url); $soap->serializer->register_ns("http://schemas.microsoft.com/2003/10/Serialization/Arrays", 'msArray'), + $soap->serializer->register_ns("http://schemas.datacontract.org/2004/07/System", 'dataContract'); return $soap; }, ); @@ -248,6 +251,61 @@ sub GetServiceUnitsForObject { return force_arrayref($res, 'ServiceUnit'); } +sub GetServiceTaskInstances { + my ($self, @tasks) = @_; + + my @objects; + foreach (@tasks) { + my $obj = ixhash( + Key => 'Id', + Type => 'ServiceTask', + Value => [ + { 'msArray:anyType' => $_ }, + ], + ); + push @objects, { ObjectRef => $obj }; + } + my $start = DateTime->now->set_time_zone(FixMyStreet->local_time_zone)->truncate( to => 'day' ); + my $end = $start->clone->add(months => 3); + my $query = ixhash( + From => dt_to_hash($start), + To => dt_to_hash($end), + ); + return [ + { ServiceTaskRef => { Value => { anyType => 401 } }, + Instances => { ScheduledTaskInfo => [ + { CurrentScheduledDate => { DateTime => '2020-07-01T00:00:00Z' } }, + ] } + }, + { ServiceTaskRef => { Value => { anyType => 402 } }, + Instances => { ScheduledTaskInfo => [ + { CurrentScheduledDate => { DateTime => '2020-07-08T00:00:00Z' } }, + ] } + }, + ] if $self->sample_data; + # uncoverable statement + my $res = $self->call('GetServiceTaskInstances', + serviceTaskRefs => \@objects, + query => $query, + ); + return force_arrayref($res, 'ServiceTaskInstances'); +} + +sub ixhash { + tie (my %data, 'Tie::IxHash', @_); + return \%data; +} + +sub dt_to_hash { + my $dt = shift; + my $utc = $dt->clone->set_time_zone('UTC'); + $dt = ixhash( + 'dataContract:DateTime' => $utc->ymd . 'T' . $utc->hms . 'Z', + 'dataContract:OffsetMinutes' => $dt->offset / 60, + ); + return $dt; +} + sub force_arrayref { my ($res, $key) = @_; return [] unless $res; -- cgit v1.2.3 From d90e1157ee31c374248da0db42b70456c37ddd5b Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 19 Jun 2020 14:56:07 +0100 Subject: [Bromley] Look for open events. --- perllib/Integrations/Echo.pm | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'perllib/Integrations/Echo.pm') diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm index 7dc2e6948..205e1178f 100644 --- a/perllib/Integrations/Echo.pm +++ b/perllib/Integrations/Echo.pm @@ -291,6 +291,46 @@ sub GetServiceTaskInstances { return force_arrayref($res, 'ServiceTaskInstances'); } +sub GetEventsForObject { + my ($self, $id, $type) = @_; + my $from = DateTime->now->set_time_zone(FixMyStreet->local_time_zone)->subtract(months => 3); + return [ { + # Missed collection for service 542 + EventTypeId => 2100, + ServiceId => 542, + }, { + # Request for a new paper container + EventTypeId => 2104, + Data => { ExtensibleDatum => [ + { Value => 2, DatatypeName => 'Source' }, + { + ChildData => { ExtensibleDatum => [ + { Value => 1, DatatypeName => 'Action' }, + { Value => 12, DatatypeName => 'Container Type' }, + ] }, + }, + ] }, + ServiceId => 535, + } ] if $self->sample_data; + # uncoverable statement + my $res = $self->call('GetEventsForObject', + objectRef => ixhash( + Key => 'Id', + Type => 'PointAddress', + Value => { 'msArray:anyType' => $id }, + ), + query => ixhash( + $type ? (EventTypeRef => ixhash( + Key => 'Id', + Type => 'EventType', + Value => { 'msArray:anyType' => $type }, + )) : (), + From => dt_to_hash($from), + ), + ); + return force_arrayref($res, 'Event'); +} + sub ixhash { tie (my %data, 'Tie::IxHash', @_); return \%data; -- cgit v1.2.3 From b8fb6677b54f99e53105de0e242be94969a53567 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 19 Jun 2020 17:28:47 +0100 Subject: [Bromley] Treat some enquiries same as missed. In terms of within-two-day and no existing open event. --- perllib/Integrations/Echo.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'perllib/Integrations/Echo.pm') diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm index 205e1178f..48a0edc6c 100644 --- a/perllib/Integrations/Echo.pm +++ b/perllib/Integrations/Echo.pm @@ -295,9 +295,12 @@ sub GetEventsForObject { my ($self, $id, $type) = @_; my $from = DateTime->now->set_time_zone(FixMyStreet->local_time_zone)->subtract(months => 3); return [ { - # Missed collection for service 542 + # Missed collection for service 542 (food waste) EventTypeId => 2100, ServiceId => 542, + }, { # And a gate not closed + EventTypeId => 2118, + ServiceId => 542, }, { # Request for a new paper container EventTypeId => 2104, -- cgit v1.2.3 From cabc4f91d55b952ab2521ec85ec745de4c354d8c Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 23 Jun 2020 17:29:04 +0100 Subject: [Bromley] Script to update open waste reports. --- perllib/Integrations/Echo.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'perllib/Integrations/Echo.pm') diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm index 48a0edc6c..9a5b65ec2 100644 --- a/perllib/Integrations/Echo.pm +++ b/perllib/Integrations/Echo.pm @@ -291,6 +291,24 @@ sub GetServiceTaskInstances { return force_arrayref($res, 'ServiceTaskInstances'); } +sub GetEvent { + my ($self, $guid) = @_; + $self->call('GetEvent', ref => ixhash( + Key => 'Guid', + Type => 'Event', + Value => { 'msArray:anyType' => $guid }, + )); +} + +sub GetEventType { + my ($self, $id) = @_; + $self->call('GetEventType', ref => ixhash( + Key => 'Id', + Type => 'EventType', + Value => { 'msArray:anyType' => $id }, + )); +} + sub GetEventsForObject { my ($self, $id, $type) = @_; my $from = DateTime->now->set_time_zone(FixMyStreet->local_time_zone)->subtract(months => 3); -- cgit v1.2.3 From 49dff7e4e4b7b6572cbf75ccb94383fe516f0e7c Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 13 Jul 2020 17:43:09 +0100 Subject: [Bromley] Fetch/show completion date/resolution. --- perllib/Integrations/Echo.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'perllib/Integrations/Echo.pm') diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm index 9a5b65ec2..c9eab0cfc 100644 --- a/perllib/Integrations/Echo.pm +++ b/perllib/Integrations/Echo.pm @@ -91,7 +91,12 @@ sub GetTasks { return [ { Ref => { Value => { anyType => [ 123, 456 ] } }, CompletedDate => undef }, - { Ref => { Value => { anyType => [ 234, 567 ] } }, CompletedDate => { DateTime => '2020-05-27T10:00:00Z' } }, + { + Ref => { Value => { anyType => [ 234, 567 ] } }, + State => { Name => 'Completed' }, + Resolution => { Name => 'Wrong Bin Out' }, + CompletedDate => { DateTime => '2020-05-27T10:00:00Z' } + }, { Ref => { Value => { anyType => [ 345, 678 ] } }, CompletedDate => undef }, { Ref => { Value => { anyType => [ 456, 789 ] } }, CompletedDate => undef }, ] if $self->sample_data; @@ -176,6 +181,7 @@ sub GetServiceUnitsForObject { }, LastInstance => { CurrentScheduledDate => { DateTime => '2020-05-27T00:00:00Z' }, + Ref => { Value => { anyType => [ 123, 456 ] } }, }, } }, } }, @@ -194,6 +200,7 @@ sub GetServiceUnitsForObject { }, LastInstance => { CurrentScheduledDate => { DateTime => '2020-05-27T00:00:00Z' }, + Ref => { Value => { anyType => [ 234, 567 ] } }, }, } }, } }, @@ -212,6 +219,7 @@ sub GetServiceUnitsForObject { }, LastInstance => { CurrentScheduledDate => { DateTime => '2020-05-20T00:00:00Z' }, + Ref => { Value => { anyType => [ 345, 678 ] } }, }, } }, } }, @@ -235,6 +243,7 @@ sub GetServiceUnitsForObject { }, LastInstance => { CurrentScheduledDate => { DateTime => '2020-05-18T00:00:00Z' }, + Ref => { Value => { anyType => [ 456, 789 ] } }, }, } ] }, } }, -- cgit v1.2.3 From 1a90fc2428eeca48347c8dc31f00ca6053e772bf Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 28 Jul 2020 14:23:04 +0100 Subject: [Bromley] Check service unit as well as property. If someone else in a block of flats has reported a missed collection, others in the same service unit should not be able to report also. Fixes https://github.com/mysociety/fixmystreet-commercial/issues/1945 --- perllib/Integrations/Echo.pm | 66 ++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 27 deletions(-) (limited to 'perllib/Integrations/Echo.pm') diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm index c9eab0cfc..ec21da8fa 100644 --- a/perllib/Integrations/Echo.pm +++ b/perllib/Integrations/Echo.pm @@ -90,13 +90,16 @@ sub GetTasks { } return [ - { Ref => { Value => { anyType => [ 123, 456 ] } }, CompletedDate => undef }, { - Ref => { Value => { anyType => [ 234, 567 ] } }, + Ref => { Value => { anyType => [ 123, 456 ] } }, State => { Name => 'Completed' }, Resolution => { Name => 'Wrong Bin Out' }, CompletedDate => { DateTime => '2020-05-27T10:00:00Z' } }, + { + Ref => { Value => { anyType => [ 234, 567 ] } }, + CompletedDate => undef + }, { Ref => { Value => { anyType => [ 345, 678 ] } }, CompletedDate => undef }, { Ref => { Value => { anyType => [ 456, 789 ] } }, CompletedDate => undef }, ] if $self->sample_data; @@ -319,41 +322,50 @@ sub GetEventType { } sub GetEventsForObject { - my ($self, $id, $type) = @_; + my ($self, $type, $id, $event_type) = @_; my $from = DateTime->now->set_time_zone(FixMyStreet->local_time_zone)->subtract(months => 3); - return [ { - # Missed collection for service 542 (food waste) - EventTypeId => 2100, - ServiceId => 542, - }, { # And a gate not closed - EventTypeId => 2118, - ServiceId => 542, - }, { - # Request for a new paper container - EventTypeId => 2104, - Data => { ExtensibleDatum => [ - { Value => 2, DatatypeName => 'Source' }, - { - ChildData => { ExtensibleDatum => [ - { Value => 1, DatatypeName => 'Action' }, - { Value => 12, DatatypeName => 'Container Type' }, - ] }, - }, - ] }, - ServiceId => 535, - } ] if $self->sample_data; + if ($self->sample_data) { + return [ { + # Missed collection for service 542 (food waste) + EventTypeId => 2100, + ServiceId => 542, + }, { # And a gate not closed + EventTypeId => 2118, + ServiceId => 542, + }, { + # Request for a new paper container + EventTypeId => 2104, + Data => { ExtensibleDatum => [ + { Value => 2, DatatypeName => 'Source' }, + { + ChildData => { ExtensibleDatum => [ + { Value => 1, DatatypeName => 'Action' }, + { Value => 12, DatatypeName => 'Container Type' }, + ] }, + }, + ] }, + ServiceId => 535, + } ] if $type eq 'PointAddress'; + return [ { + # Missed collection for service 537 (paper) + EventTypeId => 2099, + ServiceId => 537, + } ] if $type eq 'ServiceUnit' && $id == 1002; + return []; + } + # uncoverable statement my $res = $self->call('GetEventsForObject', objectRef => ixhash( Key => 'Id', - Type => 'PointAddress', + Type => $type, Value => { 'msArray:anyType' => $id }, ), query => ixhash( - $type ? (EventTypeRef => ixhash( + $event_type ? (EventTypeRef => ixhash( Key => 'Id', Type => 'EventType', - Value => { 'msArray:anyType' => $type }, + Value => { 'msArray:anyType' => $event_type }, )) : (), From => dt_to_hash($from), ), -- cgit v1.2.3 From 6e51feec73dc05237055575e9409f38134271faf Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 28 Jul 2020 16:43:34 +0100 Subject: [Bromley] No missed reporting if task not okay. Not Completed or Excess Waste Completed. Fixes https://github.com/mysociety/fixmystreet-commercial/issues/1948 --- perllib/Integrations/Echo.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'perllib/Integrations/Echo.pm') diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm index ec21da8fa..2bd98b777 100644 --- a/perllib/Integrations/Echo.pm +++ b/perllib/Integrations/Echo.pm @@ -100,7 +100,10 @@ sub GetTasks { Ref => { Value => { anyType => [ 234, 567 ] } }, CompletedDate => undef }, - { Ref => { Value => { anyType => [ 345, 678 ] } }, CompletedDate => undef }, + { + Ref => { Value => { anyType => [ 345, 678 ] } }, + State => { Name => 'Not Completed' } + }, { Ref => { Value => { anyType => [ 456, 789 ] } }, CompletedDate => undef }, ] if $self->sample_data; -- cgit v1.2.3 From 8bcba7034241ec4fd0cdcd66d7c0fa2ba3686a6a Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 28 Jul 2020 17:07:00 +0100 Subject: [Bromley] Treat out-of-stock requests as open. Even though it has a resolution code, it is still an open event. Fixes https://github.com/mysociety/fixmystreet-commercial/issues/1946 --- perllib/Integrations/Echo.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'perllib/Integrations/Echo.pm') diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm index 2bd98b777..d8608708e 100644 --- a/perllib/Integrations/Echo.pm +++ b/perllib/Integrations/Echo.pm @@ -336,7 +336,7 @@ sub GetEventsForObject { EventTypeId => 2118, ServiceId => 542, }, { - # Request for a new paper container + # Request for a new paper container, currently out of stock EventTypeId => 2104, Data => { ExtensibleDatum => [ { Value => 2, DatatypeName => 'Source' }, @@ -348,6 +348,7 @@ sub GetEventsForObject { }, ] }, ServiceId => 535, + ResolutionCodeId => 584, } ] if $type eq 'PointAddress'; return [ { # Missed collection for service 537 (paper) -- cgit v1.2.3 From 5e645b3e795e0d9a60425f0d8240c2263dc5a89d Mon Sep 17 00:00:00 2001 From: M Somerville Date: Fri, 21 Aug 2020 13:01:55 +0100 Subject: [Bromley] Check templates for completion message. --- perllib/Integrations/Echo.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/Integrations/Echo.pm') diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm index d8608708e..5878cdfa1 100644 --- a/perllib/Integrations/Echo.pm +++ b/perllib/Integrations/Echo.pm @@ -93,7 +93,7 @@ sub GetTasks { { Ref => { Value => { anyType => [ 123, 456 ] } }, State => { Name => 'Completed' }, - Resolution => { Name => 'Wrong Bin Out' }, + Resolution => { Ref => { Value => { anyType => 187 } }, Name => 'Wrong Bin Out' }, CompletedDate => { DateTime => '2020-05-27T10:00:00Z' } }, { -- cgit v1.2.3 From 2e1c10996a0a08b9bf50af05300fef5c253854e7 Mon Sep 17 00:00:00 2001 From: M Somerville Date: Mon, 5 Oct 2020 14:16:42 +0100 Subject: [Bromley] Nuanced template resolution codes. Have the response template external status code be a combination of resolution code, task type ID, and task state. --- perllib/Integrations/Echo.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'perllib/Integrations/Echo.pm') diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm index 5878cdfa1..0216240da 100644 --- a/perllib/Integrations/Echo.pm +++ b/perllib/Integrations/Echo.pm @@ -94,6 +94,7 @@ sub GetTasks { Ref => { Value => { anyType => [ 123, 456 ] } }, State => { Name => 'Completed' }, Resolution => { Ref => { Value => { anyType => 187 } }, Name => 'Wrong Bin Out' }, + TaskTypeId => 3216, CompletedDate => { DateTime => '2020-05-27T10:00:00Z' } }, { -- cgit v1.2.3 From 3f70d1f0b4d543072eda2d1b59092a5b9e6b3253 Mon Sep 17 00:00:00 2001 From: M Somerville Date: Mon, 19 Oct 2020 16:39:45 +0100 Subject: =?UTF-8?q?[Bromley]=20Handle=20today=E2=80=99s=20collection=20bet?= =?UTF-8?q?ter.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If task is outstanding and before 5pm, show it as next collection and in progress. Allow reporting after 5pm. --- perllib/Integrations/Echo.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'perllib/Integrations/Echo.pm') diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm index 0216240da..28dd1e9bc 100644 --- a/perllib/Integrations/Echo.pm +++ b/perllib/Integrations/Echo.pm @@ -99,6 +99,7 @@ sub GetTasks { }, { Ref => { Value => { anyType => [ 234, 567 ] } }, + State => { Name => 'Outstanding' }, CompletedDate => undef }, { -- cgit v1.2.3 From 5e2f1b3509391f891955db8b8fe05dbf40b7a041 Mon Sep 17 00:00:00 2001 From: M Somerville Date: Wed, 4 Nov 2020 13:45:20 +0000 Subject: [Bromley] Adapt if last instance is in future. --- perllib/Integrations/Echo.pm | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'perllib/Integrations/Echo.pm') diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm index 28dd1e9bc..bf4b453e6 100644 --- a/perllib/Integrations/Echo.pm +++ b/perllib/Integrations/Echo.pm @@ -89,25 +89,31 @@ sub GetTasks { push @refs, \%a; } - return [ - { + if ($self->sample_data) { + my %lookup = map { $_->[0] . ',' . $_->[1] => 1 } @_; + my $data = []; + push @$data, { Ref => { Value => { anyType => [ 123, 456 ] } }, State => { Name => 'Completed' }, Resolution => { Ref => { Value => { anyType => 187 } }, Name => 'Wrong Bin Out' }, TaskTypeId => 3216, CompletedDate => { DateTime => '2020-05-27T10:00:00Z' } - }, - { + } if $lookup{"123,456"}; + push @$data, { Ref => { Value => { anyType => [ 234, 567 ] } }, State => { Name => 'Outstanding' }, CompletedDate => undef - }, - { + } if $lookup{"234,567"}; + push @$data, { Ref => { Value => { anyType => [ 345, 678 ] } }, State => { Name => 'Not Completed' } - }, - { Ref => { Value => { anyType => [ 456, 789 ] } }, CompletedDate => undef }, - ] if $self->sample_data; + } if $lookup{"345,678"}; + push @$data, { + Ref => { Value => { anyType => [ 456, 789 ] } }, + CompletedDate => undef + } if $lookup{"456,789"}; + return $data; + } # This creates XML of the form ......... # uncoverable statement @@ -188,6 +194,7 @@ sub GetServiceUnitsForObject { OriginalScheduledDate => { DateTime => '2020-06-03T00:00:00Z' }, }, LastInstance => { + OriginalScheduledDate => { DateTime => '2020-05-27T00:00:00Z' }, CurrentScheduledDate => { DateTime => '2020-05-27T00:00:00Z' }, Ref => { Value => { anyType => [ 123, 456 ] } }, }, @@ -207,6 +214,7 @@ sub GetServiceUnitsForObject { OriginalScheduledDate => { DateTime => '2020-06-10T00:00:00Z' }, }, LastInstance => { + OriginalScheduledDate => { DateTime => '2020-05-27T00:00:00Z' }, CurrentScheduledDate => { DateTime => '2020-05-27T00:00:00Z' }, Ref => { Value => { anyType => [ 234, 567 ] } }, }, @@ -226,6 +234,7 @@ sub GetServiceUnitsForObject { OriginalScheduledDate => { DateTime => '2020-06-03T00:00:00Z' }, }, LastInstance => { + OriginalScheduledDate => { DateTime => '2020-05-18T00:00:00Z' }, CurrentScheduledDate => { DateTime => '2020-05-20T00:00:00Z' }, Ref => { Value => { anyType => [ 345, 678 ] } }, }, @@ -241,6 +250,7 @@ sub GetServiceUnitsForObject { ServiceTaskSchedules => { ServiceTaskSchedule => [ { EndDate => { DateTime => '2020-01-01T00:00:00Z' }, LastInstance => { + OriginalScheduledDate => { DateTime => '2019-12-31T00:00:00Z' }, CurrentScheduledDate => { DateTime => '2019-12-31T00:00:00Z' }, }, }, { @@ -250,6 +260,7 @@ sub GetServiceUnitsForObject { OriginalScheduledDate => { DateTime => '2020-06-01T00:00:00Z' }, }, LastInstance => { + OriginalScheduledDate => { DateTime => '2020-05-18T00:00:00Z' }, CurrentScheduledDate => { DateTime => '2020-05-18T00:00:00Z' }, Ref => { Value => { anyType => [ 456, 789 ] } }, }, -- cgit v1.2.3 From 0b97468330ab7146f16dfe4060a63d28ce445fa6 Mon Sep 17 00:00:00 2001 From: M Somerville Date: Thu, 12 Nov 2020 11:48:24 +0000 Subject: [Bromley] Use property ID, rather than UPRN. --- perllib/Integrations/Echo.pm | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'perllib/Integrations/Echo.pm') diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm index bf4b453e6..d6783677c 100644 --- a/perllib/Integrations/Echo.pm +++ b/perllib/Integrations/Echo.pm @@ -129,14 +129,14 @@ sub GetTasks { return force_arrayref($res, 'Task'); } -sub _uprn_ref { +sub _id_ref { require SOAP::Lite; - my $uprn = shift; + my $id = shift; tie(my %obj, 'Tie::IxHash', - Key => 'Uprn', + Key => 'Id', Type => 'PointAddress', Value => [ - { 'msArray:anyType' => SOAP::Data->value($uprn)->type('string') }, + { 'msArray:anyType' => SOAP::Data->value($id) }, ], ); return \%obj; @@ -144,10 +144,11 @@ sub _uprn_ref { sub GetPointAddress { my $self = shift; - my $uprn = shift; - my $obj = _uprn_ref($uprn); + my $id = shift; + my $obj = _id_ref($id); return { Id => '12345', + SharedRef => { Value => { anyType => '1000000002' } }, PointType => 'PointAddress', PointAddressType => { Name => 'House' }, Coordinates => { GeoPoint => { Latitude => 51.401546, Longitude => 0.015415 } }, @@ -165,11 +166,11 @@ sub FindPoints { Postcode => $pc, ); return [ - { Description => '1 Example Street, Bromley, BR1 1AA', SharedRef => { Value => { anyType => 1000000001 } } }, - { Description => '2 Example Street, Bromley, BR1 1AA', SharedRef => { Value => { anyType => 1000000002 } } }, - { Description => '3 Example Street, Bromley, BR1 1AA', SharedRef => { Value => { anyType => 1000000003 } } }, - { Description => '4 Example Street, Bromley, BR1 1AA', SharedRef => { Value => { anyType => 1000000004 } } }, - { Description => '5 Example Street, Bromley, BR1 1AA', SharedRef => { Value => { anyType => 1000000005 } } }, + { Description => '1 Example Street, Bromley, BR1 1AA', Id => '11345', SharedRef => { Value => { anyType => 1000000001 } } }, + { Description => '2 Example Street, Bromley, BR1 1AA', Id => '12345', SharedRef => { Value => { anyType => 1000000002 } } }, + { Description => '3 Example Street, Bromley, BR1 1AA', Id => '13345', SharedRef => { Value => { anyType => 1000000003 } } }, + { Description => '4 Example Street, Bromley, BR1 1AA', Id => '14345', SharedRef => { Value => { anyType => 1000000004 } } }, + { Description => '5 Example Street, Bromley, BR1 1AA', Id => '15345', SharedRef => { Value => { anyType => 1000000005 } } }, ] if $self->sample_data; my $res = $self->call('FindPoints', query => \%obj); return force_arrayref($res, 'PointInfo'); @@ -177,8 +178,8 @@ sub FindPoints { sub GetServiceUnitsForObject { my $self = shift; - my $uprn = shift; - my $obj = _uprn_ref($uprn); + my $id = shift; + my $obj = _id_ref($id); my $from = DateTime->now->set_time_zone(FixMyStreet->local_time_zone); return [ { Id => 1001, -- cgit v1.2.3