From 4a7d77be7b7ddf76dd9cdd674d04104ee990b0e4 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Sat, 25 Jan 2014 17:24:11 -0800 Subject: [PATCH] voip innovations v3.0 api, RT#25641 --- FS/FS/part_export.pm | 1 + FS/FS/part_export/fibernetics_did.pm | 1 + FS/FS/part_export/globalpops_voip.pm | 2 + FS/FS/part_export/internal_diddb.pm | 2 + FS/FS/part_export/vitelity.pm | 1 + FS/FS/part_export/voip_innovations2.pm | 2 + FS/FS/part_export/voip_innovations3.pm | 106 ++++++++++++++++++++------------- FS/FS/part_export/voipnow_did.pm | 2 + FS/FS/part_svc.pm | 2 +- 9 files changed, 76 insertions(+), 43 deletions(-) diff --git a/FS/FS/part_export.pm b/FS/FS/part_export.pm index 8b1624851..8e10ea712 100644 --- a/FS/FS/part_export.pm +++ b/FS/FS/part_export.pm @@ -680,6 +680,7 @@ sub info { } #default fallbacks... FS::part_export::DID_Common ? +sub can_get_dids { 0; } sub get_dids_can_tollfree { 0; } sub get_dids_can_manual { 0; } sub get_dids_can_edit { 0; } #don't use without can_manual, otherwise the diff --git a/FS/FS/part_export/fibernetics_did.pm b/FS/FS/part_export/fibernetics_did.pm index a51457a03..9fd996805 100644 --- a/FS/FS/part_export/fibernetics_did.pm +++ b/FS/FS/part_export/fibernetics_did.pm @@ -27,6 +27,7 @@ tie my %options, 'Tie::IxHash', sub rebless { shift; } +sub can_get_dids { 1; } sub get_dids_can_tollfree { 0; }; sub get_dids_can_manual { 1; }; sub get_dids_can_edit { 1; }; diff --git a/FS/FS/part_export/globalpops_voip.pm b/FS/FS/part_export/globalpops_voip.pm index 59e0bc46f..5eee13f34 100644 --- a/FS/FS/part_export/globalpops_voip.pm +++ b/FS/FS/part_export/globalpops_voip.pm @@ -30,6 +30,8 @@ END sub rebless { shift; } +sub can_get_dids { 1; } + sub get_dids { my $self = shift; my %opt = ref($_[0]) ? %{$_[0]} : @_; diff --git a/FS/FS/part_export/internal_diddb.pm b/FS/FS/part_export/internal_diddb.pm index b51f63173..bb9743328 100644 --- a/FS/FS/part_export/internal_diddb.pm +++ b/FS/FS/part_export/internal_diddb.pm @@ -22,6 +22,8 @@ tie my %options, 'Tie::IxHash', sub rebless { shift; } +sub can_get_dids { 1; } + sub get_dids { my $self = shift; my %opt = ref($_[0]) ? %{$_[0]} : @_; diff --git a/FS/FS/part_export/vitelity.pm b/FS/FS/part_export/vitelity.pm index 3c0534fc1..4f73d628e 100644 --- a/FS/FS/part_export/vitelity.pm +++ b/FS/FS/part_export/vitelity.pm @@ -39,6 +39,7 @@ END sub rebless { shift; } +sub can_get_dids { 1; } sub get_dids_can_tollfree { 1; }; sub get_dids { diff --git a/FS/FS/part_export/voip_innovations2.pm b/FS/FS/part_export/voip_innovations2.pm index 87a77c287..af6825c0c 100644 --- a/FS/FS/part_export/voip_innovations2.pm +++ b/FS/FS/part_export/voip_innovations2.pm @@ -35,6 +35,8 @@ END sub rebless { shift; } +sub can_get_dids { 1; } + sub get_dids { my $self = shift; my %opt = ref($_[0]) ? %{$_[0]} : @_; diff --git a/FS/FS/part_export/voip_innovations3.pm b/FS/FS/part_export/voip_innovations3.pm index 630d0c41f..3e4a1fe7e 100644 --- a/FS/FS/part_export/voip_innovations3.pm +++ b/FS/FS/part_export/voip_innovations3.pm @@ -49,13 +49,13 @@ sub vi_command { die $@; } - my $gp = Net::VoIP_Innovations->new( + my $vi = Net::VoIP_Innovations->new( 'login' => $self->option('login'), 'password' => $self->option('password'), #'debug' => $debug, ); - $gp->$command(@args); + $vi->$command(@args); } @@ -68,6 +68,8 @@ sub _export_insert { unless ( $self->option('no_provision_did') ) { + return "can't yet provision to VoIP Innovations v3 API"; #XXX + ### # reserveDID ### @@ -106,31 +108,29 @@ sub _export_insert { } ### - # 911Insert + # insert911 ### if ( $self->option('e911') ) { my %location_hash = $svc_phone->location_hash; my( $zip, $plus4 ) = split('-', $location_hash->{zip}); - my $e = $self->vi_command('911Insert', + my $resp = $self->vi_command('insert911', 'did' => $svc_phone->phonenum, - 'Address1' => $location_hash{address1}, - 'Address2' => $location_hash{address2}, - 'City' => $location_hash{city}, - 'State' => $location_hash{state}, - 'ZipCode' => $zip, - 'PlusFour' => $plus4, - 'CallerName' => + 'address1' => $location_hash{address1}, + 'address2' => $location_hash{address2}, + 'city' => $location_hash{city}, + 'state' => $location_hash{state}, + 'zip' => $zip, + 'plusFour' => $plus4, + 'callerName' => $svc_phone->phone_name || $svc_phone->cust_svc->cust_pkg->cust_main->contact_firstlast, ); - my $edid = $e->{did}; - - if ( $edid->{'statuscode'} != 100 ) { - return "Error running VoIP Innovations 911Insert: ". - $edid->{'statuscode'}. ': '. $edid->{'status'}; + if ( $resp->{'responseCode'} != 100 ) { + return "Error running VoIP Innovations insert911: ". + $resp->{'responseCode'}. ': '. $resp->{'responseMessage'}; } } @@ -149,26 +149,24 @@ sub _export_replace { if ( $self->option('e911') ) { - my %location_hash = $svc_phone->location_hash; + my %location_hash = $new->location_hash; my( $zip, $plus4 ) = split('-', $location_hash->{zip}); - my $e = $self->vi_command('911Update', + my $resp = $self->vi_command('update911', 'did' => $svc_phone->phonenum, - 'Address1' => $location_hash{address1}, - 'Address2' => $location_hash{address2}, - 'City' => $location_hash{city}, - 'State' => $location_hash{state}, - 'ZipCode' => $zip, - 'PlusFour' => $plus4, - 'CallerName' => + 'address1' => $location_hash{address1}, + 'address2' => $location_hash{address2}, + 'city' => $location_hash{city}, + 'state' => $location_hash{state}, + 'zip' => $zip, + 'plusFour' => $plus4, + 'callerName' => $svc_phone->phone_name || $svc_phone->cust_svc->cust_pkg->cust_main->contact_firstlast, ); - my $edid = $e->{did}; - - if ( $edid->{'statuscode'} != 100 ) { - return "Error running VoIP Innovations 911Update: ". - $edid->{'statuscode'}. ': '. $edid->{'status'}; + if ( $resp->{'responseCode'} != 100 ) { + return "Error running VoIP Innovations update911: ". + $resp->{'responseCode'}. ': '. $resp->{'responseMessage'}; } } @@ -179,24 +177,48 @@ sub _export_replace { sub _export_delete { my( $self, $svc_phone ) = (shift, shift); - return '' if $self->option('dry_run') - || $self->option('no_provision_did'); + return '' if $self->option('dry_run'); - #probably okay to queue the deletion...? - #but hell, let's do it inline anyway, who wants phone numbers hanging around + ### + # releaseDID + ### - my $r = $self->vi_command('releaseDID', - 'did' => $svc_phone->phonenum, - ); + unless ( $self->option('no_provision_did') ) { + + return "can't yet provision to VoIP Innovations v3 API"; #XXX + + #probably okay to queue the deletion...? + #but hell, let's do it inline anyway, who wants phone numbers hanging around + + my $r = $self->vi_command('releaseDID', + 'did' => $svc_phone->phonenum, + ); + + my $rdid = $r->{did}; - my $rdid = $r->{did}; + if ( $rdid->{'statuscode'} != 100 ) { + return "Error running VoIP Innovations releaseDID: ". + $rdid->{'statuscode'}. ': '. $rdid->{'status'}; + } - if ( $rdid->{'statuscode'} != 100 ) { - return "Error running VoIP Innovations releaseDID: ". - $rdid->{'statuscode'}. ': '. $rdid->{'status'}; } - #delete e911 information? assuming release clears all that + ### + # remove911 + ### + + if ( $self->option('e911') ) { + + my $resp = $self->vi_command('remove911', + 'did' => $svc_phone->phonenum, + ); + + if ( $resp->{'responseCode'} != 100 ) { + return "Error running VoIP Innovations remove911: ". + $resp->{'responseCode'}. ': '. $resp->{'responseMessage'}; + } + + } ''; } diff --git a/FS/FS/part_export/voipnow_did.pm b/FS/FS/part_export/voipnow_did.pm index 514db8dcd..1e1536936 100644 --- a/FS/FS/part_export/voipnow_did.pm +++ b/FS/FS/part_export/voipnow_did.pm @@ -44,6 +44,8 @@ sub did_cache { return $CACHE->get($self->exportnum) || $self->reload_cache; } +sub can_get_dids { 1; } + sub get_dids { my $self = shift; my %opt = @_; diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm index 27f0063a5..01f303494 100644 --- a/FS/FS/part_svc.pm +++ b/FS/FS/part_svc.pm @@ -480,7 +480,7 @@ are capable of returing available DID (phone number) information. sub part_export_did { my $self = shift; - grep $_->can('get_dids'), $self->part_export; + grep $_->can_get_dids, $self->part_export; } =item part_export_dsl_pull -- 2.11.0