Skip to content

Commit

Permalink
[Echo] Make sure can loop through data of one object.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Oct 11, 2023
1 parent f50b105 commit 4f22cc2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
15 changes: 13 additions & 2 deletions perllib/Open311/Endpoint/Integration/Echo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,16 @@ sub post_service_request {

# Look up extra data fields
my $event_type = $integ->GetEventType($request->{event_type});
foreach my $type (@{$event_type->{Datatypes}->{ExtensibleDatatype}}) {
my $data = force_arrayref($event_type->{Datatypes}, 'ExtensibleDatatype');
foreach my $type (@$data) {
my $row = { id => $type->{Id} };
my $value = $self->check_for_data_value($type->{Name}, $args, $request);

my %extra;
my $extra_count = 0;
if ($type->{ChildDatatypes}) {
foreach (@{$type->{ChildDatatypes}{ExtensibleDatatype}}) {
my $moredata = force_arrayref($type->{ChildDatatypes}, 'ExtensibleDatatype');
foreach (@$moredata) {
my $subrow = { id => $_->{Id} };
my $value = $self->check_for_data_value($_->{Name}, $args, $request, $type->{Name});
if (defined $value) {
Expand Down Expand Up @@ -495,4 +497,13 @@ used as part of a Multi integration.

sub get_service_request_updates { }

sub force_arrayref {
my ($res, $key) = @_;
return [] unless $res;
my $data = $res->{$key};
return [] unless $data;
$data = [ $data ] unless ref $data eq 'ARRAY';
return $data;
}

1;
11 changes: 1 addition & 10 deletions perllib/Open311/Endpoint/Integration/UK/Brent/Echo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ around post_service_request_update => sub {
my $event_type = $integ->GetEventType($event->{EventTypeId});
my $state_id = $event->{EventStateId};

my $states = force_arrayref($event_type->{Workflow}->{States}, 'State');
my $states = Open311::Endpoint::Integration::Echo::force_arrayref($event_type->{Workflow}->{States}, 'State');
my $data;
foreach (@$states) {
my $core = $_->{CoreState};
Expand All @@ -80,13 +80,4 @@ around post_service_request_update => sub {
return $class->$orig($args);
};

sub force_arrayref {
my ($res, $key) = @_;
return [] unless $res;
my $data = $res->{$key};
return [] unless $data;
$data = [ $data ] unless ref $data eq 'ARRAY';
return $data;
}

1;

0 comments on commit 4f22cc2

Please sign in to comment.