| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Nexmo::SMS::Response::Message; |
|
2
|
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
32
|
use strict; |
|
|
8
|
|
|
|
|
6
|
|
|
|
8
|
|
|
|
|
224
|
|
|
4
|
8
|
|
|
8
|
|
29
|
use warnings; |
|
|
8
|
|
|
|
|
8
|
|
|
|
8
|
|
|
|
|
462
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Module that represents a single message in the response from Nexmo SMS API! |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# create getter/setter |
|
11
|
|
|
|
|
|
|
my @attrs = qw( |
|
12
|
|
|
|
|
|
|
error_text status message_id client_ref remaining_balance |
|
13
|
|
|
|
|
|
|
message_price status_text status_desc |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
for my $attr ( @attrs ) { |
|
17
|
8
|
|
|
8
|
|
36
|
no strict 'refs'; |
|
|
8
|
|
|
|
|
9
|
|
|
|
8
|
|
|
|
|
2110
|
|
|
18
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . $attr } = sub { |
|
19
|
92
|
|
|
92
|
|
8420
|
my ($self,$value) = @_; |
|
20
|
|
|
|
|
|
|
|
|
21
|
92
|
|
|
|
|
161
|
my $key = '__' . $attr . '__'; |
|
22
|
92
|
100
|
|
|
|
506
|
$self->{$key} = $value if @_ == 2; |
|
23
|
92
|
|
|
|
|
300
|
return $self->{$key}; |
|
24
|
|
|
|
|
|
|
}; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my %status_map = ( |
|
28
|
|
|
|
|
|
|
0 => [ 'Success', 'The message was successfully accepted for delivery by nexmo' ], |
|
29
|
|
|
|
|
|
|
1 => [ 'Throttled', 'You have exceeded the submission capacity allowed on this account, please back-off and retry' ], |
|
30
|
|
|
|
|
|
|
2 => [ 'Missing params', 'Your request is incomplete and missing some mandatory parameters' ], |
|
31
|
|
|
|
|
|
|
3 => [ 'Invalid params', 'Thevalue of one or more parameters is invalid' ], |
|
32
|
|
|
|
|
|
|
4 => [ 'Invalid credentials', 'The username / password you supplied is either invalid or disabled' ], |
|
33
|
|
|
|
|
|
|
5 => [ 'Internal error', 'An error has occurred in the nexmo platform whilst processing this message' ], |
|
34
|
|
|
|
|
|
|
6 => [ 'Invalid message', 'The Nexmo platform was unable to process this message, for example, an un-recognized number prefix' ], |
|
35
|
|
|
|
|
|
|
7 => [ 'Number barred', 'The number you are trying to submit to is blacklisted and may not receive messages' ], |
|
36
|
|
|
|
|
|
|
8 => [ 'Partner account barred', 'The username you supplied is for an account that has been barred from submitting messages' ], |
|
37
|
|
|
|
|
|
|
9 => [ 'Partner quota exceeded', 'Your pre-pay account does not have sufficient credit to process this message' ], |
|
38
|
|
|
|
|
|
|
10 => [ 'Too many existing binds', 'The number of simultaneous connections to the platform exceeds the capabilities of your account' ], |
|
39
|
|
|
|
|
|
|
11 => [ 'Account not enabled for REST', 'This account is not provisioned for REST submission, you should use SMPP instead' ], |
|
40
|
|
|
|
|
|
|
12 => [ 'Message too long', 'Applies to Binary submissions, where the length of the UDF and the message body combined exceed 140 octets' ], |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This module represents a single message in a response from Nexmo. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
use Nexmo::SMS::Response::Message; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $nexmo = Nexmo::SMS::Response::Message->new( |
|
51
|
|
|
|
|
|
|
json => '{ |
|
52
|
|
|
|
|
|
|
"status":"4", |
|
53
|
|
|
|
|
|
|
"message-id":"message001", |
|
54
|
|
|
|
|
|
|
"client-ref":"Test001 - Reference", |
|
55
|
|
|
|
|
|
|
"remaining-balance":"20.0", |
|
56
|
|
|
|
|
|
|
"message-price":"0.05", |
|
57
|
|
|
|
|
|
|
"error-text":"" |
|
58
|
|
|
|
|
|
|
}', |
|
59
|
|
|
|
|
|
|
); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
print $nexmo->message_price; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 METHODS |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 new |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
create a new object |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $foo = Nexmo::SMS::Response::Message->new( |
|
70
|
|
|
|
|
|
|
json => ' |
|
71
|
|
|
|
|
|
|
{ |
|
72
|
|
|
|
|
|
|
"status":"4", |
|
73
|
|
|
|
|
|
|
"message-id":"message001", |
|
74
|
|
|
|
|
|
|
"client-ref":"Test001 - Reference", |
|
75
|
|
|
|
|
|
|
"remaining-balance":"20.0", |
|
76
|
|
|
|
|
|
|
"message-price":"0.05", |
|
77
|
|
|
|
|
|
|
"error-text":"" |
|
78
|
|
|
|
|
|
|
}', |
|
79
|
|
|
|
|
|
|
); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub new { |
|
84
|
6
|
|
|
6
|
1
|
31
|
my ($class,%param) = @_; |
|
85
|
|
|
|
|
|
|
|
|
86
|
6
|
|
|
|
|
21
|
my $self = bless {}, $class; |
|
87
|
|
|
|
|
|
|
|
|
88
|
6
|
|
|
|
|
20
|
for my $attr ( @attrs ) { |
|
89
|
48
|
|
|
|
|
79
|
(my $key = $attr) =~ tr/_/-/; |
|
90
|
48
|
|
|
|
|
151
|
$self->$attr( $param{$key} ); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
6
|
|
|
|
|
23
|
my $status = $param{status}; |
|
94
|
|
|
|
|
|
|
|
|
95
|
6
|
50
|
|
|
|
32
|
if ( exists $status_map{$status} ) { |
|
96
|
6
|
|
|
|
|
25
|
my $info = $status_map{$status}; |
|
97
|
6
|
|
|
|
|
24
|
$self->status_text( $info->[0] ); |
|
98
|
6
|
|
|
|
|
17
|
$self->status_desc( $info->[1] ); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
6
|
|
|
|
|
54
|
return $self; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
These attributes are available for C objects: |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
$nexmo->client_ref( 'client_ref' ); |
|
111
|
|
|
|
|
|
|
my $client_ref = $nexmo->client_ref; |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=over 4 |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * client_ref |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * error_text |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * message_price |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * remaining_balance |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * status_desc |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * status message_id |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item * status_text |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=back |
|
130
|
|
|
|
|
|
|
|