diff options
Diffstat (limited to 'perllib/FixMyStreet/SendReport/Barnet.pm')
-rw-r--r-- | perllib/FixMyStreet/SendReport/Barnet.pm | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/perllib/FixMyStreet/SendReport/Barnet.pm b/perllib/FixMyStreet/SendReport/Barnet.pm index 9a92686ec..07adb4c33 100644 --- a/perllib/FixMyStreet/SendReport/Barnet.pm +++ b/perllib/FixMyStreet/SendReport/Barnet.pm @@ -4,37 +4,15 @@ use Moose; BEGIN { extends 'FixMyStreet::SendReport'; } -use BarnetInterfaces::service::ZLBB_SERVICE_ORDER; use Encode; use Utils; use mySociety::Config; use mySociety::Web qw(ent); -# maximum number of webservice attempts to send before not trying any more (XXX may be better in config?) -use constant SEND_FAIL_RETRIES_CUTOFF => 3; - # specific council numbers use constant COUNCIL_ID_BARNET => 2489; use constant MAX_LINE_LENGTH => 132; -sub should_skip { - my $self = shift; - my $row = shift; - - my $council_name = 'Barnet'; - my $err_msg = ""; - - if ($row->send_fail_count >= SEND_FAIL_RETRIES_CUTOFF) { - $council_name &&= " to $council_name"; - $err_msg = "skipped: problem id=" . $row->id . " send$council_name has failed " - . $row->send_fail_count . " times, cutoff is " . SEND_FAIL_RETRIES_CUTOFF; - - $self->skipped( $err_msg ); - - return 1; - } -} - sub construct_message { my %h = @_; my $message = <<EOF; @@ -66,6 +44,7 @@ sub send { my $geo_code = "$h{easting} $h{northing}"; + require BarnetInterfaces::service::ZLBB_SERVICE_ORDER; my $interface = BarnetInterfaces::service::ZLBB_SERVICE_ORDER->new(); my ($nearest_postcode, $nearest_street) = ('', ''); @@ -80,9 +59,9 @@ sub send { ? $h{query} : $nearest_postcode; # use given postcode if available # note: endpoint can be of form 'https://username:password@url' - my $council_config = FixMyStreet::App->model("DB::Open311conf")->search( { area_id => COUNCIL_ID_BARNET} )->first; - if ($council_config and $council_config->endpoint) { - $interface->set_proxy($council_config->endpoint); + my $body = FixMyStreet::App->model("DB::Body")->search( { 'body_areas.area_id' => COUNCIL_ID_BARNET }, { join => "body_areas" } )->first; + if ($body and $body->endpoint) { + $interface->set_proxy($body->endpoint); # Barnet web service doesn't like namespaces in the elements so use a prefix $interface->set_prefix('urn'); # uncomment these lines to print XML that will be sent rather @@ -90,7 +69,7 @@ sub send { #$interface->outputxml(1); #$interface->no_dispatch(1); } else { - die "Barnet webservice FAIL: looks like you're missing some config data: no endpoint (URL) found for area_id=" . COUNCIL_ID_BARNET; + die "Barnet webservice FAIL: looks like you're missing some config data: no endpoint (URL) found for area ID " . COUNCIL_ID_BARNET; } eval { |