X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fthinktel.pm;h=9ab645539c3d0d7e2aaeded2a9150dfc6eacb11d;hb=38e34bbc53a4222c7507e95914e1364a5a74623f;hp=4a28649a3919d7ea1d1a703b6c0a5fe57ef442c1;hpb=fcb43580b83129097a2abf53104ca29f3185d44b;p=freeside.git diff --git a/FS/FS/part_export/thinktel.pm b/FS/FS/part_export/thinktel.pm index 4a28649a3..9ab645539 100644 --- a/FS/FS/part_export/thinktel.pm +++ b/FS/FS/part_export/thinktel.pm @@ -7,7 +7,7 @@ use Tie::IxHash; use URI::Escape; use LWP::UserAgent; use URI::Escape; -use JSON; +use Cpanel::JSON::XS; use FS::Record qw( qsearch qsearchs ); @@ -66,9 +66,11 @@ tie my %roles, 'Tie::IxHash', }, 'did' => { label => 'DID', svcdb => 'svc_phone', + multiple => 1, }, 'gateway' => { label => 'SIP gateway', - svcdb => 'svc_pbx' + svcdb => 'svc_pbx', + multiple => 1, }, ; @@ -86,7 +88,7 @@ our %info = (
  • A phone service for the SIP trunk. This should be attached to the export in the "trunk" role. Usually there will be only one of these per package. The max_simultaneous field of this service will set - the channel limit on the trunk. The I will be used for + the channel limit on the trunk. The sip_password will be used for all gateways.
  • A phone service for a DID. This should be attached in the "did" role. DIDs should have no properties other than the number and the E911 @@ -103,40 +105,6 @@ our %info = ( END ); -=item svc_with_role { SVC | PKGNUM }, ROLE - -Finds the service(s) in the same package as SVC (or the package PKGNUM) that -are linked to the export in ROLE (trunk, gateway, or did). - -=cut - -sub svc_with_role { - my $self = shift; - my $svc_or_pkgnum = shift; - my $role = shift; - my $pkgnum; - if ( ref $svc_or_pkgnum ) { - $pkgnum = $svc_or_pkgnum->cust_svc->pkgnum or return ''; - } else { - $pkgnum = $svc_or_pkgnum; - } - my $svcdb = ($role eq 'gateway' ? 'svc_pbx' : 'svc_phone'); - my @svcs = qsearch({ - 'table' => $svcdb, - 'addl_from' => ' JOIN cust_svc USING (svcnum)' . - ' JOIN export_svc USING (svcpart)', - 'extra_sql' => " WHERE cust_svc.pkgnum = $pkgnum" . - " AND export_svc.exportnum = ".$self->exportnum . - " AND export_svc.role = '$role'", - }); - if ( $role eq 'trunk' ) { - warn "$me more than one trunk service in pkgnum $pkgnum.\n" if @svcs > 1; - return $svcs[0]; - } else { - return @svcs; - } -} - sub check_svc { # check the service for validity my($self, $svc_x) = (shift, shift); my $role = $self->svc_role($svc_x) @@ -163,7 +131,7 @@ sub check_svc { # check the service for validity ''; } -sub export_insert { +sub _export_insert { my($self, $svc_x) = (shift, shift); my $error = $self->check_svc($svc_x); @@ -246,7 +214,7 @@ sub insert_gateway { my $content = { ContactIPAddress => $svc_x->ip_addr, ContactPort => 5060, - IPMatchRequired => JSON::true, + IPMatchRequired => Cpanel::JSON::XS::true, SipDomainName => $self->option('proxy'), SipTrunkType => $self->option('trunktype'), SipUsername => $trunknum, @@ -302,7 +270,7 @@ sub insert_trunk { my $endpoint = "SipTrunks"; my $content = { Account => $self->option('username'), - Enabled => JSON::true, + Enabled => Cpanel::JSON::XS::true, Label => $svc_x->phone_name_or_cust, Locale => $locales{$self->option('locale')}, MaxChannels => $svc_x->max_simultaneous, @@ -326,7 +294,7 @@ sub insert_trunk { } } -sub export_replace { +sub _export_replace { my ($self, $svc_new, $svc_old) = @_; my $error = $self->check_svc($svc_new); @@ -357,7 +325,7 @@ sub replace_trunk { my $self = FS::part_export->by_key($exportnum); my $svc_x = FS::svc_phone->by_key($svcnum); - my $enabled = JSON::is_bool( $self->cust_svc->cust_pkg->susp == 0 ); + my $enabled = Cpanel::JSON::XS::is_bool( $self->cust_svc->cust_pkg->susp == 0 ); my $phonenum = $svc_x->phonenum; my $endpoint = "SipTrunks/$phonenum"; @@ -430,7 +398,7 @@ sub replace_gateway { ContactIPAddress => $svc_x->ip_addr, ContactPort => 5060, ID => $binding_id, - IPMatchRequired => JSON::true, + IPMatchRequired => Cpanel::JSON::XS::true, Name => $binding_name, SipDomainName => $self->option('proxy'), SipTrunkType => $self->option('trunktype'), @@ -444,7 +412,7 @@ sub replace_gateway { } } -sub export_delete { +sub _export_delete { my ($self, $svc_x) = (shift, shift); my $role = $self->svc_role($svc_x) @@ -638,7 +606,7 @@ have a 'Message' element. sub api_request { my $self = shift; my ($method, $endpoint, $content) = @_; - my $json = JSON->new->canonical(1); # hash keys are ordered + my $json = Cpanel::JSON::XS->new->canonical(1); # hash keys are ordered $DEBUG ||= 1 if $self->option('debug');