aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Open311/GetUpdates.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/GetUpdates.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/GetUpdates.pm')
-rw-r--r--perllib/Open311/GetUpdates.pm19
1 files changed, 4 insertions, 15 deletions
diff --git a/perllib/Open311/GetUpdates.pm b/perllib/Open311/GetUpdates.pm
index 901e78809..1b1e339e3 100644
--- a/perllib/Open311/GetUpdates.pm
+++ b/perllib/Open311/GetUpdates.pm
@@ -42,23 +42,12 @@ sub update_reports {
my ( $self, $report_ids, $open311, $body ) = @_;
my $service_requests = $open311->get_service_requests( $report_ids );
-
- my $requests;
-
- # XML::Simple is a bit inconsistent in how it structures
- # things depending on the number of children an element has :(
- if ( ref $service_requests->{request} eq 'ARRAY' ) {
- $requests = $service_requests->{request};
- }
- else {
- $requests = [ $service_requests->{request} ];
- }
+ my $requests = $service_requests->{request};
for my $request (@$requests) {
- # if it's a ref that means it's an empty element
- # however, if there's no updated date then we can't
- # tell if it's newer that what we have so we should skip it
- next if ref $request->{updated_datetime} || ! exists $request->{updated_datetime};
+ # if there's no updated date then we can't
+ # tell if it's newer than what we have so we should skip it
+ next unless $request->{updated_datetime};
my $request_id = $request->{service_request_id};