X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fnetsapiens.pm;h=31d16a83ed4b8c6de742ff5787bc25c827726b9d;hb=bfee00e26a87ccc687f085fdeaffef8e4b2a9b50;hp=9181344fb767c3c73f07ff2341d40c824caa063c;hpb=b898dc674b2d5158a2ecccd3424ad2ea7dc264e0;p=freeside.git diff --git a/FS/FS/part_export/netsapiens.pm b/FS/FS/part_export/netsapiens.pm index 9181344fb..31d16a83e 100644 --- a/FS/FS/part_export/netsapiens.pm +++ b/FS/FS/part_export/netsapiens.pm @@ -1,7 +1,6 @@ package FS::part_export::netsapiens; use vars qw(@ISA $me %info); -use URI; use MIME::Base64; use Tie::IxHash; use FS::part_export; @@ -21,7 +20,7 @@ tie my %options, 'Tie::IxHash', ; %info = ( - 'svc' => 'svc_phone', + 'svc' => [ 'svc_phone', ], # 'part_device', 'desc' => 'Provision phone numbers to NetSapiens', 'options' => \%options, 'notes' => <<'END' @@ -61,8 +60,7 @@ sub _ns_command { $args[0] .= $ns->buildQuery( { @_ } ); } - warn "$me $method ". $self->option($prefix.'url'). - " $command ". join(', ', @_). "\n" + warn "$me $method ". $self->option($prefix.'url'). join(', ', @args). "\n" if $self->option('debug'); my $auth = encode_base64( $self->option($prefix.'login'). ':'. @@ -73,10 +71,15 @@ sub _ns_command { $ns; } +sub ns_domain { + my($self, $svc_phone) = (shift, shift); + $svc_phone->domain || $self->option('domain'); +} + sub ns_subscriber { my($self, $svc_phone) = (shift, shift); - my $domain = $self->option('domain'); + my $domain = $self->ns_domain($svc_phone); my $phonenum = $svc_phone->phonenum; "/domains_config/$domain/subscriber_config/$phonenum"; @@ -85,10 +88,6 @@ sub ns_subscriber { sub ns_registrar { my($self, $svc_phone) = (shift, shift); - my $domain = $self->option('domain'); - my $countrycode = $svc_phone->countrycode; - my $phonenum = $svc_phone->phonenum; - $self->ns_subscriber($svc_phone). '/registrar_config/'. $self->ns_devicename($svc_phone); } @@ -96,20 +95,22 @@ sub ns_registrar { sub ns_devicename { my( $self, $svc_phone ) = (shift, shift); - my $domain = $self->option('domain'); - my $countrycode = $svc_phone->countrycode; + my $domain = $self->ns_domain($svc_phone); + #my $countrycode = $svc_phone->countrycode; my $phonenum = $svc_phone->phonenum; - "sip:$countrycode$phonenum@$domain"; + #"sip:$countrycode$phonenum\@$domain"; + "sip:$phonenum\@$domain"; } sub ns_dialplan { my($self, $svc_phone) = (shift, shift); - my $countrycode = $svc_phone->countrycode; + #my $countrycode = $svc_phone->countrycode; my $phonenum = $svc_phone->phonenum; - "/dialplans/DID+Table/dialplan_config/sip:$countrycode$phonenum@*" + #"/dialplans/DID+Table/dialplan_config/sip:$countrycode$phonenum\@*" + "/domains_config/admin-only/dialplans/DID+Table/dialplan_config/sip:$phonenum\@*,*,*,*,*,*,*"; } sub ns_device { @@ -118,14 +119,14 @@ sub ns_device { #my $countrycode = $svc_phone->countrycode; #my $phonenum = $svc_phone->phonenum; - "/phones_config/". $phone_device->mac_addr; + "/phones_config/". lc($phone_device->mac_addr); } sub ns_create_or_update { my($self, $svc_phone, $dial_policy) = (shift, shift, shift); - my $domain = $self->option('domain'); - my $countrycode = $svc_phone->countrycode; + my $domain = $self->ns_domain($svc_phone); + #my $countrycode = $svc_phone->countrycode; my $phonenum = $svc_phone->phonenum; my( $firstname, $lastname ); @@ -158,6 +159,7 @@ sub ns_create_or_update { #Piece 2 - sip device creation my $ns2 = $self->ns_command( 'PUT', $self->ns_registrar($svc_phone), + 'termination_match' => $self->ns_devicename($svc_phone) ); if ( $ns2->responseCode !~ /^2/ ) { @@ -168,7 +170,7 @@ sub ns_create_or_update { #Piece 3 - DID mapping to user my $ns3 = $self->ns_command( 'PUT', $self->ns_dialplan($svc_phone), - 'to_user' => $countrycode.$phonenum, + 'to_user' => $phonenum, 'to_host' => $domain, ); @@ -240,17 +242,15 @@ sub _export_unsuspend { sub export_device_insert { my( $self, $svc_phone, $phone_device ) = (shift, shift, shift); - #my $domain = $self->option('domain'); + my $domain = $self->ns_domain($svc_phone); my $countrycode = $svc_phone->countrycode; my $phonenum = $svc_phone->phonenum; - my $device = $self->ns_devicename($svc_phone); - my $ns = $self->ns_device_command( 'PUT', $self->ns_device($svc_phone, $phone_device), 'line1_enable' => 'yes', 'device1' => $self->ns_devicename($svc_phone), - 'line1_ext' => $countrycode.$phonenum, + 'line1_ext' => $phonenum, , #'line2_enable' => 'yes', #'device2' => @@ -258,7 +258,7 @@ sub export_device_insert { #'notes' => 'server' => 'SiPbx', - 'domain' => $self->option('domain'), + 'domain' => $domain, 'brand' => $phone_device->part_device->devicename,