[freeside-commits] branch master updated. 3e8421688bfed701dd6d3be79c270db4af2b3e8d

Mark Wells mark at 420.am
Sun Jul 6 21:06:09 PDT 2014


The branch, master has been updated
       via  3e8421688bfed701dd6d3be79c270db4af2b3e8d (commit)
      from  9260bf91dae80e2b42b3d793505f11a5f162cbf5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3e8421688bfed701dd6d3be79c270db4af2b3e8d
Author: Mark Wells <mark at freeside.biz>
Date:   Sun Jul 6 21:06:04 2014 -0700

    Northern 911 export, #29195

diff --git a/FS/FS/part_export/northern_911.pm b/FS/FS/part_export/northern_911.pm
new file mode 100644
index 0000000..27f150c
--- /dev/null
+++ b/FS/FS/part_export/northern_911.pm
@@ -0,0 +1,107 @@
+package FS::part_export::northern_911;
+
+use strict;
+use vars qw(@ISA %info);
+use Tie::IxHash;
+use FS::Record qw(qsearch dbh);
+use base 'FS::part_export';
+use Data::Dumper;
+
+tie my %options, 'Tie::IxHash',
+  'vendor_code'   => { label=>'Northern 911 vendor code' },
+  'password'      => { label=>'API passcode' },
+  'test_mode'     => { label=>'Test mode',
+                       type =>'checkbox' },
+  'debug'         => { label=>'Enable debugging',
+                       type =>'checkbox' },
+;
+
+%info = (
+  'svc'     => 'svc_phone',
+  'desc'    => 'Provision E911 to Northern 911',
+  'options' => \%options,
+  'no_machine' => 1,
+  'notes'   => <<'END'
+Requires installation of
+<a href="http://search.cpan.org/dist/WebService-Northern911">WebService::Northern911</a>
+from CPAN.
+END
+);
+
+sub client {
+  my $self = shift;
+
+  if (!$self->get('client')) {
+    local $@;
+    eval "use WebService::Northern911";
+    return "error loading WebService::Northern911 ($@)" if $@;
+    $self->set('client',
+      WebService::Northern911->new(
+        vendor_code => $self->option('vendor_code'),
+        password    => $self->option('password'),
+        live        => ( $self->option('test_mode') ? 0 : 1),
+      )
+    );
+  }
+
+  return $self->get('client');
+}
+
+sub export_insert {
+  my( $self, $svc_phone ) = (shift, shift);
+
+  my %location_hash = $svc_phone->location_hash;
+  $location_hash{address1} =~ /^(\w+) +(.*)$/;
+  my %customer = (
+    'PHONE_NUMBER'        => $svc_phone->phonenum,
+    'STREET_NUMBER'       => $1,
+    'STREET_NAME'         => $2,
+    'CITY'                => $location_hash{city},
+    'PROVINCE_STATE'      => $location_hash{state},
+    'POSTAL_CODE_ZIP'     => $location_hash{zip},
+    'OTHER_ADDRESS_INFO'  => $location_hash{address2},
+  );
+
+  if ($self->option('debug')) {
+    warn "\nAddorUpdateCustomer:\n".Dumper(\%customer)."\n\n";
+  }
+  my $response = $self->client->AddorUpdateCustomer(%customer);
+  if (!$response->is_success) {
+    return $response->error_message;
+  }
+  '';
+}
+
+sub export_replace {
+  my( $self, $new, $old ) = (shift, shift, shift);
+
+  # except when changing the phone number, exactly like export_insert;
+  if ($new->phonenum ne $old->phonenum) {
+    my $error = $self->export_delete($old);
+    return $error if $error;
+  }
+  $self->export_insert($new);
+}
+
+sub export_delete {
+  my ($self, $svc_phone) = (shift, shift);
+
+  if ($self->option('debug')) {
+    warn "\nDeleteCustomer:\n".$svc_phone->phonenum."\n\n";
+  }
+  my $response = $self->client->DeleteCustomer($svc_phone->phonenum);
+  if (!$response->is_success) {
+    return $response->error_message;
+  }
+  '';
+}
+
+# export_suspend and _unsuspend do nothing
+
+sub export_relocate {
+  my ($self, $svc_phone) = (shift, shift);
+  $self->export_insert($svc_phone);
+}
+
+1;
+

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/part_export/northern_911.pm |  107 +++++++++++++++++++++++++++++++++++++
 1 file changed, 107 insertions(+)
 create mode 100644 FS/FS/part_export/northern_911.pm




More information about the freeside-commits mailing list