Skip to content

Commit

Permalink
[Kingston] Spot payment method in garden too.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Aug 6, 2024
1 parent dab7b25 commit f50869e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 8 deletions.
19 changes: 19 additions & 0 deletions perllib/Open311/Endpoint/Integration/UK/Kingston.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,23 @@ around BUILDARGS => sub {
return $class->$orig(%args);
};

around check_for_data_value => sub {
my ($orig, $class, $name, $args, $request, $parent_name) = @_;

# Garden waste
if ($args->{service_code} eq '1638') {
my $method = $args->{attributes}{payment_method} || '';
if ($name eq 'Payment Type') {
return 3 if $method eq 'csc' || $method eq 'cheque'; # Telephone
}
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
}
}


return $class->$orig($name, $args, $request, $parent_name);
};

1;
6 changes: 6 additions & 0 deletions perllib/Open311/Endpoint/Integration/UK/Sutton.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ around check_for_data_value => sub {
}
}

# Garden waste
if ($args->{service_code} eq '1638') {
my $method = $args->{attributes}{payment_method} || '';
return 3 if $name eq 'Payment Type' && $method eq 'cheque'; # Telephone
}

return $class->$orig($name, $args, $request, $parent_name);
};

Expand Down
7 changes: 0 additions & 7 deletions perllib/Open311/Endpoint/Role/SLWP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ around check_for_data_value => sub {
return 1 if $name eq 'Refuse Bag' && $service eq '2242';
return 1 if $name eq 'Refuse Bin' && ($service eq '2238' || $service eq '2243' || $service eq '3576');

# Garden waste
if ($args->{service_code} eq '1638') {
my $method = $args->{attributes}{LastPayMethod} || '';
return 2 if $name eq 'Payment Type' && $method eq 3; # DD
return 3 if $name eq 'Payment Type' && $method eq 4; # 'cheque' (or phone)
}

# Bulky items
if ($args->{service_code} eq '1636') {
# Default in configuration is Payment Type 1 (Card), Payment Method 2 (Website)
Expand Down
9 changes: 9 additions & 0 deletions t/open311/endpoint/kingston.t
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ $soap_lite->mock(call => sub {
if ($client_ref eq 'bulky-cc') { # Also check items
is @data, 9, 'Has all six items present in the data';
}
} elsif ($event_type_id == 1638 && $client_ref eq 'REF-123') {
my @data = ${$params[0]->value}->value->value;
my @type = ${$data[0]->value}->value;
is $type[0]->value, 1011;
is $type[1]->value, 3;
my @method = ${$data[1]->value}->value;
is $method[0]->value, 1013;
is $method[1]->value, 1;
}
} elsif (@params == 2) {
is $params[0]->value, '123pay';
Expand Down Expand Up @@ -157,6 +165,7 @@ subtest "POST subscription request OK" => sub {
subtest "POST subscription request with client ref provided OK" => sub {
my $res = $endpoint->run_test_request(@params,
service_code => EVENT_TYPE_SUBSCRIBE,
'attribute[payment_method]' => 'csc',
'attribute[client_reference]' => 'REF-123',
);
ok $res->is_success, 'valid request'
Expand Down
2 changes: 1 addition & 1 deletion t/open311/endpoint/sutton.t
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ subtest "POST subscription request OK" => sub {
'attribute[Subscription_Details_Containers]' => 26, # Garden Bin
'attribute[Subscription_Details_Quantity]' => 1,
'attribute[Request_Type]' => 1,
'attribute[LastPayMethod]' => 4,
'attribute[payment_method]' => 'cheque',
);
ok $res->is_success, 'valid request'
or diag $res->content;
Expand Down

0 comments on commit f50869e

Please sign in to comment.