| 1 | package SMS::OVH; | ||
| 2 | |||
| 3 | 1 | ▶ | use 5.006; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | ▶ | use OvhApi; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 1 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 1 | has [qw( app_key app_secret cons_key serviceName sender )] => ( | |
| 12 | isa => 'Str', | ||
| 13 | is => 'ro', | ||
| 14 | required => 1 | ||
| 15 | ); | ||
| 16 | |||
| 17 | has 'receivers' => ( | ||
| 18 | is => 'rw', | ||
| 19 | isa => 'ArrayRef', | ||
| 20 | required => 1, | ||
| 21 | lazy => 1, | ||
| 22 | 0 | ▶ | default => sub { [] } |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 23 | 1 | ); | |
| 24 | |||
| 25 | 1 | has 'message' => ( | |
| 26 | isa => 'Str', | ||
| 27 | is => 'rw', | ||
| 28 | required => 1, | ||
| 29 | lazy => 1, | ||
| 30 | default => '' | ||
| 31 | ); | ||
| 32 | |||
| 33 | has '_api' => ( | ||
| 34 | is => 'ro', | ||
| 35 | lazy => 1, | ||
| 36 | 0 | ▶ | default => sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 37 | 0 | my $self = shift; | |
| 38 | 0 | my $api = OvhApi->new( | |
| 39 | type => OvhApi::OVH_API_EU, | ||
| 40 | applicationKey => $self->app_key, | ||
| 41 | applicationSecret => $self->app_secret, | ||
| 42 | consumerKey => $self->cons_key | ||
| 43 | ); | ||
| 44 | 0 | return $api; | |
| 45 | } | ||
| 46 | 1 | ); | |
| 47 | |||
| 48 | =head1 NAME | ||
| 49 | |||
| 50 | SMS::OVH - Send SMS using OVH API (https://api.ovh.com/) | ||
| 51 | |||
| 52 | =head1 VERSION | ||
| 53 | |||
| 54 | Version 0.03 | ||
| 55 | |||
| 56 | =cut | ||
| 57 | |||
| 58 | 1 | our $VERSION = '0.03'; | |
| 59 | |||
| 60 | =head1 SYNOPSIS | ||
| 61 | |||
| 62 | This is just a little module that use OvhApi.pm to send SMS using the french provider API. | ||
| 63 | You'll need the OvhApi.pm module provided by OVH at: | ||
| 64 | |||
| 65 | https://eu.api.ovh.com/wrappers/OvhApi-perl-1.1.zip | ||
| 66 | |||
| 67 | OvhApi is not a CPAN modeula (yet), so you'll need to have it installed before install this module. | ||
| 68 | |||
| 69 | This module also depends on Moose (https://metacpan.org/pod/Moose) | ||
| 70 | |||
| 71 | use SMS::OVH; | ||
| 72 | |||
| 73 | my $sms = SMS::OVH->new( | ||
| 74 | app_key => 'your-key', | ||
| 75 | app_secret => 'your-secret', | ||
| 76 | cons_key => 'your-cons-key', | ||
| 77 | serviceName => 'a-service-name', | ||
| 78 | sender => 'a-sender-name', | ||
| 79 | receivers => ['+33123123123'], | ||
| 80 | message => 'This is a test text message.' | ||
| 81 | ); | ||
| 82 | |||
| 83 | $sms->send(); | ||
| 84 | |||
| 85 | =head1 METHODS | ||
| 86 | |||
| 87 | =head2 send | ||
| 88 | |||
| 89 | This is the only method. It just tries to complete the API request. | ||
| 90 | It takes no arguments, just uses the parameters set when the instance is created. | ||
| 91 | |||
| 92 | =cut | ||
| 93 | |||
| 94 | 0 | ▶ | sub send { |
|
Subroutine
send: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 95 | 0 | my $self = shift; | |
| 96 | 0 | my $url = "/sms/" . $self->serviceName . "/jobs"; | |
| 97 | 0 | my %body = ( | |
| 98 | message => $self->message, | ||
| 99 | sender => $self->sender, | ||
| 100 | noStopClause => 'true', | ||
| 101 | receivers => $self->receivers | ||
| 102 | ); | ||
| 103 | 0 | return $self->_api->rawCall( | |
| 104 | path => $url, | ||
| 105 | method => 'post', | ||
| 106 | body => \%body | ||
| 107 | ); | ||
| 108 | } | ||
| 109 | |||
| 110 | =head1 AUTHOR | ||
| 111 | |||
| 112 | Paco Esteban, C<< <paco at onna.be> >> | ||
| 113 | |||
| 114 | =head1 BUGS | ||
| 115 | |||
| 116 | Please report any bugs or feature requests to C<bug-sms-ovh at rt.cpan.org>, or through | ||
| 117 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SMS-OVH>. I will be notified, and then you'll | ||
| 118 | automatically be notified of progress on your bug as I make changes. | ||
| 119 | |||
| 120 | =head1 SUPPORT | ||
| 121 | |||
| 122 | You can find documentation for this module with the perldoc command. | ||
| 123 | |||
| 124 | perldoc SMS::OVH | ||
| 125 | |||
| 126 | |||
| 127 | You can also look for information at: | ||
| 128 | |||
| 129 | =over 4 | ||
| 130 | |||
| 131 | =item * RT: CPAN's request tracker (report bugs here) | ||
| 132 | |||
| 133 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=SMS-OVH> | ||
| 134 | |||
| 135 | =item * AnnoCPAN: Annotated CPAN documentation | ||
| 136 | |||
| 137 | L<http://annocpan.org/dist/SMS-OVH> | ||
| 138 | |||
| 139 | =item * CPAN Ratings | ||
| 140 | |||
| 141 | L<http://cpanratings.perl.org/d/SMS-OVH> | ||
| 142 | |||
| 143 | =item * Search CPAN | ||
| 144 | |||
| 145 | L<http://search.cpan.org/dist/SMS-OVH/> | ||
| 146 | |||
| 147 | =back | ||
| 148 | |||
| 149 | =head1 LICENSE AND COPYRIGHT | ||
| 150 | |||
| 151 | Copyright 2015 Paco Esteban. | ||
| 152 | and | ||
| 153 | Powerspace Advertising SL <http://powerspace.com/> | ||
| 154 | |||
| 155 | This program is distributed under the (Revised) BSD License: | ||
| 156 | L<http://www.opensource.org/licenses/BSD-3-Clause> | ||
| 157 | |||
| 158 | Redistribution and use in source and binary forms, with or without | ||
| 159 | modification, are permitted provided that the following conditions | ||
| 160 | are met: | ||
| 161 | |||
| 162 | * Redistributions of source code must retain the above copyright | ||
| 163 | notice, this list of conditions and the following disclaimer. | ||
| 164 | |||
| 165 | * Redistributions in binary form must reproduce the above copyright | ||
| 166 | notice, this list of conditions and the following disclaimer in the | ||
| 167 | documentation and/or other materials provided with the distribution. | ||
| 168 | |||
| 169 | * Neither the name of Paco Esteban's Organization | ||
| 170 | nor the names of its contributors may be used to endorse or promote | ||
| 171 | products derived from this software without specific prior written | ||
| 172 | permission. | ||
| 173 | |||
| 174 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 175 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 176 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| 177 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| 178 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 179 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| 180 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| 181 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| 182 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 183 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| 184 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 185 | |||
| 186 | |||
| 187 | =cut | ||
| 188 | |||
| 189 | 1 | 1; # End of SMS::OVH | |