initial version appears to be hooked up and working against dev sandbox
[Net-VoIP_Innovations.git] / lib / Net / VoIP_Innovations.pm
1 package Net::VoIP_Innovations;
2
3 use warnings;
4 use strict;
5 use Data::Dumper;
6 use SOAP::Lite;
7 #SOAP::Lite->import(+trace=>'debug');
8
9 =head1 NAME
10
11 Net::VoIP_Innovations - Interface to VoIP_Innovations API
12
13 =cut
14
15 our $VERSION = '3.00_01';
16 our $URI     = 'http://dev.voipinnovations.com/VOIP/Services/APIService.asmx';
17 our $NS      = 'http://tempuri.org'; #nice one
18
19 our $AUTOLOAD;
20 our $errstr = '';
21
22 =head1 SYNOPSIS
23
24     use Net::VoIP_Innovations 3;
25
26     my $handle = Net::VoIP_Innovations->new(
27         'login'    => 'tofu',
28         'password' => 'beast',
29         'debug'    => 1,
30     );
31
32     #DID functions
33     #auditDIDs
34     #queryDID
35     #reserveDID
36     #assignDID
37     #configDID
38     #releaseDID
39
40     #911 Functions
41     #insert911
42     #update911
43     #remove911
44
45     #Locator Functions
46
47     ...
48
49 =head1 METHODS
50
51 =head2 new HASHREF | OPTION, VALUE ...
52
53 Creates a new Net::VoIP_Innovations object.  Options may be passed
54 as a hash reference or a flat list of names and values.
55
56 =over 4
57
58 =item login (required)
59
60 =item password (secret) (required)
61
62 =item debug
63
64 =back
65
66 =cut
67
68 #  If there is an error,
69 #returns false and sets an error string which may be queried with the I<errstr>
70 #class method.
71
72 sub new {
73   my $proto = shift;
74   my $class = ref($proto) || $proto;
75   my $self = ref($_[0]) ? shift : { @_ };
76   $self->{'debug'} ||= 0;
77   bless($self, $class);
78 }
79
80 =head2 errstr
81
82 =cut
83
84 sub errstr {
85   my $class = shift;
86
87   return $errstr
88     unless ref($class) && $class->isa('Net::VoIP_Innovations');
89
90   my $self = $class;
91   $self->{errstr};
92 }
93
94 sub DESTROY { }; # no-op
95
96 sub AUTOLOAD {
97   my $self = shift;
98   my $opts = ref($_[0]) ? shift : { @_ };
99
100   $AUTOLOAD =~ /(^|::)(\w+)$/ or die "unparsable AUTOLOAD: $AUTOLOAD";
101   my $function = $2;
102
103   $opts->{'login'}  ||= $self->{'login'};
104   $opts->{'secret'} ||= $self->{'password'};
105   my @soap_opts = map { SOAP::Data->name($_)->value( $opts->{$_} ) }
106                     keys %$opts;
107
108   SOAP::Lite
109     ->proxy($URI)
110     #->uri($NS)
111     ->default_ns($NS)
112     ->on_action( sub { join '/', @_ } )
113     ->$function( @soap_opts )
114     ->result();
115
116 }
117
118 =head1 AUTHOR
119
120 Ivan Kohler, C<< <ivan-net-voipinnovations at freeside.biz> >>
121
122 =head1 BUGS
123
124 Please report any bugs or feature requests to C<bug-net-voip_innovations at rt.cpan.org>, or through
125 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-VoIP_Innovations>.  I will be notified, and then you'll
126 automatically be notified of progress on your bug as I make changes.
127
128
129
130
131 =head1 SUPPORT
132
133 You can find documentation for this module with the perldoc command.
134
135     perldoc Net::VoIP_Innovations
136
137
138 You can also look for information at:
139
140 =over 4
141
142 =item * RT: CPAN's request tracker
143
144 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-VoIP_Innovations>
145
146 =item * AnnoCPAN: Annotated CPAN documentation
147
148 L<http://annocpan.org/dist/Net-VoIP_Innovations>
149
150 =item * CPAN Ratings
151
152 L<http://cpanratings.perl.org/d/Net-VoIP_Innovations>
153
154 =item * Search CPAN
155
156 L<http://search.cpan.org/dist/Net-VoIP_Innovations>
157
158 =back
159
160
161 =head1 ACKNOWLEDGEMENTS
162
163
164 =head1 COPYRIGHT & LICENSE
165
166 Copyright 2008-2014 Freeside Internet Services, Inc. (http://freeside.biz/)
167
168 This program is free software; you can redistribute it and/or modify it
169 under the same terms as Perl itself.
170
171
172 =head1 ADVERTISEMENT
173
174 Need a complete, open-source back-office and customer self-service solution?
175 The Freeside software includes support for VoIP Innovations integration, CDR
176 rating, invoicing, credit card and electronic check processing, integrated
177 trouble ticketing, and customer signup and self-service web interfaces.
178
179 http://freeside.biz/freeside/
180
181 =cut
182
183 1;