1 package Net::VoIP_Innovations;
7 #SOAP::Lite->import(+trace=>'debug');
11 Net::VoIP_Innovations - Interface to VoIP_Innovations API
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
24 use Net::VoIP_Innovations 3;
26 my $handle = Net::VoIP_Innovations->new(
28 'password' => 'beast',
51 =head2 new HASHREF | OPTION, VALUE ...
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.
58 =item login (required)
60 =item password (secret) (required)
68 # If there is an error,
69 #returns false and sets an error string which may be queried with the I<errstr>
74 my $class = ref($proto) || $proto;
75 my $self = ref($_[0]) ? shift : { @_ };
76 $self->{'debug'} ||= 0;
88 unless ref($class) && $class->isa('Net::VoIP_Innovations');
94 sub DESTROY { }; # no-op
98 my $opts = ref($_[0]) ? shift : { @_ };
100 $AUTOLOAD =~ /(^|::)(\w+)$/ or die "unparsable AUTOLOAD: $AUTOLOAD";
103 $opts->{'login'} ||= $self->{'login'};
104 $opts->{'secret'} ||= $self->{'password'};
105 my @soap_opts = map { SOAP::Data->name($_)->value( $opts->{$_} ) }
108 my $result = SOAP::Lite
112 ->on_action( sub { join '/', @_ } )
113 ->$function( @soap_opts )
116 #warn Dumper($result);
122 sub PROTOTYPE_AUTOLOAD {
123 my $w = new XML::Writer(OUTPUT => \$output, DATA_MODE => 1, DATA_INDENT => 3);
125 $w->xmlDecl('ISO-8859-1');
126 $w->doctype('request', undef, $URL);
128 $w->startTag('request', 'id' => ''); #XXX request ID???
129 $w->startTag('header');
130 $w->startTag('sender');
132 if ( $self->{'sessionid'} ) {
134 #$w->dataElement( 'login' => '' );
135 #$w->dataElement( 'password' => '' );
136 $w->dataElement( 'sessionid' => $self->{'sessionid'} );
140 $w->dataElement( 'login' => $self->{'login'} );
141 $w->dataElement( 'password' => $self->{'password'} );
142 #$w->dataElement( 'sessionid' => '' );
146 $w->endTag('sender');
147 $w->endTag('header');
149 $w->startTag('body');
151 $w->dataElement( 'requesttype' => $function );
154 $w->startTag('item');
155 foreach my $opt ( keys %$opts ) {
156 $w->dataElement( $opt => $opts->{$opt} );
163 $w->endTag('request');
165 #$output =~ s/\n+/\n/g;
167 warn "XML Request for $function function:\n$output"
168 if $self->{'debug'} > 1;
170 my( $page, $response, %reply_headers ) = https_post(
173 'path' => ($PATH||443),
174 'args' => { 'apidata' => $output, },
175 #'content' => $output,
176 #'Content-Type' => 'text/plain',
177 #'Content-Type' => 'text/xml',
178 'Content-Type' => 'application/xml',
180 'debug' => ( $self->{'debug'} > 1 ? 1 : 0 ),
183 unless ( $response =~ /^200/i ) {
184 $self->{'errstr'} = $response;
188 warn "XML Response for $function function:\n: $page"
189 if $self->{'debug'} > 1;
191 my $hashref = XMLin( $page );
193 warn "Parsed response for $function funtion:\n". Dumper($hashref)
194 if $self->{'debug'} > 1;
196 my $return = $hashref->{'body'};
198 warn "Returning data:\n". Dumper($return)
199 if $self->{'debug'} > 1;
207 Ivan Kohler, C<< <ivan-net-voipinnovations at freeside.biz> >>
211 Please report any bugs or feature requests to C<bug-net-voip_innovations at rt.cpan.org>, or through
212 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-VoIP_Innovations>. I will be notified, and then you'll
213 automatically be notified of progress on your bug as I make changes.
220 You can find documentation for this module with the perldoc command.
222 perldoc Net::VoIP_Innovations
225 You can also look for information at:
229 =item * RT: CPAN's request tracker
231 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-VoIP_Innovations>
233 =item * AnnoCPAN: Annotated CPAN documentation
235 L<http://annocpan.org/dist/Net-VoIP_Innovations>
239 L<http://cpanratings.perl.org/d/Net-VoIP_Innovations>
243 L<http://search.cpan.org/dist/Net-VoIP_Innovations>
248 =head1 ACKNOWLEDGEMENTS
251 =head1 COPYRIGHT & LICENSE
253 Copyright 2014 Freeside Internet Services, Inc. (http://freeside.biz/)
255 This program is free software; you can redistribute it and/or modify it
256 under the same terms as Perl itself.
261 Need a complete, open-source back-office and customer self-service solution?
262 The Freeside software includes support for VoIP Innovations integration, CDR
263 rating, invoicing, credit card and electronic check processing, integrated
264 trouble ticketing, and customer signup and self-service web interfaces.
266 http://freeside.biz/freeside/