diff options
Diffstat (limited to 'perllib/FixMyStreet/SendReport/Open311.pm')
-rw-r--r-- | perllib/FixMyStreet/SendReport/Open311.pm | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/SendReport/Open311.pm b/perllib/FixMyStreet/SendReport/Open311.pm index c6d838998..1b79bcc99 100644 --- a/perllib/FixMyStreet/SendReport/Open311.pm +++ b/perllib/FixMyStreet/SendReport/Open311.pm @@ -9,6 +9,9 @@ use FixMyStreet::App; use mySociety::Config; use DateTime::Format::W3CDTF; use Open311; +use Readonly; + +Readonly::Scalar my $COUNCIL_ID_OXFORDSHIRE => 2237; sub should_skip { my $self = shift; @@ -34,7 +37,7 @@ sub send { my $send_notpinpointed = 0; my $use_service_as_deviceid = 0; - my $basic_desc = 0; + my $extended_desc = 1; # To rollback temporary changes made by this function my $revert = 0; @@ -69,7 +72,22 @@ sub send { push @$extra, { name => 'last_name', value => $lastname }; } - $basic_desc = 1; + $extended_desc = 0; + } + + # extra Oxfordshire fields: send nearest street, postcode, northing and easting, and the FMS id + if ( $row->council =~ /$COUNCIL_ID_OXFORDSHIRE/ ) { + + my $extra = $row->extra; + push @$extra, { name => 'external_id', value => $row->id }; + push @$extra, { name => 'closest_address', value => $h->{closest_address} } if $h->{closest_address}; + if ( $row->used_map || ( !$row->used_map && !$row->postcode ) ) { + push @$extra, { name => 'northing', value => $h->{northing} }; + push @$extra, { name => 'easting', value => $h->{easting} }; + } + $row->extra( $extra ); + + $extended_desc = 'oxfordshire'; } # FIXME: we've already looked this up before @@ -86,7 +104,7 @@ sub send { always_send_latlong => $always_send_latlong, send_notpinpointed => $send_notpinpointed, use_service_as_deviceid => $use_service_as_deviceid, - basic_description => $basic_desc, + extended_description => $extended_desc, ); # non standard west berks end points @@ -94,6 +112,12 @@ sub send { $open311->endpoints( { services => 'Services', requests => 'Requests' } ); } + # non-standard Oxfordshire endpoint (because it's just a script, not a full Open311 service) + if ( $row->council =~ /$COUNCIL_ID_OXFORDSHIRE/ ) { + $open311->endpoints( { requests => 'open311_service_request.cgi' } ); + $revert = 1; + } + # required to get round issues with CRM constraints if ( $row->bodies_str =~ /2218/ ) { $row->user->name( $row->user->id . ' ' . $row->user->name ); @@ -101,7 +125,7 @@ sub send { } if ($row->cobrand eq 'fixmybarangay') { - # FixMyBarangay endpoints expect external_id as an attribute + # FixMyBarangay endpoints expect external_id as an attribute, as do Oxfordshire $row->extra( [ { 'name' => 'external_id', 'value' => $row->id } ] ); $revert = 1; } @@ -115,9 +139,17 @@ sub send { $row->external_id( $resp ); $row->send_method_used('Open311'); if ($row->cobrand eq 'fixmybarangay') { - # currently the only external body using Open311 is DPS - # (this will change when we have 'body' logic in place, meanwhile: hardcoded) - $row->external_body("DPS"); + # FixMyBarangay: currently the external bodies using Open311 are DPS, DEPW, DPWH + # for now identify the latter two by their name in the service_code ($contact->email) + # So: this works because we are anticipating the service codes for (e.g., potholes) look + # like this: + # POTDEPW or POTDPWH + # (TODO: this will change when we have 'body' logic in place, meanwhile: hardcoded) + if ($contact->email =~ /(DEPW|DPWH)$/i) { + $row->external_body(uc $1); # body is DEPW (city roads) or DPWH (national roads) + } else { + $row->external_body("DPS"); # only other open311 dept is DPS + } } $result *= 0; $self->success( 1 ); |