aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Open311.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2017-12-20 15:58:51 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-03-15 13:17:18 +0000
commit935f431ee0da77dd26a78b959d3b9afb89665c0f (patch)
tree68b4b80d88cfcd9f2915f091b16927a00f2a0680 /perllib/Open311.pm
parent40a3bfb7566b02db2eb6019adcbefeaa19ffb42f (diff)
fetch new problems over open311
This enables the display of existing reports from the back end on FMS if the body is configured to do this. Reports will not be created if they are missing an id, a lat or a long, if the lat/long is outside the area covered by the body, if there is already a report with a matching id, or if we can't parse out the request time.
Diffstat (limited to 'perllib/Open311.pm')
-rw-r--r--perllib/Open311.pm43
1 files changed, 40 insertions, 3 deletions
diff --git a/perllib/Open311.pm b/perllib/Open311.pm
index 44af0b134..22293ee9f 100644
--- a/perllib/Open311.pm
+++ b/perllib/Open311.pm
@@ -213,14 +213,20 @@ sub _generate_service_request_description {
sub get_service_requests {
my $self = shift;
- my $report_ids = shift;
+ my $args = shift;
my $params = {};
- if ( $report_ids ) {
- $params->{service_request_id} = join ',', @$report_ids;
+ if ( $args->{report_ids} ) {
+ $params->{service_request_id} = join ',', @{$args->{report_ids}};
+ delete $args->{report_ids};
}
+ $params = {
+ %$params,
+ %$args
+ };
+
my $service_request_xml = $self->_get( $self->endpoints->{requests}, $params || undef );
return $self->_get_xml_object( $service_request_xml );
}
@@ -291,6 +297,37 @@ sub post_service_request_update {
return 0;
}
+sub add_media {
+ my ($self, $url, $object) = @_;
+
+ my $ua = LWP::UserAgent->new;
+ my $res = $ua->get($url);
+ if ( $res->is_success && $res->content_type eq 'image/jpeg' ) {
+ my $photoset = FixMyStreet::App::Model::PhotoSet->new({
+ data_items => [ $res->decoded_content ],
+ });
+ $object->photo($photoset->data);
+ }
+}
+
+sub map_state {
+ my $self = shift;
+ my $incoming_state = shift;
+
+ $incoming_state = lc($incoming_state);
+ $incoming_state =~ s/_/ /g;
+
+ my %state_map = (
+ fixed => 'fixed - council',
+ 'not councils responsibility' => 'not responsible',
+ 'no further action' => 'unable to fix',
+ open => 'confirmed',
+ closed => 'fixed - council',
+ );
+
+ return $state_map{$incoming_state} || $incoming_state;
+}
+
sub _populate_service_request_update_params {
my $self = shift;
my $comment = shift;