| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::Mocean; |
|
2
|
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
682757
|
use namespace::clean; |
|
|
11
|
|
|
|
|
172167
|
|
|
|
11
|
|
|
|
|
101
|
|
|
4
|
11
|
|
|
11
|
|
7718
|
use strictures 2; |
|
|
11
|
|
|
|
|
17729
|
|
|
|
11
|
|
|
|
|
448
|
|
|
5
|
11
|
|
|
11
|
|
2071
|
use utf8; |
|
|
11
|
|
|
|
|
23
|
|
|
|
11
|
|
|
|
|
76
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
333
|
use Module::Runtime qw(require_module); |
|
|
11
|
|
|
|
|
24
|
|
|
|
11
|
|
|
|
|
76
|
|
|
8
|
11
|
|
|
11
|
|
6400
|
use Moo; |
|
|
11
|
|
|
|
|
75926
|
|
|
|
11
|
|
|
|
|
52
|
|
|
9
|
11
|
|
|
11
|
|
21665
|
use Types::Standard qw(Str InstanceOf); |
|
|
11
|
|
|
|
|
817041
|
|
|
|
11
|
|
|
|
|
119
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
11
|
|
|
11
|
|
15303
|
use WebService::Mocean::Client; |
|
|
11
|
|
|
|
|
45
|
|
|
|
11
|
|
|
|
|
4459
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has api_key => ( |
|
16
|
|
|
|
|
|
|
isa => Str, |
|
17
|
|
|
|
|
|
|
is => 'rw', |
|
18
|
|
|
|
|
|
|
required => 1, |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has api_secret => ( |
|
22
|
|
|
|
|
|
|
isa => Str, |
|
23
|
|
|
|
|
|
|
is => 'rw', |
|
24
|
|
|
|
|
|
|
required => 1, |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has api_url => ( |
|
28
|
|
|
|
|
|
|
isa => Str, |
|
29
|
|
|
|
|
|
|
is => 'rw', |
|
30
|
|
|
|
|
|
|
default => sub { 'https://rest.moceanapi.com/rest/1' }, |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has client => ( |
|
34
|
|
|
|
|
|
|
is => 'lazy', |
|
35
|
|
|
|
|
|
|
isa => InstanceOf['WebService::Mocean::Client'], |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _build_client { |
|
39
|
2
|
|
|
2
|
|
115
|
my $self = shift; |
|
40
|
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
37
|
my $client = WebService::Mocean::Client->new( |
|
42
|
|
|
|
|
|
|
api_key => $self->api_key, |
|
43
|
|
|
|
|
|
|
api_secret => $self->api_secret, |
|
44
|
|
|
|
|
|
|
api_url => $self->api_url, |
|
45
|
|
|
|
|
|
|
); |
|
46
|
|
|
|
|
|
|
|
|
47
|
2
|
|
|
|
|
37
|
return $client; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has sms => ( |
|
51
|
|
|
|
|
|
|
is => 'lazy', |
|
52
|
|
|
|
|
|
|
default => sub { _delegate(shift, 'Sms') }, |
|
53
|
|
|
|
|
|
|
); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
has account => ( |
|
56
|
|
|
|
|
|
|
is => 'lazy', |
|
57
|
|
|
|
|
|
|
default => sub { _delegate(shift, 'Account') }, |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
has report => ( |
|
61
|
|
|
|
|
|
|
is => 'lazy', |
|
62
|
|
|
|
|
|
|
default => sub { _delegate(shift, 'Report') }, |
|
63
|
|
|
|
|
|
|
); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _delegate { |
|
66
|
0
|
|
|
0
|
|
|
my ($self, $module) = @_; |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my $package = __PACKAGE__ . "::$module"; |
|
69
|
0
|
|
|
|
|
|
require_module $package; |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return $package->new(client => $self->client); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
|
75
|
|
|
|
|
|
|
__END__ |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=encoding utf-8 |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=for stopwords mocean sms moceansms |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 NAME |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
WebService::Mocean - Perl library for integration with MoceanSMS gateway, |
|
84
|
|
|
|
|
|
|
https://moceanapi.com. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
use WebService::Mocean; |
|
89
|
|
|
|
|
|
|
my $mocean_api = WebService::Mocean->new(api_key => 'foo', api_secret => 'bar'); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
WebService::Mocean is Perl library for integrating with MoceanSMS gateway, |
|
94
|
|
|
|
|
|
|
https://moceanapi.com. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 DEVELOPMENT |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Source repository at L<https://github.com/kianmeng/webservice-mocean|https://github.com/kianmeng/webservice-mocean>. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
How to contribute? Follow through the L<CONTRIBUTING.md|https://github.com/kianmeng/webservice-mocean/blob/master/CONTRIBUTING.md> document to setup your development environment. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 METHODS |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 new($api_key, $api_secret, [%$args]) |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Construct a new WebService::Mocean instance. The api_key and api_secret is |
|
107
|
|
|
|
|
|
|
compulsory fields. Optionally takes additional hash or hash reference. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# Instantiate the class. |
|
110
|
|
|
|
|
|
|
my $mocean_api = WebService::Mocean->new(api_key => 'foo', api_secret => 'bar'); |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# Alternative way. |
|
113
|
|
|
|
|
|
|
my $mocean_api = WebService::Mocean->new({api_key => 'foo', api_secret => 'bar'}); |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head3 api_url |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
The URL of the API resource. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# Instantiate the class by setting the URL of the API endpoints. |
|
120
|
|
|
|
|
|
|
my $mocean_api = WebService::Mocean->new({api_url => 'http://example.com/api/'}); |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# Alternative way. |
|
123
|
|
|
|
|
|
|
my $mocean_api = WebService::Mocean->new(api_key => 'foo', api_secret => 'bar'); |
|
124
|
|
|
|
|
|
|
$mocean_api->api_url('http://example.com/api/'); |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 sms->send($params) |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Send Mobile Terminated (MT) message, which means the message is sent from |
|
129
|
|
|
|
|
|
|
mobile SMS provider and terminated at the to the mobile phone. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# Send sample SMS. |
|
132
|
|
|
|
|
|
|
my $response = $mocean_api->sms->send({ |
|
133
|
|
|
|
|
|
|
'mocean-to' => '0123456789', |
|
134
|
|
|
|
|
|
|
'mocean-from' => 'ACME Ltd.', |
|
135
|
|
|
|
|
|
|
'mocean-text' => 'Hello' |
|
136
|
|
|
|
|
|
|
}); |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 sms->send_verification_code($params) |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Send a random code for verification to a mobile number. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
my $response = $mocean_api->sms->send_verification_code({ |
|
143
|
|
|
|
|
|
|
'mocean-to' => '0123456789', |
|
144
|
|
|
|
|
|
|
'mocean-brand' => 'ACME Ltd.', |
|
145
|
|
|
|
|
|
|
}); |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 sms->check_verification_code($params) |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Check the verification code received from your user. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
my $response = $mocean_api->sms->check_verification_code({ |
|
152
|
|
|
|
|
|
|
'mocean-reqid' => '395935', |
|
153
|
|
|
|
|
|
|
'mocean-code' => '234839', |
|
154
|
|
|
|
|
|
|
}); |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 account->get_balance() |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Get your Mocean account balance. |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
my $response = $mocean_api->account->get_balance(); |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 account->get_pricing() |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Get your Mocean account pricing and supported destination. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
my $response = $mocean_api->account->get_pricing(); |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 report->get_message_status($params) |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Get the outbound SMS current status. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
my $response = $mocean_api->report->get_message_status({ |
|
173
|
|
|
|
|
|
|
'mocean-msgid' => 123456 |
|
174
|
|
|
|
|
|
|
}); |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 AUTHOR |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Kian Meng, Ang E<lt>kianmeng@cpan.orgE<gt> |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
This software is Copyright (c) 2018-2019 by Kian Meng, Ang. |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
This is free software, licensed under: |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |