line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Nexmo::SMS::MockLWP; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Module for the Nexmo SMS API! |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
7
|
|
|
7
|
|
1021059
|
use LWP::UserAgent; |
|
7
|
|
|
|
|
9378438
|
|
|
7
|
|
|
|
|
333
|
|
7
|
7
|
|
|
7
|
|
98
|
use HTTP::Response; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
138
|
|
8
|
7
|
|
|
7
|
|
9914
|
use JSON::PP; |
|
7
|
|
|
|
|
2723333
|
|
|
7
|
|
|
|
|
790
|
|
9
|
|
|
|
|
|
|
|
10
|
7
|
|
|
7
|
|
78
|
use strict; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
213
|
|
11
|
7
|
|
|
7
|
|
40
|
use warnings; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
271
|
|
12
|
|
|
|
|
|
|
|
13
|
7
|
|
|
7
|
|
38
|
no warnings 'redefine'; |
|
7
|
|
|
|
|
20
|
|
|
7
|
|
|
|
|
4581
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = 0.01; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
*LWP::UserAgent::post = sub { |
18
|
5
|
|
|
5
|
|
14
|
my ($object,$url,$params) = @_; |
19
|
|
|
|
|
|
|
|
20
|
5
|
|
|
|
|
12
|
my $json = do{ undef $/; }; |
|
5
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
226
|
|
21
|
|
|
|
|
|
|
|
22
|
5
|
|
|
|
|
59
|
my $coder = JSON::PP->new->ascii->pretty->allow_nonref; |
23
|
5
|
|
|
|
|
972
|
my $perl = $coder->decode( $json ); |
24
|
5
|
|
|
|
|
247320
|
my $from = $params->{from}; |
25
|
|
|
|
|
|
|
|
26
|
5
|
50
|
|
|
|
92
|
if ( $url =~ /get-balance/ ) { |
27
|
0
|
|
|
|
|
0
|
$from = 'get-balance'; |
28
|
0
|
|
|
|
|
0
|
$url = 'get-balance'; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
5
|
|
|
|
|
18
|
my $subhash = $perl->{$url}->{$from}; |
32
|
5
|
|
|
|
|
44
|
my $response = $coder->encode( $subhash ); |
33
|
|
|
|
|
|
|
|
34
|
5
|
|
|
|
|
4729
|
my $http_response = HTTP::Response->new( 200 ); |
35
|
5
|
|
|
|
|
563
|
$http_response->content( $response ); |
36
|
|
|
|
|
|
|
|
37
|
5
|
|
|
|
|
359
|
return $http_response; |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
*LWP::UserAgent::get = sub { |
41
|
1
|
|
|
1
|
|
3
|
my ($object,$url,$params) = @_; |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
3
|
my $json = do{ undef $/; }; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
27
|
|
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
12
|
my $coder = JSON::PP->new->ascii->pretty->allow_nonref; |
46
|
1
|
|
|
|
|
221
|
my $perl = $coder->decode( $json ); |
47
|
1
|
|
|
|
|
44394
|
my $from = $params->{from}; |
48
|
|
|
|
|
|
|
|
49
|
1
|
50
|
|
|
|
10
|
if ( $url =~ /get-balance/ ) { |
50
|
1
|
|
|
|
|
3
|
$from = 'get-balance'; |
51
|
1
|
|
|
|
|
4
|
$url = 'get-balance'; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
4
|
my $subhash = $perl->{$url}->{$from}; |
55
|
1
|
|
|
|
|
9
|
my $response = $coder->encode( $subhash ); |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
214
|
my $http_response = HTTP::Response->new( 200 ); |
58
|
1
|
|
|
|
|
87
|
$http_response->content( $response ); |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
65
|
return $http_response; |
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=pod |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 NAME |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Nexmo::SMS::MockLWP - Module for the Nexmo SMS API! |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 VERSION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
version 0.06 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 DESCRIPTION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This module mocks POST requests. It exists only for the unit tests! |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 VERSION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Version 0.01 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Copyright 2011 Renee Baecker. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This program is released under the following license: artistic_2 |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 AUTHOR |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Renee Baecker |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This software is Copyright (c) 2011 by Renee Baecker. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This is free software, licensed under: |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__DATA__ |