1 package FS::part_export::northern_911;
4 use vars qw(@ISA %info);
6 use FS::Record qw(qsearch dbh);
7 use base 'FS::part_export';
10 tie my %options, 'Tie::IxHash',
11 'vendor_code' => { label=>'Northern 911 vendor code' },
12 'password' => { label=>'API passcode' },
13 'test_mode' => { label=>'Test mode',
15 'debug' => { label=>'Enable debugging',
21 'desc' => 'Provision E911 to Northern 911',
22 'options' => \%options,
25 Requires installation of
26 <a href="http://search.cpan.org/dist/WebService-Northern911">WebService::Northern911</a>
34 if (!$self->get('client')) {
36 eval "use WebService::Northern911";
37 return "error loading WebService::Northern911 ($@)" if $@;
39 WebService::Northern911->new(
40 vendor_code => $self->option('vendor_code'),
41 password => $self->option('password'),
42 live => ( $self->option('test_mode') ? 0 : 1),
47 return $self->get('client');
51 my( $self, $svc_phone ) = (shift, shift);
53 my %location_hash = $svc_phone->location_hash;
54 $location_hash{address1} =~ /^(\w+) +(.*)$/;
56 'PHONE_NUMBER' => $svc_phone->phonenum,
57 'STREET_NUMBER' => $1,
59 'CITY' => $location_hash{city},
60 'PROVINCE_STATE' => $location_hash{state},
61 'POSTAL_CODE_ZIP' => $location_hash{zip},
62 'OTHER_ADDRESS_INFO' => $location_hash{address2},
65 if ($self->option('debug')) {
66 warn "\nAddorUpdateCustomer:\n".Dumper(\%customer)."\n\n";
68 my $response = $self->client->AddorUpdateCustomer(%customer);
69 if (!$response->is_success) {
70 return $response->error_message;
76 my( $self, $new, $old ) = (shift, shift, shift);
78 # except when changing the phone number, exactly like export_insert;
79 if ($new->phonenum ne $old->phonenum) {
80 my $error = $self->export_delete($old);
81 return $error if $error;
83 $self->export_insert($new);
87 my ($self, $svc_phone) = (shift, shift);
89 if ($self->option('debug')) {
90 warn "\nDeleteCustomer:\n".$svc_phone->phonenum."\n\n";
92 my $response = $self->client->DeleteCustomer($svc_phone->phonenum);
93 if (!$response->is_success) {
94 return $response->error_message;
99 # export_suspend and _unsuspend do nothing
101 sub export_relocate {
102 my ($self, $svc_phone) = (shift, shift);
103 $self->export_insert($svc_phone);