From c0fc4ff514307f032b16b827b6f4b2ae95ca18f9 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 27 Jun 2008 00:27:08 +0000 Subject: commiting globalpops export start. stupid power failure. --- FS/FS/part_export/globalpops_voip.pm | 90 ++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 FS/FS/part_export/globalpops_voip.pm (limited to 'FS') diff --git a/FS/FS/part_export/globalpops_voip.pm b/FS/FS/part_export/globalpops_voip.pm new file mode 100644 index 000000000..c64e49a50 --- /dev/null +++ b/FS/FS/part_export/globalpops_voip.pm @@ -0,0 +1,90 @@ +package FS::part_export::globalpops_voip; + +use vars qw(@ISA %info); +use Tie::IxHash; +use FS::part_export; + +@ISA = qw(FS::part_export); + +tie my %options, 'Tie::IxHash', + 'login' => { label=>'GlobalPOPs Media Services API login', + 'password' => { label=>'GlobalPOPs Media Services API password', +; + +%info = ( + 'svc' => 'svc_phone', + 'desc' => 'Provision phone numbers to GlobalPOPs VoIP', + 'options' => \%options, + 'notes' => <<'END' +Requires installation of +Net::GlobalPOPs::MediaServicesAPI +from CPAN. +END +); + +sub rebless { shift; } + +sub _export_insert { + my( $self, $svc_phone ) = (shift, shift); + #we want to provision and catch errors now, not queue +} + +sub _export_replace { + my( $self, $new, $old ) = (shift, shift, shift); + #hmm, what's to change? +} + +sub _export_delete { + my( $self, $svc_phone ) = (shift, shift); + #probably okay to queue the deletion... +} + +sub _export_suspend { + my( $self, $svc_phone ) = (shift, shift); + #nop for now +} + +sub _export_unsuspend { + my( $self, $svc_phone ) = (shift, shift); + #nop for now +} + +#hmm, might forgo queueing entirely for most things, data is too much of a pita + +sub globalpops_voip_queue { + my( $self, $svcnum, $method ) = (shift, shift, shift); + my $queue = new FS::queue { + 'svcnum' => $svcnum, + 'job' => 'FS::part_export::globalpops_voip::globalpops_voip_command', + }; + $queue->insert( + $self->option('login'), + $self->option('password'), + $method, + @_, + ); +} + +sub globalpops_voip_command { + my($login, $password, $method, @args) = @_; + + eval "use Net::GlobalPOPs::MediaServicesAPI;"; + die $@ if $@: + + my $gp = new Net::GlobalPOPs + 'login' => $login, + 'password' => $password, + #'debug' => 1, + ; + + my $return = $gp->$method( @args ); + + #$return->{'status'} + #$return->{'statuscode'} + + die $return->{'status'} if $return->{'statuscode'}; + +} + +1; + -- cgit v1.2.1