diff options
author | Dave Whiteland <dave@mysociety.org> | 2012-05-29 15:57:41 +0100 |
---|---|---|
committer | Dave Whiteland <dave@mysociety.org> | 2012-05-29 15:57:41 +0100 |
commit | 67da8efc720d2d0bd22bd9fe8655b7e983b35bb4 (patch) | |
tree | 38b8570647124df06c637d4b923f6010211ef328 /perllib/FixMyStreet/SendReport/EastHants.pm | |
parent | 40b3a51d33caefa8f5fb97ce9be18ef936c7e260 (diff) | |
parent | 131ff6e9bf3626d6a8fff6ae54669d250148a63a (diff) |
Merge remote branch 'origin/master' into fmb-read-only
Conflicts:
bin/send-reports
perllib/FixMyStreet/Cobrand/Default.pm
perllib/FixMyStreet/Cobrand/FixMyStreet.pm
templates/web/fixmystreet/alert/index.html
templates/web/fixmystreet/around/display_location.html
web/cobrands/fixmystreet/_layout.scss
web/js/map-OpenLayers.js
Diffstat (limited to 'perllib/FixMyStreet/SendReport/EastHants.pm')
-rw-r--r-- | perllib/FixMyStreet/SendReport/EastHants.pm | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/SendReport/EastHants.pm b/perllib/FixMyStreet/SendReport/EastHants.pm new file mode 100644 index 000000000..681a9d4c4 --- /dev/null +++ b/perllib/FixMyStreet/SendReport/EastHants.pm @@ -0,0 +1,62 @@ +package FixMyStreet::SendReport::EastHants; + +use Moose; + +BEGIN { extends 'FixMyStreet::SendReport'; } + +# export just what we need as error if we use :try +use Error qw(try otherwise); +use Encode; +use mySociety::Web qw(ent); +use EastHantsWSDL; + +sub construct_message { + my %h = @_; + my $message = ''; + $message .= "[ This report was also sent to the district council covering the location of the problem, as the user did not categorise it; please ignore if you're not the correct council to deal with the issue. ]\n\n" + if $h{multiple}; + $message .= <<EOF; +Subject: $h{title} + +Details: $h{detail} + +$h{fuzzy}, or to provide an update on the problem, please visit the following link: + +$h{url} + +$h{closest_address} +EOF + return $message; +} + +sub send { + return if mySociety::Config::get('STAGING_SITE'); + + my ( $self, $row, $h, $to, $template, $recips, $nomail ) = @_; + + # FIXME: should not recreate this each time + my $eh_service; + + $h->{category} = 'Customer Services' if $h->{category} eq 'Other'; + $h->{message} = construct_message( %$h ); + my $return = 1; + $eh_service ||= EastHantsWSDL->on_fault(sub { my($soap, $res) = @_; die ref $res ? $res->faultstring : $soap->transport->status, "\n"; }); + try { + # ServiceName, RemoteCreatedBy, Salutation, FirstName, Name, Email, Telephone, HouseNoName, Street, Town, County, Country, Postcode, Comments, FurtherInfo, ImageURL + my $message = ent(encode_utf8($h->{message})); + my $name = ent(encode_utf8($h->{name})); + my $result = $eh_service->INPUTFEEDBACK( + $h->{category}, 'FixMyStreet', '', '', $name, $h->{email}, $h->{phone}, + '', '', '', '', '', '', $message, 'Yes', $h->{image_url} + ); + $return = 0 if $result eq 'Report received'; + } otherwise { + my $e = shift; + print "Caught an error: $e\n"; + $self->error( "Error sending to East Hants: $e" ); + }; + $self->success( !$return ); + return $return; +} + +1; |