aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Open311.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/Open311.pm')
-rw-r--r--perllib/Open311.pm78
1 files changed, 60 insertions, 18 deletions
diff --git a/perllib/Open311.pm b/perllib/Open311.pm
index 52e17e99d..4f9b948ce 100644
--- a/perllib/Open311.pm
+++ b/perllib/Open311.pm
@@ -22,9 +22,10 @@ has success => ( is => 'rw', 'isa' => 'Bool', default => 0 );
has error => ( is => 'rw', 'isa' => 'Str', default => '' );
has always_send_latlong => ( is => 'ro', isa => 'Bool', default => 1 );
has send_notpinpointed => ( is => 'ro', isa => 'Bool', default => 0 );
-has basic_description => ( is => 'ro', isa => 'Bool', default => 0 );
+has extended_description => ( is => 'ro', isa => 'Str', default => 1 );
has use_service_as_deviceid => ( is => 'ro', isa => 'Bool', default => 0 );
has use_extended_updates => ( is => 'ro', isa => 'Bool', default => 0 );
+has extended_statuses => ( is => 'ro', isa => 'Bool', default => 0 );
before [
qw/get_service_list get_service_meta_info get_service_requests get_service_request_updates
@@ -38,7 +39,11 @@ sub get_service_list {
my $service_list_xml = $self->_get( $self->endpoints->{services} );
- return $self->_get_xml_object( $service_list_xml );
+ if ( $service_list_xml ) {
+ return $self->_get_xml_object( $service_list_xml );
+ } else {
+ return undef;
+ }
}
sub get_service_meta_info {
@@ -95,15 +100,15 @@ sub _populate_service_request_params {
my $service_code = shift;
my $description;
- if ( $self->basic_description ) {
- $description = $problem->detail;
- } else {
+ if ( $self->extended_description ) {
$description = $self->_generate_service_request_description(
$problem, $extra
);
+ } else {
+ $description = $problem->detail;
}
- my ( $firstname, $lastname ) = ( $problem->user->name =~ /(\w+)\.?\s+(.+)/ );
+ my ( $firstname, $lastname ) = ( $problem->name =~ /(\w+)\.?\s+(.+)/ );
my $params = {
email => $problem->user->email,
@@ -167,16 +172,23 @@ sub _generate_service_request_description {
my $problem = shift;
my $extra = shift;
- my $description = <<EOT;
-title: @{[$problem->title()]}
-
-detail: @{[$problem->detail()]}
-
-url: $extra->{url}
-
-Submitted via FixMyStreet
-EOT
-;
+ my $description = "";
+ if ($extra->{easting_northing}) { # Proxy for cobrand being in the UK
+ $description .= "detail: " . $problem->detail . "\n\n";
+ $description .= "url: " . $extra->{url} . "\n\n";
+ $description .= "Submitted via FixMyStreet\n";
+ if ($self->extended_description ne 'oxfordshire') {
+ $description = "title: " . $problem->title . "\n\n$description";
+ }
+ } elsif ($problem->cobrand eq 'fixamingata') {
+ $description .= "Beskrivning: " . $problem->detail . "\n\n";
+ $description .= "Länk till ärendet: " . $extra->{url} . "\n\n";
+ $description .= "Skickad via FixaMinGata\n";
+ } else {
+ $description .= $problem->title . "\n\n";
+ $description .= $problem->detail . "\n\n";
+ $description .= $extra->{url} . "\n";
+ }
return $description;
}
@@ -282,11 +294,41 @@ sub _populate_service_request_update_params {
my $name = $comment->name || $comment->user->name;
my ( $firstname, $lastname ) = ( $name =~ /(\w+)\.?\s+(.+)/ );
+ $lastname ||= '-';
+
+ # fall back to problem state as it's probably correct
+ my $state = $comment->problem_state || $comment->problem->state;
+
+ my $status = 'OPEN';
+ if ( $self->extended_statuses ) {
+ if ( FixMyStreet::DB::Result::Problem->fixed_states()->{$state} ) {
+ $status = 'FIXED';
+ } elsif ( $state eq 'in progress' ) {
+ $status = 'IN_PROGRESS';
+ } elsif ($state eq 'action scheduled'
+ || $state eq 'planned' ) {
+ $status = 'ACTION_SCHEDULED';
+ } elsif ( $state eq 'investigating' ) {
+ $status = 'INVESTIGATING';
+ } elsif ( $state eq 'duplicate' ) {
+ $status = 'DUPLICATE';
+ } elsif ( $state eq 'not responsible' ) {
+ $status = 'NOT_COUNCILS_RESPONSIBILITY';
+ } elsif ( $state eq 'unable to fix' ) {
+ $status = 'NO_FURTHER_ACTION';
+ } elsif ( $state eq 'internal referral' ) {
+ $status = 'INTERNAL_REFERRAL';
+ }
+ } else {
+ if ( !FixMyStreet::DB::Result::Problem->open_states()->{$state} ) {
+ $status = 'CLOSED';
+ }
+ }
my $params = {
- updated_datetime => DateTime::Format::W3CDTF->format_datetime($comment->confirmed_local->set_nanosecond(0)),
+ updated_datetime => DateTime::Format::W3CDTF->format_datetime($comment->confirmed->set_nanosecond(0)),
service_request_id => $comment->problem->external_id,
- status => $comment->problem->is_open ? 'OPEN' : 'CLOSED',
+ status => $status,
email => $comment->user->email,
description => $comment->text,
last_name => $lastname,