SMS-OVH

SMS::OVH - Send SMS using OVH API (https://api.ovh.com/)
git clone https://git.e1e0.net/SMS-OVH.git
Log | Files | Refs | README

commit e74b39654e7998a7cac04aca873831b4b8632b61
Author: Paco Esteban <paco@onna.be>
Date:   Fri,  4 Sep 2015 18:59:57 +0200

first commit

Diffstat:
AChanges | 5+++++
AMANIFEST | 9+++++++++
AMakefile.PL | 27+++++++++++++++++++++++++++
AREADME | 75+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alib/SMS/OVH.pm | 184+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
At/00-load.t | 13+++++++++++++
At/manifest.t | 15+++++++++++++++
At/pod-coverage.t | 24++++++++++++++++++++++++
At/pod.t | 16++++++++++++++++
Axt/boilerplate.t | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10 files changed, 425 insertions(+), 0 deletions(-)

diff --git a/Changes b/Changes @@ -0,0 +1,5 @@ +Revision history for SMS-OVH + +0.01 Date/time + First version, released on an unsuspecting world. + diff --git a/MANIFEST b/MANIFEST @@ -0,0 +1,9 @@ +Changes +lib/SMS/OVH.pm +Makefile.PL +MANIFEST This list of files +README +t/00-load.t +t/manifest.t +t/pod-coverage.t +t/pod.t diff --git a/Makefile.PL b/Makefile.PL @@ -0,0 +1,27 @@ +use 5.006; +use strict; +use warnings; +use ExtUtils::MakeMaker; + +WriteMakefile( + NAME => 'SMS::OVH', + AUTHOR => q{Paco Esteban <paco@onna.be>}, + VERSION_FROM => 'lib/SMS/OVH.pm', + ABSTRACT_FROM => 'lib/SMS/OVH.pm', + LICENSE => 'bsd', + PL_FILES => {}, + MIN_PERL_VERSION => 5.006, + CONFIGURE_REQUIRES => { + 'ExtUtils::MakeMaker' => 0, + }, + BUILD_REQUIRES => { + 'Test::More' => 0, + }, + PREREQ_PM => { + 'OvhApi' => 0, + 'Moose' => 0, + 'namespace::clean' => 0 + }, + dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, + clean => { FILES => 'SMS-OVH-*' }, +); diff --git a/README b/README @@ -0,0 +1,75 @@ +SMS-OVH + +Send SMS using OVH API (https://api.ovh.com/) + +This is just a little module that use OvhApi.pm to send SMS using the french provider API. +You'll need the OvhApi.pm module provided by OVH at: + +https://eu.api.ovh.com/wrappers/OvhApi-perl-1.1.zip + +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 SMS::OVH + +You can also look for information at: + + RT, CPAN's request tracker (report bugs here) + http://rt.cpan.org/NoAuth/Bugs.html?Dist=SMS-OVH + + AnnoCPAN, Annotated CPAN documentation + http://annocpan.org/dist/SMS-OVH + + CPAN Ratings + http://cpanratings.perl.org/d/SMS-OVH + + Search CPAN + http://search.cpan.org/dist/SMS-OVH/ + + +LICENSE AND COPYRIGHT + +Copyright (C) 2015 Paco Esteban + +This program is distributed under the (Revised) BSD License: +L<http://www.opensource.org/licenses/BSD-3-Clause> + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +* Neither the name of Paco Esteban's Organization +nor the names of its contributors may be used to endorse or promote +products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/lib/SMS/OVH.pm b/lib/SMS/OVH.pm @@ -0,0 +1,184 @@ +package SMS::OVH; + +use 5.006; +use strict; +use warnings; + +use OvhApi; +use Moose; +use namespace::autoclean; + +has [qw( app_key app_secret cons_key serviceName sender )] => ( + isa => 'Str', + is => 'ro', + required => 1 +); + +has 'receivers' => ( + is => 'rw', + isa => 'ArrayRef' +); + +has 'message' => ( + isa => 'Str', + is => 'rw', + required => 1, + lazy => 1 +); + +has '_api' => ( + is => 'ro', + lazy => 1, + default => sub { + my $self = shift; + my $api = OvhApi->new( + type => OvhApi::OVH_API_EU, + applicationKey => $self->app_key, + applicationSecret => $self->app_secret, + consumerKey => $self->cons_key + ); + return $api; + } +); + +=head1 NAME + +SMS::OVH - Send SMS using OVH API (https://api.ovh.com/) + +=head1 VERSION + +Version 0.01 + +=cut + +our $VERSION = '0.01'; + + +=head1 SYNOPSIS + +This is just a little module that use OvhApi.pm to send SMS using the french provider API. +You'll need the OvhApi.pm module provided by OVH at: + +https://eu.api.ovh.com/wrappers/OvhApi-perl-1.1.zip + + use Ovh::SMS; + + my $sms = Ovh::SMS->new( + app_key => 'your-key', + app_secret => 'your-secret', + cons_key => 'your-cons-key', + serviceName => 'a-service-name', + sender => 'a-sender-name', + receiver => ['+33123123123'], + message => 'This is a test text message.' + ); + + $sms->send(); + +=head1 METHODS + +=head2 send + +=cut + +sub send { + my $self = shift; + my $url = "/sms/" . $self->serviceName . "/jobs"; + my %body = ( + message => $self->message, + sender => $self->sender, + noStopClause => 'true', + receivers => $self->receivers + ); + return $self->_api->rawCall( + path => $url, + method => 'post', + body => \%body + ); +} + +=head1 AUTHOR + +Paco Esteban, C<< <paco at onna.be> >> + +=head1 BUGS + +Please report any bugs or feature requests to C<bug-sms-ovh at rt.cpan.org>, or through +the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SMS-OVH>. 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 SMS::OVH + + +You can also look for information at: + +=over 4 + +=item * RT: CPAN's request tracker (report bugs here) + +L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=SMS-OVH> + +=item * AnnoCPAN: Annotated CPAN documentation + +L<http://annocpan.org/dist/SMS-OVH> + +=item * CPAN Ratings + +L<http://cpanratings.perl.org/d/SMS-OVH> + +=item * Search CPAN + +L<http://search.cpan.org/dist/SMS-OVH/> + +=back + + +=head1 ACKNOWLEDGEMENTS + + +=head1 LICENSE AND COPYRIGHT + +Copyright 2015 Paco Esteban. + +This program is distributed under the (Revised) BSD License: +L<http://www.opensource.org/licenses/BSD-3-Clause> + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +* Neither the name of Paco Esteban's Organization +nor the names of its contributors may be used to endorse or promote +products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +=cut + +1; # End of SMS::OVH diff --git a/t/00-load.t b/t/00-load.t @@ -0,0 +1,13 @@ +#!perl -T +use 5.006; +use strict; +use warnings; +use Test::More; + +plan tests => 1; + +BEGIN { + use_ok( 'SMS::OVH' ) || print "Bail out!\n"; +} + +diag( "Testing SMS::OVH $SMS::OVH::VERSION, Perl $], $^X" ); diff --git a/t/manifest.t b/t/manifest.t @@ -0,0 +1,15 @@ +#!perl -T +use 5.006; +use strict; +use warnings; +use Test::More; + +unless ( $ENV{RELEASE_TESTING} ) { + plan( skip_all => "Author tests not required for installation" ); +} + +my $min_tcm = 0.9; +eval "use Test::CheckManifest $min_tcm"; +plan skip_all => "Test::CheckManifest $min_tcm required" if $@; + +ok_manifest(); diff --git a/t/pod-coverage.t b/t/pod-coverage.t @@ -0,0 +1,24 @@ +#!perl -T +use 5.006; +use strict; +use warnings; +use Test::More; + +unless ( $ENV{RELEASE_TESTING} ) { + plan( skip_all => "Author tests not required for installation" ); +} + +# 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 @@ -0,0 +1,16 @@ +#!perl -T +use 5.006; +use strict; +use warnings; +use Test::More; + +unless ( $ENV{RELEASE_TESTING} ) { + plan( skip_all => "Author tests not required for installation" ); +} + +# 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(); diff --git a/xt/boilerplate.t b/xt/boilerplate.t @@ -0,0 +1,57 @@ +#!perl -T +use 5.006; +use strict; +use warnings; +use Test::More; + +plan 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/SMS/OVH.pm'); + + +} +