line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Nexmo::SMS::Response::Message; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
39
|
use strict; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
155
|
|
4
|
8
|
|
|
8
|
|
91
|
use warnings; |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
356
|
|
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
|
|
45
|
no strict 'refs'; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
2019
|
|
18
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . $attr } = sub { |
19
|
92
|
|
|
92
|
|
2563
|
my ($self,$value) = @_; |
20
|
|
|
|
|
|
|
|
21
|
92
|
|
|
|
|
137
|
my $key = '__' . $attr . '__'; |
22
|
92
|
100
|
|
|
|
211
|
$self->{$key} = $value if @_ == 2; |
23
|
92
|
|
|
|
|
240
|
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
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub new { |
45
|
6
|
|
|
6
|
1
|
30
|
my ($class,%param) = @_; |
46
|
|
|
|
|
|
|
|
47
|
6
|
|
|
|
|
13
|
my $self = bless {}, $class; |
48
|
|
|
|
|
|
|
|
49
|
6
|
|
|
|
|
17
|
for my $attr ( @attrs ) { |
50
|
48
|
|
|
|
|
66
|
(my $key = $attr) =~ tr/_/-/; |
51
|
48
|
|
|
|
|
119
|
$self->$attr( $param{$key} ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
6
|
|
|
|
|
28
|
my $status = $param{status}; |
55
|
|
|
|
|
|
|
|
56
|
6
|
50
|
|
|
|
25
|
if ( exists $status_map{$status} ) { |
57
|
6
|
|
|
|
|
12
|
my $info = $status_map{$status}; |
58
|
6
|
|
|
|
|
19
|
$self->status_text( $info->[0] ); |
59
|
6
|
|
|
|
|
13
|
$self->status_desc( $info->[1] ); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
6
|
|
|
|
|
31
|
return $self; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |