line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SMS::Send::Sendinblue; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
55210
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
42
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
389
|
use parent 'SMS::Send::Driver'; |
|
1
|
|
|
|
|
273
|
|
|
1
|
|
|
|
|
4
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
658
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
10
|
1
|
|
|
1
|
|
550
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
40185
|
|
|
1
|
|
|
|
|
30
|
|
11
|
1
|
|
|
1
|
|
7
|
use HTTP::Headers; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
12
|
1
|
|
|
1
|
|
586
|
use JSON; |
|
1
|
|
|
|
|
8407
|
|
|
1
|
|
|
|
|
4
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
SMS::Send::Sendinblue - SMS::Send driver for Sendinblue |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 VERSION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Version 0.02 |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $sender = SMS::Send->new('Sendinblue', |
30
|
|
|
|
|
|
|
_apikey => 'apikey', |
31
|
|
|
|
|
|
|
_sender => 'Sender', |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $sent = $sender->send_sms( |
35
|
|
|
|
|
|
|
text => 'Text message', |
36
|
|
|
|
|
|
|
to => '+61 (4) 1234 5678', |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 METHODS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 new |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $sender = SMS::Send->new('Sendinblue', |
46
|
|
|
|
|
|
|
_apikey => 'apikey', |
47
|
|
|
|
|
|
|
_sender => 'Sender', |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head3 Parameters |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=over |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item * C<_apikey> The API key can be retrieved from the Sendinblue account settings |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item * C<_sender> Name of the sender. Only alphanumeric characters. No more than 11 characters |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=back |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub new { |
63
|
0
|
|
|
0
|
1
|
|
my ($class, %params) = @_; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
foreach my $param (qw(_apikey _sender)) { |
66
|
0
|
0
|
|
|
|
|
unless (exists $params{$param}) { |
67
|
0
|
|
|
|
|
|
croak $class . "->new requires $param parameter"; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $self = \%params; |
72
|
0
|
|
|
|
|
|
bless $self, $class; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
return $self; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub send_sms { |
79
|
0
|
|
|
0
|
1
|
|
my ($self, %params) = @_; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my $request = HTTP::Request->new(POST => 'https://api.sendinblue.com/v3/transactionalSMS/sms'); |
82
|
0
|
|
|
|
|
|
$request->content_type('application/json'); |
83
|
0
|
|
|
|
|
|
$request->header(api_key => $self->{_apikey}); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $body = { |
86
|
|
|
|
|
|
|
sender => $self->{_sender}, |
87
|
|
|
|
|
|
|
recipient => $params{to}, |
88
|
|
|
|
|
|
|
content => $params{text}, |
89
|
0
|
|
|
|
|
|
type => 'transactional', |
90
|
|
|
|
|
|
|
}; |
91
|
0
|
|
|
|
|
|
$request->content(encode_json($body)); |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new(); |
94
|
0
|
|
|
|
|
|
my $response = $ua->request($request); |
95
|
|
|
|
|
|
|
|
96
|
0
|
0
|
|
|
|
|
if ($response->is_error) { |
97
|
0
|
|
|
|
|
|
warn "Failed to send SMS: " . $response->status_line; |
98
|
0
|
|
|
|
|
|
return 0; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
return 1; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 AUTHOR |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Julian Maurice, C<< >> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 BUGS |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
111
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
112
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SUPPORT |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
perldoc SMS::Send::Sendinblue |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
You can also look for information at: |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=over 4 |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
L |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
L |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item * CPAN Ratings |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * Search CPAN |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
L |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=back |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Copyright 2019 Julian Maurice. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
152
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
153
|
|
|
|
|
|
|
copy of the full license at: |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
158
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
159
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
160
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
163
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
164
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
167
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
170
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
171
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
172
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
173
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
174
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
175
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
176
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
179
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
180
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
181
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
182
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
183
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
184
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
185
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
1; # End of SMS::Send::Sendinblue |