X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fnetsapiens.pm;h=a24bc3727cbcfb97b2f4c5b3dc0e5e958f97e4b1;hb=b3e081bbd2ba95554687a531bc134c00026a3669;hp=a1957d46dbca1d9e7fb9e84fd897e35a8c07a18b;hpb=ef49390629d8bd97cc4f607b559c9552aa86b482;p=freeside.git diff --git a/FS/FS/part_export/netsapiens.pm b/FS/FS/part_export/netsapiens.pm index a1957d46d..a24bc3727 100644 --- a/FS/FS/part_export/netsapiens.pm +++ b/FS/FS/part_export/netsapiens.pm @@ -1,12 +1,13 @@ package FS::part_export::netsapiens; -use vars qw(@ISA %info); +use vars qw(@ISA $me %info); use URI; use MIME::Base64; use Tie::IxHash; use FS::part_export; @ISA = qw(FS::part_export); +$me = '[FS::part_export::netsapiens]'; tie my %options, 'Tie::IxHash', 'login' => { label=>'NetSapiens tac2 User API username' }, @@ -16,6 +17,7 @@ tie my %options, 'Tie::IxHash', 'device_password' => { label=>'NetSapiens tac2 Device API password' }, 'device_url' => { label=>'NetSapiens tac2 Device URL' }, 'domain' => { label=>'NetSapiens Domain' }, + 'debug' => { label=>'Enable debugging', type=>'checkbox' }, ; %info = ( @@ -38,10 +40,10 @@ sub ns_command { sub ns_device_command { my $self = shift; - $self->_ns_command('device', @_); + $self->_ns_command('device_', @_); } -sub ns_command { +sub _ns_command { my( $self, $prefix, $method, $command ) = splice(@_,0,4); eval 'use REST::Client'; @@ -59,6 +61,10 @@ sub ns_command { $args[0] .= $ns->buildQuery( { @_ } ); } + warn "$me $method ". $self->option($prefix.'url'). + " $command ". join(', ', @_). "\n" + if $self->option('debug'); + my $auth = encode_base64( $self->option($prefix.'login'). ':'. $self->option($prefix.'password') ); push @args, { 'Authorization' => "Basic $auth" }; @@ -112,7 +118,7 @@ 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 { @@ -281,7 +287,6 @@ sub export_device_delete { ''; - }