1 package FS::part_export::cust_location_http;
4 use base qw( FS::part_export::http );
5 use vars qw( %options %info );
7 my @location_fields = qw(
29 tie %options, 'Tie::IxHash',
30 'method' => { label =>'Method',
32 #options =>[qw(POST GET)],
35 'url' => { label => 'URL', default => 'http://', },
36 'ssl_no_verify' => { label => 'Skip SSL certificate validation',
39 'include_fields' => { 'label' => 'Include fields',
42 'options' => [ @location_fields ] },
44 label => 'Success Regexp',
50 'svc' => [qw( cust_location )],
51 'desc' => 'Send an HTTP or HTTPS GET or POST request, for customer locations',
52 'options' => \%options,
55 Send an HTTP or HTTPS GET or POST to the specified URL on customer location insert
56 or replace. Always sends cgi fields action ('insert' or 'replace') and locationnum,
57 as well as any fields specified below. Only sends on replace if one of the
58 specified fields changed.
59 For HTTPS support, <a href="http://search.cpan.org/dist/Crypt-SSLeay">Crypt::SSLeay</a>
60 or <a href="http://search.cpan.org/dist/IO-Socket-SSL">IO::Socket::SSL</a> is required.
64 sub http_queue_standard {
66 $self->http_queue( '',
67 ( $self->option('ssl_no_verify') ? 'ssl_no_verify' : '' ),
68 $self->option('method'),
70 $self->option('success_regexp'),
77 split( /\s+/, $self->option('include_fields') );
81 my( $self, $action, $cust_location ) = ( shift, shift, shift );
83 return '' unless $action eq 'insert';
85 $self->http_queue_standard(
87 map { $_ => $cust_location->get($_) } ('locationnum', $self->_include_fields)
92 # currently, only custnum can change (when converting prospect to customer)
93 # but using more generic logic for ease of adding other changeable fields
95 my( $self, $new, $old ) = ( shift, shift, shift );
98 foreach my $field ($self->_include_fields) {
99 next if $new->get($field) eq $old->get($field);
100 next if ($field =~ /latitude|longitude/) and $new->get($field) == $old->get($field);
103 return '' unless $changed;
105 $self->http_queue_standard(
106 'action' => 'replace',
107 map { $_ => $new->get($_) } ('locationnum', $self->_include_fields)