1 package FS::part_export::voip_innovations2_e911;
3 use vars qw(@ISA %info);
5 use FS::Record qw(qsearch dbh);
10 @ISA = qw(FS::part_export);
12 tie my %options, 'Tie::IxHash',
13 'login' => { label=>'VoIP Innovations API login' },
14 'password' => { label=>'VoIP Innovations API password' },
15 'endpointgroup' => { label=>'VoIP Innovations endpoint group number' },
16 'dry_run' => { label=>"Test mode - don't actually provision",
23 'desc' => 'Provision E911 only to VoIP Innovations (API 2.0)',
24 'options' => \%options,
27 Requires installation of
28 <a href="http://search.cpan.org/dist/Net-VoIP_Innovations">Net::VoIP_Innovations</a>
33 sub rebless { shift; }
36 my( $self, $command, @args ) = @_;
38 eval "use Net::VoIP_Innovations 2.00;";
44 my $gp = Net::VoIP_Innovations->new(
45 'login' => $self->option('login'),
46 'password' => $self->option('password'),
55 my( $self, $svc_phone ) = (shift, shift);
57 return '' if $self->option('dry_run');
59 #we want to provision and catch errors now, not queue
65 my %location_hash = $svc_phone->location_hash;
66 my( $zip, $plus4 ) = split('-', $location_hash->{zip});
67 my $e = $self->gp_command('911Insert',
68 'did' => $svc_phone->phonenum,
69 'Address1' => $location_hash{address1},
70 'Address2' => $location_hash{address2},
71 'City' => $location_hash{city},
72 'State' => $location_hash{state},
76 $svc_phone->phone_name
77 || $svc_phone->cust_svc->cust_pkg->cust_main->contact_firstlast,
82 if ( $edid->{'statuscode'} != 100 ) {
83 return "Error running VoIP Innovations 911Insert: ".
84 $edid->{'statuscode'}. ': '. $edid->{'status'};
91 my( $self, $new, $old ) = (shift, shift, shift);
93 #hmm, anything to change besides E911 data?
99 my %location_hash = $svc_phone->location_hash;
100 my( $zip, $plus4 ) = split('-', $location_hash->{zip});
101 my $e = $self->gp_command('911Update',
102 'did' => $svc_phone->phonenum,
103 'Address1' => $location_hash{address1},
104 'Address2' => $location_hash{address2},
105 'City' => $location_hash{city},
106 'State' => $location_hash{state},
108 'PlusFour' => $plus4,
110 $svc_phone->phone_name
111 || $svc_phone->cust_svc->cust_pkg->cust_main->contact_firstlast,
114 my $edid = $e->{did};
116 if ( $edid->{'statuscode'} != 100 ) {
117 return "Error running VoIP Innovations 911Update: ".
118 $edid->{'statuscode'}. ': '. $edid->{'status'};
125 my( $self, $svc_phone ) = (shift, shift);
127 return '' if $self->option('dry_run');
129 #XXX delete e911 information
134 sub _export_suspend {
135 my( $self, $svc_phone ) = (shift, shift);
140 sub _export_unsuspend {
141 my( $self, $svc_phone ) = (shift, shift);