X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fthirdlane.pm;h=60c099748d67a1bf35b7c2b21a08d53c425481a6;hb=ff27c3f36240aee48ed50153dd5d8fe3ac3f2443;hp=f2846fc7f122aa4e01b99fdc2a4b4d53a9553c18;hpb=5632dffc420f19b86504044f21b53babe6447135;p=freeside.git diff --git a/FS/FS/part_export/thirdlane.pm b/FS/FS/part_export/thirdlane.pm index f2846fc7f..60c099748 100644 --- a/FS/FS/part_export/thirdlane.pm +++ b/FS/FS/part_export/thirdlane.pm @@ -13,8 +13,12 @@ tie my %options, 'Tie::IxHash', #'server' => { label => 'Thirdlane server name or IP address', }, 'username' => { label => 'Thirdlane username', }, 'password' => { label => 'Thirdlane password', }, - 'port' => { label => 'Port number if not 80', }, + 'ssl' => { label => 'Enable HTTPS (SSL) connection', + type => 'checkbox', + }, + 'port' => { label => 'Port number if not 80 or 443', }, 'prototype_tenant' => { label => 'Prototype tenant name', }, + 'omit_countrycode' => { label => 'Omit country code', type => 'checkbox' }, 'debug' => { label => 'Checkbox label', type => 'checkbox' }, # 'select_option' => { label => 'Select option description', # type => 'select', options=>[qw(chocolate vanilla)], @@ -71,7 +75,7 @@ sub _export_insert { my $result = $self->_thirdlane_command( 'asterisk::rpc_did_create', - $svc_x->countrycode. $svc_x->phonenum, + $self->_thirdlane_did($svc_x) ); #use Data::Dumper; @@ -82,7 +86,7 @@ sub _export_insert { $result = $self->_thirdlane_command( 'asterisk::rpc_did_assign', - $svc_x->countrycode. $svc_x->phonenum, + $self->_thirdlane_did($svc_x), $svc_x->pbx_title, ); @@ -153,7 +157,7 @@ sub _export_replace { if ( $old->pbxsvc ) { my $result = $self->_thirdlane_command( 'asterisk::rpc_did_unassign', - $new->countrycode. $new->phonenum, + $self->_thirdlane_did($old), ); $result eq '0' or return 'Thirdlane API failure (rpc_did_unassign)'; } @@ -161,7 +165,7 @@ sub _export_replace { if ( $new->pbxsvc ) { my $result = $self->_thirdlane_command( 'asterisk::rpc_did_assign', - $new->countrycode. $new->phonenum, + $self->_thirdlane_did($new), $new->pbx_title, ); $result eq '0' or return 'Thirdlane API failure (rpc_did_assign)'; @@ -186,7 +190,7 @@ sub _export_replace { ''; #we don't care then } else { - die "guru meditation #11: $svc_x is not FS::svc_pbx, FS::svc_phone or FS::svc_acct"; + die "guru meditation #11: $new is not FS::svc_pbx, FS::svc_phone or FS::svc_acct"; } } @@ -216,14 +220,14 @@ sub _export_delete { if ( $svc_x->pbxsvc ) { my $result = $self->_thirdlane_command( 'asterisk::rpc_did_unassign', - $svc_x->countrycode. $svc_x->phonenum, + $self->_thirdlane_did($svc_x), ); $result eq '0' or return 'Thirdlane API failure (rpc_did_unassign)'; } my $result = $self->_thirdlane_command( 'asterisk::rpc_did_delete', - $svc_x->countrycode. $svc_x->phonenum, + $self->_thirdlane_did($svc_x), ); $result eq '0' ? '' : 'Thirdlane API failure (rpc_did_delete)'; @@ -253,10 +257,11 @@ sub _export_delete { sub _thirdlane_command { my($self, @param) = @_; - my $url = 'http://'. uri_escape($self->option('username')). ':'. - uri_escape($self->option('password')). '@'. - $self->machine; - $url.= ':'. $self->option('port') if $self->option('port'); + my $url = $self->option('ssl') ? 'https://' : 'http://'; + $url .= uri_escape($self->option('username')). ':'. + uri_escape($self->option('password')). '@'. + $self->machine; + $url .= ':'. $self->option('port') if $self->option('port'); $url .= '/xmlrpc.cgi'; warn "$me connecting to $url\n" @@ -272,6 +277,15 @@ sub _thirdlane_command { } +sub _thirdlane_did { + my($self, $svc_phone) = @_; + if ( $self->option('omit_countrycode') ) { + $svc_phone->phonenum; + } else { + $svc_phone->countrycode. $svc_phone->phonenum; + } +} + #my( $self, $svc_something ) = (shift, shift); #$err_or_queue = $self->thirdlane_queue( $svc_something->svcnum, # 'delete', $svc_something->username );