From 55c933db01346b350ad08c03246ca0db0473c056 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 30 Jun 2009 02:54:54 +0000 Subject: [PATCH] add DID association w/user? docs from netsapiens rough... RT#5226 --- FS/FS/part_export/netsapiens.pm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/FS/FS/part_export/netsapiens.pm b/FS/FS/part_export/netsapiens.pm index 172f7b053..22124e951 100644 --- a/FS/FS/part_export/netsapiens.pm +++ b/FS/FS/part_export/netsapiens.pm @@ -63,6 +63,15 @@ sub ns_subscriber { "/domains_config/$domain/subscriber_config/$phonenum"; } +sub ns_dialplan { + my($self, $svc_phone) = (shift, shift); + + my $countrycode = $svc_phone->countrycode; + my $phonenum = $svc_phone->phonenum; + + "/dialplans/DID+Table/dialplan_config/sip:$countrycode$phonenum@*" +} + sub ns_create_or_update { my($self, $svc_phone, $dial_policy) = (shift, shift, shift); @@ -80,6 +89,8 @@ sub ns_create_or_update { $lastname = $cust_main->get('last'); } + #create user + my $ns = $self->ns_command( 'PUT', $self->ns_subscriber($svc_phone), 'subscriber_login' => $phonenum.'@'.$domain, 'firstname' => $firstname, @@ -94,6 +105,17 @@ sub ns_create_or_update { join(', ', $self->ns_parse_response( $ns->responseContent ) ); } + #map DID to user + my $ns2 = $self->ns_command( 'PUT', $self->ns_dialplan($svc_phone), + 'to_user' => $phonenum.'@'.$domain, + 'to_host' => $domain, + ); + + if ( $ns2->responseCode !~ /^2/ ) { + return $ns2->responseCode. ' '. + join(', ', $self->ns_parse_response( $ns2->responseContent ) ); + } + ''; } -- 2.11.0