aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Open311/PopulateServiceList.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2016-06-15 12:43:54 +0100
committerMatthew Somerville <matthew@mysociety.org>2016-06-15 13:47:53 +0100
commit8d428f9c8fd9e25821560a20d00d444d9fb67e08 (patch)
tree52b75a1f922b589a151acccc0ee38c2ac9a90f59 /perllib/Open311/PopulateServiceList.pm
parent96c72fa72e547a2ce5b435db3cae8c3c45efafc1 (diff)
Tidy up Open311 XML handling.
Parse the XML in such a way other parts of the code do not have to worry about single-value folding or the like.
Diffstat (limited to 'perllib/Open311/PopulateServiceList.pm')
-rw-r--r--perllib/Open311/PopulateServiceList.pm12
1 files changed, 2 insertions, 10 deletions
diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm
index 3236f3798..dd3bd65d6 100644
--- a/perllib/Open311/PopulateServiceList.pm
+++ b/perllib/Open311/PopulateServiceList.pm
@@ -71,8 +71,6 @@ sub process_services {
$self->found_contacts( [] );
my $services = $list->{service};
- # XML might only have one result and then squashed the 'array'-ness
- $services = [ $services ] unless ref $services eq 'ARRAY';
foreach my $service ( @$services ) {
$self->_current_service( $service );
$self->process_service;
@@ -205,13 +203,7 @@ sub _add_meta_to_contact {
print "Fetching meta data for " . $self->_current_service->{service_code} . "\n" if $self->verbose >= 2;
my $meta_data = $self->_current_open311->get_service_meta_info( $self->_current_service->{service_code} );
- if ( ref $meta_data->{ attributes }->{ attribute } eq 'HASH' ) {
- $meta_data->{ attributes }->{ attribute } = [
- $meta_data->{ attributes }->{ attribute }
- ];
- }
-
- if ( ! $meta_data->{attributes}->{attribute} ) {
+ unless ($meta_data->{attributes}) {
warn sprintf( "Empty meta data for %s at %s",
$self->_current_service->{service_code},
$self->_current_body->endpoint )
@@ -225,7 +217,7 @@ sub _add_meta_to_contact {
map { $_->{description} =~ s/:\s*//; $_ }
# there is a display order and we only want to sort once
sort { $a->{order} <=> $b->{order} }
- @{ $meta_data->{attributes}->{attribute} };
+ @{ $meta_data->{attributes} };
# Some Open311 endpoints, such as Bromley and Warwickshire send <metadata>
# for attributes which we *don't* want to display to the user (e.g. as