line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Moip::V2::Endpoint; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
9
|
use IO::Socket::SSL; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
16
|
|
4
|
2
|
|
|
2
|
|
296
|
use MIME::Base64; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
82
|
|
5
|
2
|
|
|
2
|
|
8
|
use Furl; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
34
|
|
6
|
2
|
|
|
2
|
|
6
|
use JSON (); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
21
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
5
|
use Moo; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
8
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $JSON = JSON->new->utf8; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'path', is => 'ro', required => 1; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'api_url', is => 'ro',required => 1; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has 'ua', is => 'ro', required => 1; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has 'token', is => 'ro', required => 1; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'key', is => 'ro', required => 1; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has 'client_id', is => 'ro'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has 'client_secret', is => 'ro'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has 'access_token', is => 'ro'; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has '_basic_auth_token', is => 'ro', lazy => 1, default => sub { |
29
|
|
|
|
|
|
|
my $self = shift; |
30
|
|
|
|
|
|
|
'Basic '.MIME::Base64::encode_base64( $self->token .':'. $self->key, ''); |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has 'url', is => 'ro', init_arg => undef, default => sub { |
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
join '/', $self->api_url, $self->path; |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get { |
41
|
2
|
|
|
2
|
0
|
2
|
my ($self, $id) = @_; |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
66
|
|
|
16
|
my $url = join '/', $self->url, $id || (); |
44
|
2
|
|
|
|
|
48
|
$self->ua->get($url, [ |
45
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
46
|
|
|
|
|
|
|
'Authentication' => $self->_basic_auth_token |
47
|
|
|
|
|
|
|
]); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub post { |
51
|
1
|
|
|
1
|
1
|
2
|
my ($self, $data) = @_; |
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
17
|
$self->ua->post($self->url, [ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
56
|
|
|
|
|
|
|
'Authentication' => $self->_basic_auth_token |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
], $JSON->encode($data) ); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub decode_json { |
62
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
63
|
0
|
|
|
|
|
|
$JSON->decode($_[0]); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
__END__ |