Skip to content

Commit

Permalink
Merge branch 'master' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Oct 15, 2024
2 parents aadbe46 + 38259c1 commit 703a76d
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 64 deletions.
8 changes: 1 addition & 7 deletions perllib/Integrations/Symology.pm
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,7 @@ sub current_date {
sub SOAP::Serializer::as_ArrayOfAdditionalFieldSend {
my ($self, $value, $name, $type, $attr) = @_;

# Allow individual integrations to provide their own values here, otherwise
# assume it's a simple value for the customer type field.
unless (ref $value eq 'ARRAY') {
$value = [
[ FieldLine => 17, ValueType => 1, DataValue => $value ],
];
}
die unless ref $value eq 'ARRAY';

my $elem = \SOAP::Data
->name('tns:AdditionalFieldSend' => map { [ make_soap_structure(@$_) ] } @$value)
Expand Down
1 change: 1 addition & 0 deletions perllib/Open311/Endpoint/Integration/Confirm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,7 @@ sub get_service_requests {
my $code = $enquiry->{ServiceCode} . "_" . $enquiry->{SubjectCode};
my $service = $services{$code};
my $status = $self->reverse_status_mapping->{$enquiry->{EnquiryStatusCode}};
next if $status && $status eq 'IGNORE';

unless ($service || ($service = $self->_find_wrapping_service($code, \@services))) {
$self->logger->warn("no service for service code $code");
Expand Down
38 changes: 32 additions & 6 deletions perllib/Open311/Endpoint/Integration/Symology.pm
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,28 @@ has update_urls => (
default => sub { $_[0]->endpoint_config->{update_urls} }
);

=item * field_defaults contains info for use when constructing the additional fields
=cut

has field_defaults => (
is => 'lazy',
default => sub { $_[0]->endpoint_config->{field_defaults} || {} }
);

=item * customer_defaults contains info for use when constructing the customer
=cut

has customer_defaults => (
is => 'lazy',
default => sub { $_[0]->endpoint_config->{customer_defaults} }
);

=item * request_defaults contains info for use when constructing the request
=cut

has request_defaults => (
is => 'lazy',
default => sub { $_[0]->endpoint_config->{request_defaults} || {} }
Expand Down Expand Up @@ -179,19 +196,28 @@ sub process_service_request_args {
}
}

# Bit Bexley-specific still
my $contact_type = $self->customer_defaults->{ContactType};
$contact_type //= $request->{contributed_by} ? 'TL' : 'OL';

my $customer = {
name => $args->{first_name} . " " . $args->{last_name},
email => $args->{email},
phone => $args->{phone},
customer_type => $self->customer_defaults->{CustomerType},
contact_type => $contact_type,
contact_type => $self->customer_defaults->{ContactType},
};

my $fields = delete $request->{contributed_by};
my $fields = [];
if (my $field_line_value = $self->field_defaults->{URL}) {
push @$fields, [ FieldLine => $field_line_value, ValueType => 8, DataValue => $args->{attributes}->{report_url} ];
}
if (my $field_line_value = $self->field_defaults->{PhotoStart}) {
my $value_type = $self->field_defaults->{PhotoType} || 8;
foreach my $photo_url ( @{ $args->{media_url} } ) {
push @$fields, [ FieldLine => $field_line_value, ValueType => $value_type, DataValue => $photo_url ];

# Only send the first three photos
last if $field_line_value == $self->field_defaults->{PhotoEnd};
$field_line_value++;
}
}

return ($request, $customer, $fields);
}
Expand Down
13 changes: 11 additions & 2 deletions perllib/Open311/Endpoint/Integration/UK/Bexley/Symology.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package Open311::Endpoint::Integration::UK::Bexley::Symology;
use Moo;
extends 'Open311::Endpoint::Integration::Symology';

use Open311::Endpoint::Service::UKCouncil::BexleySymology;
use Open311::Endpoint::Service::UKCouncil::Symology::Bexley;

has jurisdiction_id => (
is => 'ro',
Expand All @@ -14,16 +14,25 @@ has jurisdiction_id => (

has service_class => (
is => 'ro',
default => 'Open311::Endpoint::Service::UKCouncil::BexleySymology'
default => 'Open311::Endpoint::Service::UKCouncil::Symology::Bexley'
);

sub process_service_request_args {
my $self = shift;
my @args = $self->SUPER::process_service_request_args(@_);
my $request = $args[0];
my $customer = $args[1];

$request->{NextAction} = $self->post_add_next_action_update($request->{NSGRef});

$customer->{contact_type} = $request->{contributed_by} ? 'TL' : 'OL';

push @{ $args[2] }, [
FieldLine => 17,
ValueType => 1,
DataValue => delete $request->{contributed_by},
];

return @args;
}

Expand Down
12 changes: 0 additions & 12 deletions perllib/Open311/Endpoint/Integration/UK/Brent/Symology.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@ sub process_service_request_args {
my $response = $args[0];
$response->{Location} = $location;

push @{ $args[2] }, [ FieldLine => 3, ValueType => 8, DataValue => $_[0]->{attributes}->{report_url} ];
# Add the photo URLs to the request
my $field_line_value = 4;

foreach my $photo_url ( @{ $_[0]->{media_url} } ) {
push @{ $args[2] }, [ FieldLine => $field_line_value, ValueType => 7, DataValue => $photo_url ];

# Only send the first three photos
last if $field_line_value == 6;

$field_line_value++;
};
return @args;
}

Expand Down
26 changes: 0 additions & 26 deletions perllib/Open311/Endpoint/Integration/UK/Camden/Symology.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,4 @@ has jurisdiction_id => (
default => 'camden_symology',
);

=head2 process_service_request_args
Camden's Symology has got three fields for photo URLs. We send the first
three photo URLs to those fields when creating a report.
=cut

sub process_service_request_args {
my $self = shift;

my @args = $self->SUPER::process_service_request_args(@_);

# Add the photo URLs to the request
my $field_line_value = 10;
foreach my $photo_url ( @{ $_[0]->{media_url} } ) {
push @{ $args[2] }, [ FieldLine => $field_line_value, ValueType => 8, DataValue => $photo_url ];

# Only send the first three photos
last if $field_line_value == 12;

$field_line_value++;
}

return @args;
}

1;
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ sub process_service_request_args {

$response->{Location} = $location;

# Send the first photo to the appropriate field in Symology
# (these values are specific to Central Beds and were divined by
# inspecting the GetRequestAdditionalGroup output for an existing
# enquiry that had a photo.)
if ( my $photo_url = $_[0]->{media_url}->[0] ) {
$args[2] = [
[ FieldLine => 15, ValueType => 8, DataValue => $photo_url ],
];
}

return @args;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Open311::Endpoint::Service::UKCouncil::BexleySymology;
package Open311::Endpoint::Service::UKCouncil::Symology::Bexley;

use Moo;
extends 'Open311::Endpoint::Service::UKCouncil::Symology';
Expand Down
5 changes: 5 additions & 0 deletions t/open311/endpoint/brent_symology.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ request_defaults:
ServiceCode: 'ServiceCode'
customer_defaults:
CustomerType: "PB"
field_defaults:
URL: 3
PhotoStart: 4
PhotoEnd: 6
PhotoType: 7
event_action_event_type: CHRR
event_status_mapping:
19: 'investigating'
Expand Down
3 changes: 3 additions & 0 deletions t/open311/endpoint/camden_symology.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ username: FMS
customer_defaults:
CustomerType: ""
ContactType: ""
field_defaults:
PhotoStart: 10
PhotoEnd: 12
event_action_event_type: NOTE
category_mapping:
Potholes:
Expand Down
4 changes: 4 additions & 0 deletions t/open311/endpoint/centralbedfordshire_symology.t
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ $centralbeds_symology_end->mock(endpoint_config => sub {
{
username => 'FMS',
nsgref_to_action => {},
field_defaults => {
PhotoStart => 15,
PhotoEnd => 15,
},
customer_defaults => {
CustomerType => "",
ContactType => "",
Expand Down

0 comments on commit 703a76d

Please sign in to comment.