Skip to content

Commit 7a8a87b

Browse files
dracosMorayMySoc
authored andcommitted
[Bristol] Add attribute fallback support.
1 parent b7f81a2 commit 7a8a87b

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

perllib/Open311/Endpoint/Integration/UK/Bristol/Alloy.pm

+6-2
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,18 @@ sub process_attributes {
5151
};
5252

5353
my $attributes_names = $self->config->{request_to_resource_attribute_manual_mapping}->{$args->{service_code_alloy}};
54+
my $attribute_fallback = $self->config->{request_attribute_defaults}{$code};
5455

5556
for my $att (keys %$attributes_names) {
5657
next if $att eq 'JobType';
57-
next unless length $args->{attributes}->{$att};
58+
next unless length $args->{attributes}->{$att} || $attribute_fallback->{$att};
59+
60+
my $value = length $args->{attributes}->{$att} ? $args->{attributes}->{$att} : $attribute_fallback->{$att};
61+
$value = $attributes_values->{$att}->[ $value ] if $attributes_values->{$att};
5862

5963
my $myattrib = {
6064
attributeCode => $attributes_names->{$att},
61-
value => $attributes_values->{$att} ? $attributes_values->{$att}->[ $args->{attributes}->{$att} ] : $args->{attributes}->{$att},
65+
value => $value,
6266
};
6367

6468
if ($myattrib->{value} =~ /^[01]$/) {

t/open311/endpoint/bristol_alloy.t

-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ for my $test (
279279
{
280280
title => "Dead cow report",
281281
extra_params => {
282-
'attribute[SizeOfIssue]' => '1',
283282
'attribute[TypeOfAnimal]' => '1',
284283
'attribute[category]' => 'Dead animal',
285284
'service_code' => 'Dead_animal',

t/open311/endpoint/bristol_alloy.yml

+7
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@
6868
},
6969
},
7070

71+
"request_attribute_defaults": {
72+
"Bin overflowing": { "SizeOfIssue": 1 },
73+
"Bin damaged": { "SizeOfIssue": 1 },
74+
"Dead animal": { "SizeOfIssue": 1 },
75+
"Dog fouling": { "SizeOfIssue": 1 },
76+
},
77+
7178
"request_attribute_to_values": {
7279
"SizeOfIssue": ["5e1f1be1ca3150041c4141fb", "5e1f1bf0ca31500c541f82cb", "5e1f1bffca31500c541f82d8", "5e1f1c0aca31500f4ca4d4e5"],
7380
"PropertyType": ['5e1f3aa5ca31500b78e78b16', '5e1f3ad1ca31500b78e78c3f'],

0 commit comments

Comments
 (0)