| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::SMS::CDYNE; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
737
|
use 5.008_001; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
49
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
926
|
use Any::Moose; |
|
|
1
|
|
|
|
|
187905
|
|
|
|
1
|
|
|
|
|
6
|
|
|
7
|
1
|
|
|
1
|
|
991
|
use Any::Moose 'X::NonMoose'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
5
|
|
|
8
|
1
|
|
|
1
|
|
13654
|
use XML::Simple; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Carp qw/croak cluck/; |
|
10
|
|
|
|
|
|
|
use Net::SMS::CDYNE::Response; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
extends 'REST::Client'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'debug' => ( |
|
15
|
|
|
|
|
|
|
is => 'rw', |
|
16
|
|
|
|
|
|
|
isa => 'Bool', |
|
17
|
|
|
|
|
|
|
default => 0, |
|
18
|
|
|
|
|
|
|
); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'api_key' => ( |
|
21
|
|
|
|
|
|
|
is => 'rw', |
|
22
|
|
|
|
|
|
|
isa => 'Str', |
|
23
|
|
|
|
|
|
|
required => 1, |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub do_cdyne_request { |
|
27
|
|
|
|
|
|
|
my ($self, $method, $uri, $args, $body) = @_; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
croak "URI is required" unless $uri; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$args ||= {}; |
|
32
|
|
|
|
|
|
|
$args->{LicenseKey} ||= $self->api_key; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# build request |
|
35
|
|
|
|
|
|
|
my $headers = {}; |
|
36
|
|
|
|
|
|
|
my $args_encoded = $args && %$args ? $self->buildQuery($args) : ''; |
|
37
|
|
|
|
|
|
|
$args_encoded =~ s/^(\?)//; |
|
38
|
|
|
|
|
|
|
if (lc $method eq 'get') { |
|
39
|
|
|
|
|
|
|
$uri .= '?' . $args_encoded; |
|
40
|
|
|
|
|
|
|
} else { |
|
41
|
|
|
|
|
|
|
$headers->{'Content-Type'} = 'text/xml'; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
warn "Request: $uri\n" if $self->debug; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$self->request($method, $uri, $body, $headers); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $response_code = $self->responseCode; |
|
49
|
|
|
|
|
|
|
my $content = $self->responseContent; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
if (! $response_code || index($response_code, '2') != 0) { |
|
52
|
|
|
|
|
|
|
warn "CDYNEv2 request ($uri) failed with code $response_code: " . $content . |
|
53
|
|
|
|
|
|
|
"\n\nRequest body was: $body\n"; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# return empty response |
|
56
|
|
|
|
|
|
|
return Net::SMS::CDYNE::Response->new(response_code => $response_code); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
warn "\nResponse: $content\n" if $self->debug; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# attempt to parse response XML |
|
62
|
|
|
|
|
|
|
my $resp_obj = eval { XMLin($content) }; |
|
63
|
|
|
|
|
|
|
warn "Failed parsing response: $content ($@)" unless $resp_obj; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# if we do an advanced send, we get an array of responses. |
|
66
|
|
|
|
|
|
|
# since we only handle sending one message at a time, we can just grab the first response. |
|
67
|
|
|
|
|
|
|
$resp_obj = $resp_obj->{SMSResponse} if $resp_obj->{SMSResponse}; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $ret = { |
|
70
|
|
|
|
|
|
|
response_code => $response_code, |
|
71
|
|
|
|
|
|
|
%$resp_obj, |
|
72
|
|
|
|
|
|
|
}; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
return bless $ret, 'Net::SMS::CDYNE::Response'; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# takes a phone number, returns a structure of info |
|
78
|
|
|
|
|
|
|
sub phone_verify { |
|
79
|
|
|
|
|
|
|
my ($self, $phone_number) = @_; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $uri = 'http://ws.cdyne.com/phoneverify/phoneverify.asmx/CheckPhoneNumber'; |
|
82
|
|
|
|
|
|
|
return $self->do_cdyne_request('GET', $uri, { PhoneNumber => $phone_number }); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
# $ curl 'http://ws.cdyne.com/phoneverify/phoneverify.asmx/CheckPhoneNumber?PhoneNumber=17575449510&LicenseKey=XXXXX' |
|
85
|
|
|
|
|
|
|
# |
|
86
|
|
|
|
|
|
|
# |
|
87
|
|
|
|
|
|
|
# LEVEL 3 COMM - VA |
|
88
|
|
|
|
|
|
|
# true |
|
89
|
|
|
|
|
|
|
# |
|
90
|
|
|
|
|
|
|
# VA |
|
91
|
|
|
|
|
|
|
# NRFOLKZON2 |
|
92
|
|
|
|
|
|
|
# 8825 |
|
93
|
|
|
|
|
|
|
# 17575449510 |
|
94
|
|
|
|
|
|
|
# 7575449510 |
|
95
|
|
|
|
|
|
|
# CHSKVAAY0MD |
|
96
|
|
|
|
|
|
|
# |
|
97
|
|
|
|
|
|
|
# United States |
|
98
|
|
|
|
|
|
|
# CHSKVAAYDS0 |
|
99
|
|
|
|
|
|
|
# CLEC - (Competitive Local Exchange Carrier) |
|
100
|
|
|
|
|
|
|
# 252 |
|
101
|
|
|
|
|
|
|
# CLEC - (Competitive Local Exchange Carrier) |
|
102
|
|
|
|
|
|
|
# |
|
103
|
|
|
|
|
|
|
# 05/24/2001 |
|
104
|
|
|
|
|
|
|
# PARKSLEY |
|
105
|
|
|
|
|
|
|
# |
|
106
|
|
|
|
|
|
|
# VA |
|
107
|
|
|
|
|
|
|
# 23421 |
|
108
|
|
|
|
|
|
|
# EST |
|
109
|
|
|
|
|
|
|
# 37.7790 |
|
110
|
|
|
|
|
|
|
# -75.6343 |
|
111
|
|
|
|
|
|
|
# false |
|
112
|
|
|
|
|
|
|
# 7576559199 |
|
113
|
|
|
|
|
|
|
# |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub simple_sms_send_with_postback { |
|
116
|
|
|
|
|
|
|
my ($self, %args) = @_; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my $uri = 'https://sms2.cdyne.com/sms.svc/SecureREST/SimpleSMSsendWithPostback'; |
|
119
|
|
|
|
|
|
|
return $self->do_cdyne_request('GET', $uri, \%args); |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub simple_sms_send { |
|
123
|
|
|
|
|
|
|
my ($self, %args) = @_; |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
my $uri = 'https://sms2.cdyne.com/sms.svc/SecureREST/SimpleSMSsend'; |
|
126
|
|
|
|
|
|
|
return $self->do_cdyne_request('GET', $uri, \%args); |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# takes AssignedDID |
|
130
|
|
|
|
|
|
|
sub advanced_sms_send { |
|
131
|
|
|
|
|
|
|
my ($self, %args) = @_; |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
my $uri = 'https://sms2.cdyne.com/sms.svc/SecureREST/AdvancedSMSsend'; |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
$args{LicenseKey} ||= $self->api_key; |
|
136
|
|
|
|
|
|
|
my $num = delete $args{PhoneNumber}; |
|
137
|
|
|
|
|
|
|
my $refid = delete $args{ReferenceID} || ''; |
|
138
|
|
|
|
|
|
|
my $doc = { |
|
139
|
|
|
|
|
|
|
SMSAdvancedRequest => { |
|
140
|
|
|
|
|
|
|
xmlns => 'http://schemas.datacontract.org/2004/07/SmsWS', |
|
141
|
|
|
|
|
|
|
LicenseKey => [ delete $args{LicenseKey} ], |
|
142
|
|
|
|
|
|
|
SMSRequests => [ |
|
143
|
|
|
|
|
|
|
{ |
|
144
|
|
|
|
|
|
|
SMSRequest => [ |
|
145
|
|
|
|
|
|
|
{ |
|
146
|
|
|
|
|
|
|
xmlns => "http://sms2.cdyne.com", |
|
147
|
|
|
|
|
|
|
Message => [ delete $args{Message} ], |
|
148
|
|
|
|
|
|
|
AssignedDID => [ delete $args{AssignedDID} ], |
|
149
|
|
|
|
|
|
|
StatusPostBackURL => [ delete $args{StatusPostBackURL} ], |
|
150
|
|
|
|
|
|
|
ReferenceID => [ $refid ], |
|
151
|
|
|
|
|
|
|
PhoneNumbers => [ { |
|
152
|
|
|
|
|
|
|
string => [ |
|
153
|
|
|
|
|
|
|
{ |
|
154
|
|
|
|
|
|
|
xmlns => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', |
|
155
|
|
|
|
|
|
|
content => $num, |
|
156
|
|
|
|
|
|
|
}, |
|
157
|
|
|
|
|
|
|
], |
|
158
|
|
|
|
|
|
|
} ], |
|
159
|
|
|
|
|
|
|
}, |
|
160
|
|
|
|
|
|
|
], |
|
161
|
|
|
|
|
|
|
}, |
|
162
|
|
|
|
|
|
|
], |
|
163
|
|
|
|
|
|
|
}, |
|
164
|
|
|
|
|
|
|
}; |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
my $body = XML::Simple::XMLout($doc, KeepRoot => 1, ContentKey => 'content'); |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
return $self->do_cdyne_request('POST', $uri, \%args, $body); |
|
169
|
|
|
|
|
|
|
} |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub get_unread_incoming_messages { |
|
172
|
|
|
|
|
|
|
my ($self, %args) = @_; |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
my $uri = 'https://sms2.cdyne.com/sms.svc/SecureREST/GetUnreadIncomingMessages'; |
|
175
|
|
|
|
|
|
|
return $self->do_cdyne_request('GET', $uri, \%args); |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub get_message_status_by_reference_id { |
|
179
|
|
|
|
|
|
|
my ($self, %args) = @_; |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
my $uri = 'https://sms2.cdyne.com/sms.svc/SecureREST/GetMessageStatusByReferenceID'; |
|
182
|
|
|
|
|
|
|
return $self->do_cdyne_request('GET', $uri, \%args); |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub get_message_status { |
|
186
|
|
|
|
|
|
|
my ($self, %args) = @_; |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
my $uri = 'https://sms2.cdyne.com/sms.svc/SecureREST/GetMessageStatus'; |
|
189
|
|
|
|
|
|
|
return $self->do_cdyne_request('GET', $uri, \%args); |
|
190
|
|
|
|
|
|
|
} |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub cancel_message { |
|
193
|
|
|
|
|
|
|
my ($self, %args) = @_; |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
my $uri = 'https://sms2.cdyne.com/sms.svc/SecureREST/CancelMessage'; |
|
196
|
|
|
|
|
|
|
return $self->do_cdyne_request('GET', $uri, \%args); |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
1; |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
__END__ |