initial version appears to be hooked up and working against dev sandbox
[Net-VoIP_Innovations.git] / lib / Net / VoIP_Innovations.pm
index bd56c8b..01affe2 100644 (file)
@@ -3,9 +3,8 @@ package Net::VoIP_Innovations;
 use warnings;
 use strict;
 use Data::Dumper;
-use XML::Simple;
-use XML::Writer;
-use Net::HTTPS::Any qw( 0.10 https_post );
+use SOAP::Lite;
+#SOAP::Lite->import(+trace=>'debug');
 
 =head1 NAME
 
@@ -13,19 +12,16 @@ Net::VoIP_Innovations - Interface to VoIP_Innovations API
 
 =cut
 
-our $VERSION = '2.00';
-our $URL     = 'https://www.loginto.us/VOIP/api2.pl';
-#could be parsed from URL, if it mattered...
-our $HOST    = 'www.loginto.us';
-our $PATH    = '/VOIP/api2.pl';
-our $PORT    = 443; #to allow testing to override
+our $VERSION = '3.00_01';
+our $URI     = 'http://dev.voipinnovations.com/VOIP/Services/APIService.asmx';
+our $NS      = 'http://tempuri.org'; #nice one
 
 our $AUTOLOAD;
 our $errstr = '';
 
 =head1 SYNOPSIS
 
-    use Net::VoIP_Innovations;
+    use Net::VoIP_Innovations 3;
 
     my $handle = Net::VoIP_Innovations->new(
         'login'    => 'tofu',
@@ -42,6 +38,9 @@ our $errstr = '';
     #releaseDID
 
     #911 Functions
+    #insert911
+    #update911
+    #remove911
 
     #Locator Functions
 
@@ -58,9 +57,9 @@ as a hash reference or a flat list of names and values.
 
 =item login (required)
 
-=item password (required)
+=item password (secret) (required)
 
-=item login (required)
+=item debug
 
 =back
 
@@ -101,7 +100,26 @@ sub AUTOLOAD {
   $AUTOLOAD =~ /(^|::)(\w+)$/ or die "unparsable AUTOLOAD: $AUTOLOAD";
   my $function = $2;
 
-  my $output;
+  $opts->{'login'}  ||= $self->{'login'};
+  $opts->{'secret'} ||= $self->{'password'};
+  my @soap_opts = map { SOAP::Data->name($_)->value( $opts->{$_} ) }
+                    keys %$opts;
+
+  my $result = SOAP::Lite
+                 ->proxy($URI)
+                 #->uri($NS)
+                 ->default_ns($NS)
+                 ->on_action( sub { join '/', @_ } )
+                 ->$function( @soap_opts )
+                 ->result();
+
+  #warn Dumper($result);
+
+}
+
+=cut 
+
+sub PROTOTYPE_AUTOLOAD {
   my $w = new XML::Writer(OUTPUT => \$output, DATA_MODE => 1, DATA_INDENT => 3);
 
   $w->xmlDecl('ISO-8859-1');
@@ -232,7 +250,7 @@ L<http://search.cpan.org/dist/Net-VoIP_Innovations>
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2008-2012 Freeside Internet Services, Inc. (http://freeside.biz/)
+Copyright 2014 Freeside Internet Services, Inc. (http://freeside.biz/)
 
 This program is free software; you can redistribute it and/or modify it
 under the same terms as Perl itself.
@@ -249,4 +267,4 @@ http://freeside.biz/freeside/
 
 =cut
 
-1; # End of Net::VoIP_Innovations
+1;