From 10932ee4bba2b77542e126ad0f14876ff6d532b0 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 8 Dec 2023 12:09:41 +0000 Subject: [PATCH] fixup! [SLWP] Pass in correct payment meta information. --- .../Open311/Endpoint/Integration/UK/Sutton.pm | 28 +++++++++++++++++++ perllib/Open311/Endpoint/Role/SLWP.pm | 9 ++---- t/open311/endpoint/kingston.t | 2 +- t/open311/endpoint/kingston.yml | 1 + t/open311/endpoint/sutton.t | 6 +++- 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/perllib/Open311/Endpoint/Integration/UK/Sutton.pm b/perllib/Open311/Endpoint/Integration/UK/Sutton.pm index b9383b192..9eefcc52f 100644 --- a/perllib/Open311/Endpoint/Integration/UK/Sutton.pm +++ b/perllib/Open311/Endpoint/Integration/UK/Sutton.pm @@ -1,3 +1,15 @@ +=head1 NAME + +Open311::Endpoint::Integration::UK::Sutton + +=head1 DESCRIPTION + +The Sutton integration. As well as the boilerplate, and setting it as an Echo +integration, this makes sure the right "Payment Taken By" option is chosen for +bulky collections. + +=cut + package Open311::Endpoint::Integration::UK::Sutton; use Moo; @@ -10,4 +22,20 @@ around BUILDARGS => sub { return $class->$orig(%args); }; +around check_for_data_value => sub { + my ($orig, $class, $name, $args, $request, $parent_name) = @_; + + # Bulky items + if ($args->{service_code} eq '1636') { + my $method = $args->{attributes}{payment_method} || ''; + if ($method eq 'csc' || $method eq 'cheque') { + return 1 if $name eq 'Payment Taken By'; # Council + } elsif ($method eq 'credit_card') { + return 2 if $name eq 'Payment Taken By'; # Veolia + } + } + + return $class->$orig($name, $args, $request, $parent_name); +}; + 1; diff --git a/perllib/Open311/Endpoint/Role/SLWP.pm b/perllib/Open311/Endpoint/Role/SLWP.pm index e914f5195..4e692d1d1 100644 --- a/perllib/Open311/Endpoint/Role/SLWP.pm +++ b/perllib/Open311/Endpoint/Role/SLWP.pm @@ -38,12 +38,9 @@ around check_for_data_value => sub { # Default in configuration is Payment Type 1 (Card), Payment Method 2 (Website) my $method = $args->{attributes}{payment_method} || ''; return 2 if $name eq 'Payment Type' && $method eq 'cheque'; # Cheque - if ($method eq 'csc' || $method eq 'cheque') { - return 1 if $name eq 'Payment Taken By'; # Council - return 1 if $name eq 'Payment Method'; # Borough Phone Payment - } elsif ($method eq 'credit_card') { - return 2 if $name eq 'Payment Taken By'; # Veolia - return 2 if $name eq 'Payment Method'; # Borough Website Payment + if ($name eq 'Payment Method') { + return 1 if $method eq 'csc' || $method eq 'cheque'; # Borough Phone Payment + return 2 if $method eq 'credit_card'; # Borough Website Payment } } diff --git a/t/open311/endpoint/kingston.t b/t/open311/endpoint/kingston.t index 4ecb0bc5c..f59c20cab 100644 --- a/t/open311/endpoint/kingston.t +++ b/t/open311/endpoint/kingston.t @@ -58,7 +58,7 @@ $soap_lite->mock(call => sub { my $val = $client_ref eq 'bulky-cc' ? 2 : 1; @payment = ${$data[1]->value}->value; is $payment[0]->value, 1012; - is $payment[1]->value, $val; + is $payment[1]->value, 1; # Always 1 @payment = ${$data[2]->value}->value; is $payment[0]->value, 1013; is $payment[1]->value, $val; diff --git a/t/open311/endpoint/kingston.yml b/t/open311/endpoint/kingston.yml index 0b99e61d7..fbb3af5b4 100644 --- a/t/open311/endpoint/kingston.yml +++ b/t/open311/endpoint/kingston.yml @@ -28,3 +28,4 @@ service_id_override: default_data_event_type: 1636: Payment Type: 1 + Payment Taken By: 1 diff --git a/t/open311/endpoint/sutton.t b/t/open311/endpoint/sutton.t index 3dcb1195f..268ce1be3 100644 --- a/t/open311/endpoint/sutton.t +++ b/t/open311/endpoint/sutton.t @@ -91,6 +91,9 @@ $soap_lite->mock(call => sub { my @method = ${$data[1]->value}->value; is $method[0]->value, 1010; is $method[1]->value, 2; + my @by = ${$data[2]->value}->value; + is $by[0]->value, 1011; + is $by[1]->value, 2; } return SOAP::Result->new(result => { EventGuid => '1234', @@ -110,6 +113,7 @@ $soap_lite->mock(call => sub { { Id => 2002, Name => "Paper" }, { Id => 1009, Name => "Payment Type" }, { Id => 1010, Name => "Payment Method" }, + { Id => 1011, Name => "Payment Taken By" }, ] }, }); } else { @@ -185,7 +189,7 @@ subtest "POST bulky collection OK" => sub { my $res = $endpoint->run_test_request(@params, service_code => EVENT_TYPE_BULKY, 'attribute[fixmystreet_id]' => 2000126, - 'attribute[LastPayMethod]' => 2, + 'attribute[payment_method]' => 'credit_card', ); ok $res->is_success, 'valid request' or diag $res->content;