From 0bbc67fcb177d8ca6a70727438f3d3dcdffa3a8e Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 2 Mar 2009 08:56:54 +0000 Subject: [PATCH 1/1] initial import --- .cvsignore | 10 ++ Changes | 5 + MANIFEST | 8 ++ Makefile.PL | 16 +++ README | 53 ++++++++ lib/Net/Vitelity.pm | 342 ++++++++++++++++++++++++++++++++++++++++++++++++++++ t/00-load.t | 9 ++ t/boilerplate.t | 55 +++++++++ t/pod-coverage.t | 18 +++ t/pod.t | 12 ++ 10 files changed, 528 insertions(+) create mode 100644 .cvsignore create mode 100644 Changes create mode 100644 MANIFEST create mode 100644 Makefile.PL create mode 100644 README create mode 100644 lib/Net/Vitelity.pm create mode 100644 t/00-load.t create mode 100644 t/boilerplate.t create mode 100644 t/pod-coverage.t create mode 100644 t/pod.t diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 0000000..1039091 --- /dev/null +++ b/.cvsignore @@ -0,0 +1,10 @@ +blib* +Makefile +Makefile.old +Build +_build* +pm_to_blib* +*.tar.gz +.lwpcookies +Net-Vitelity-* +cover_db diff --git a/Changes b/Changes new file mode 100644 index 0000000..2fe70d8 --- /dev/null +++ b/Changes @@ -0,0 +1,5 @@ +Revision history for Net-Vitelity + +0.01 unreleased + First version, released on an unsuspecting world. + diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..7c6d4f9 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,8 @@ +Changes +MANIFEST +Makefile.PL +README +lib/Net/Vitelity.pm +t/00-load.t +t/pod-coverage.t +t/pod.t diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..acdbf96 --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,16 @@ +use strict; +use warnings; +use ExtUtils::MakeMaker; + +WriteMakefile( + NAME => 'Net::Vitelity', + AUTHOR => 'Ivan Kohler ', + VERSION_FROM => 'lib/Net/Vitelity.pm', + ABSTRACT_FROM => 'lib/Net/Vitelity.pm', + PL_FILES => {}, + PREREQ_PM => { + 'Test::More' => 0, + }, + dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, + clean => { FILES => 'Net-Vitelity-*' }, +); diff --git a/README b/README new file mode 100644 index 0000000..4e1f468 --- /dev/null +++ b/README @@ -0,0 +1,53 @@ +Net-Vitelity + +This is an interface to the Vitelity API for wholesale DID (phone number) +provisioning. It is only useful if you have an account with Vitelity +wholesale VoIP service. + +INSTALLATION + +To install this module, run the following commands: + + perl Makefile.PL + make + make test + make install + +SUPPORT AND DOCUMENTATION + +After installing, you can find documentation for this module with the +perldoc command. + + perldoc Net::Vitelity + +You can also look for information at: + + RT, CPAN's request tracker + http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Vitelity + + AnnoCPAN, Annotated CPAN documentation + http://annocpan.org/dist/Net-Vitelity + + CPAN Ratings + http://cpanratings.perl.org/d/Net-Vitelity + + Search CPAN + http://search.cpan.org/dist/Net-Vitelity + + +COPYRIGHT AND LICENCE + +Copyright (C) 2009 Freeside Internet Services, Inc. + +This program is free software; you can redistribute it and/or modify it +under the same terms as Perl itself. + +ADVERTISEMENT + +Need a complete, open-source back-office and customer self-service solution? +The Freeside software includes support for GlobalPOPs integration, CDR rating, +invoicing, credit card and electronic check processing, integrated trouble +ticketing, and customer signup and self-service web interfaces. + +http://freeside.biz/freeside/ + diff --git a/lib/Net/Vitelity.pm b/lib/Net/Vitelity.pm new file mode 100644 index 0000000..d0ef45e --- /dev/null +++ b/lib/Net/Vitelity.pm @@ -0,0 +1,342 @@ +package Net::Vitelity; + +use warnings; +use strict; + +=head1 NAME + +Net::Vitelity - Interface to Vitelity API + +=head1 VERSION + +Version 0.01 + +=cut + +our $VERSION = '0.01'; + +our $URL = 'http://70.84.157.157/api.php'; + +=head1 SYNOPSIS + + use Net::Vitelity; + + my $vitelity = Net::Vitelity->new( + 'login' => $your_login, + 'pass' => $your_pass, + ); + +=head1 METHODS + +=cut + +sub new { + #XXX need a generic new +} + +sub AUTOLOAD { + my $self = shift; + + $AUTOLOAD =~ /(^|::)(\w+)$/ or die "unparsable AUTOLOAD: $AUTOLOAD"; + my $cmd = $2; + return if $cmd eq 'DESTROY'; + + my $ua = LWP::UserAgent->new; + + #XXX md5 encrypt pass + + $ua->post($URL, { + login => $self->{login}, + pass => $self=>{pass} + cmd => $cmd, + @_, + } + ); + + die $response->status_line unless $response->is_success; + + #hmm + #my $content = $response->content; + my $content = $response->decoded_content; + + #dear vitelity api: why does this make it easier to parse? + $content =~ s/^x\[\[/; + $content =~ s/\[\[x$/; + + wantarray ? split("\n", $content) : $content; + +} + +=head2 listtollfree + +List ALL available toll free numbers + +Possible Results: none OR [list of tf numbers] + +=head2 callfromclick + +Sends someone a phone call that then connects them to customer service/another number. + +Options: number=number AND servicenumber=number + +Possible Results:OK or INVALID + +=head2 listlocal + +Lists ALL available local numbers in a specific state and ratecenter + +Requires: state=STATE + +Options: type=unlimited OR type=pri OR withrates=yes + ratecenter=RATECENTER + +Possible Results: unavailable or missing or [list of dids] + +=head2 gettollfree + +Orders a specific toll free number in our available list (SLOW) +Requires: did=TOLL-FREE-NUMBER +Options: routesip=route_to_this_subaccount +Possible Results: success or unavailable or missingdid + +=head2 getlocaldid + +Orders a specific local number from our available list + +Requires: did=AVAILABLE-LOCAL-NUMBER + +Options: type=perminute OR type=unlimited OR type=your-pri OR + routesip=route_to_this_subaccount + +Possible Results: invalid or success or missingdid + +=head2 removedid + +Remove Local or Toll Free DID from account + +Requires: did=AVAILABLE-LOCAL-NUMBER + +Possible Results: success OR unavailable OR missingdid + +=head2 listratecenters + +Lists all of the available rate centers for a specific state line by line + +Requires: state=STATE (ie, state=CO) + +Options: type=perminute OR type=unlimited OR type=pri + +Possible Results: unavailable OR missingdata OR [list of ratecenters] + +=head2 listavailratecenters + +Lists all available rate centers DIDs are currently in stock for a specific state line by line + +Requires: state=STATE (ie, state=CO) + +Options: type=unlimited OR type=pri + +Possible Results: missingdata OR unavailable or [list of ratecenters] + +=head2 requestvanity + +Orders a specific available toll free number from the SMS database. + +Requires: did=8009879891 (number can be any available number) + +Possible Results: missingdata OR exists OR success + +=head2 searchtoll + +Searches the SMS/800 database for an available number matching the specific data you provide + +Requires: did=8**333**** + +Possible Results: none OR missingdata OR [list of avail numbers] + +=head2 listavailstates + +Lists all states that have DIDs which are currently in stock + +Options: type=perminute OR type=unlimited OR type=pri + +Possible Results: unavailable OR [list of states] + +=head2 liststates + +Lists all available DID states line by line + +Options: type=perminute OR type=unlimited OR type=pri + +Possible Results: unavailable OR [list of states] + +=head2 cnam + +Lookup a specific caller id number for the name + +Requires: did=3037855015 (number) + +Possible Results: missingdata OR [cnam value] + +=head2 searchtoll + +Searches the SMS/800 database for an available number matching the specific data you provide + +Requires: did=8**333**** + +Possible Results: none OR missingdata OR [list of avail numbers] + +=head2 localbackorder + +Orders a specific local number from our available list + +Requires: ratecenter=RATECENTER and state=STATE + +Options: type=perminute OR type=unlimited + +Possible Results: invalid OR ok OR missing + +=head2 reroute + +Changes the sub account a DID rings to. + +Requires: did=DID_NUMBER & routesip=SIP_SUB_ACCOUNT + +Possible Results: missingdata OR ok OR invalid + +=head2 balance + +Reports back your current account balance + +=head2 listdids + +Lists all current Local and Toll free DIDs + +Options: extra=yes + +Results: number,ratecenter,price_per_minute,subaccount + +extra=yes adds STATE,MONTHLY_DID_RATE + +=head2 routeall + +Changes the routing on all dids to a specific sip account + +Requires: routesip=sub_account OR routesip=login (routes to main) + +Possible Results: ok OR invalid + +=head2 getrate + +Gets a rate on a specific domestic or International call + +Requires: number=[countrycode_thenumber] ex: 01144.. or 1303.. + +Results: invalid OR the_rate_per_minute + +=head2 subaccounts + +Lists sub accounts + +Requires: do=list + +Possible Results: subaccount list separated by return OR invalid + +=head1 All Possible Result Return Codes + +=over 4 + +=item success + +The request you made was successful + +=item missingdata + +You are missing login= or pass= or cmd= or other in your URL string + +=item invalidauth + +You have submitted an invalid login or password + +=item missingrc + +You are missing the ratecenter or state for a specific local did order + +=item unavailable + +The number you requested is not available + +=item none + +There are no numbers available + +=item missingdid + +you are missing &did=number + +=item list of data + +If you asked for a list of numbers and we had some available, they will be listed. + +In a list contect, all entries will be returned in a list. In a scalar +scalar context, entries will be separated by newlines. + +=head1 AUTHOR + +Ivan Kohler, C<< >> + +=head1 BUGS + +Please report any bugs or feature requests to C, or through +the web interface at L. I will be notified, and then you'll +automatically be notified of progress on your bug as I make changes. + +=head1 SUPPORT + +You can find documentation for this module with the perldoc command. + + perldoc Net::Vitelity + +You can also look for information at: + +=over 4 + +=item * RT: CPAN's request tracker + +L + +=item * AnnoCPAN: Annotated CPAN documentation + +L + +=item * CPAN Ratings + +L + +=item * Search CPAN + +L + +=back + +=head1 ACKNOWLEDGEMENTS + +This module was developed by Freeside Internet Services, Inc. +If you need a complete, open-source web-based application to manage your +customers, billing and trouble ticketing, please visit http://freeside.biz/ + +Development sponsored by Ring Carrier LLC. If you need a hosted or on-site +PBX, please visit http://www.ringcarrier.com/ + +=head1 COPYRIGHT & LICENSE + +Copyright 2009 Freeside Internet Services, Inc. +All rights reserved. + +This program is free software; you can redistribute it and/or modify it +under the same terms as Perl itself. + +=cut + +1; + diff --git a/t/00-load.t b/t/00-load.t new file mode 100644 index 0000000..770261a --- /dev/null +++ b/t/00-load.t @@ -0,0 +1,9 @@ +#!perl -T + +use Test::More tests => 1; + +BEGIN { + use_ok( 'Net::Vitelity' ); +} + +diag( "Testing Net::Vitelity $Net::Vitelity::VERSION, Perl $], $^X" ); diff --git a/t/boilerplate.t b/t/boilerplate.t new file mode 100644 index 0000000..0f429a0 --- /dev/null +++ b/t/boilerplate.t @@ -0,0 +1,55 @@ +#!perl -T + +use strict; +use warnings; +use Test::More tests => 3; + +sub not_in_file_ok { + my ($filename, %regex) = @_; + open( my $fh, '<', $filename ) + or die "couldn't open $filename for reading: $!"; + + my %violated; + + while (my $line = <$fh>) { + while (my ($desc, $regex) = each %regex) { + if ($line =~ $regex) { + push @{$violated{$desc}||=[]}, $.; + } + } + } + + if (%violated) { + fail("$filename contains boilerplate text"); + diag "$_ appears on lines @{$violated{$_}}" for keys %violated; + } else { + pass("$filename contains no boilerplate text"); + } +} + +sub module_boilerplate_ok { + my ($module) = @_; + not_in_file_ok($module => + 'the great new $MODULENAME' => qr/ - The great new /, + 'boilerplate description' => qr/Quick summary of what the module/, + 'stub function definition' => qr/function[12]/, + ); +} + +TODO: { + local $TODO = "Need to replace the boilerplate text"; + + not_in_file_ok(README => + "The README is used..." => qr/The README is used/, + "'version information here'" => qr/to provide version information/, + ); + + not_in_file_ok(Changes => + "placeholder date/time" => qr(Date/time) + ); + + module_boilerplate_ok('lib/Net/Vitelity.pm'); + + +} + diff --git a/t/pod-coverage.t b/t/pod-coverage.t new file mode 100644 index 0000000..fc40a57 --- /dev/null +++ b/t/pod-coverage.t @@ -0,0 +1,18 @@ +use strict; +use warnings; +use Test::More; + +# Ensure a recent version of Test::Pod::Coverage +my $min_tpc = 1.08; +eval "use Test::Pod::Coverage $min_tpc"; +plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage" + if $@; + +# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version, +# but older versions don't recognize some common documentation styles +my $min_pc = 0.18; +eval "use Pod::Coverage $min_pc"; +plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" + if $@; + +all_pod_coverage_ok(); diff --git a/t/pod.t b/t/pod.t new file mode 100644 index 0000000..ee8b18a --- /dev/null +++ b/t/pod.t @@ -0,0 +1,12 @@ +#!perl -T + +use strict; +use warnings; +use Test::More; + +# Ensure a recent version of Test::Pod +my $min_tp = 1.22; +eval "use Test::Pod $min_tp"; +plan skip_all => "Test::Pod $min_tp required for testing POD" if $@; + +all_pod_files_ok(); -- 2.11.0