line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Dimona; |
2
|
1
|
|
|
1
|
|
69243
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
708
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
47160
|
|
|
1
|
|
|
|
|
36
|
|
5
|
1
|
|
|
1
|
|
490
|
use JSON::MaybeXS qw( encode_json decode_json ); |
|
1
|
|
|
|
|
5776
|
|
|
1
|
|
|
|
|
536
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = 0.01; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
1
|
|
|
1
|
1
|
514
|
my ($class, %params) = @_; |
11
|
1
|
50
|
|
|
|
5
|
die 'api_key required' unless defined $params{api_key}; |
12
|
|
|
|
|
|
|
return bless { |
13
|
|
|
|
|
|
|
debug => $params{debug}, |
14
|
|
|
|
|
|
|
api_key => $params{api_key} || die 'api_key is required', |
15
|
|
|
|
|
|
|
ua => LWP::UserAgent->new( |
16
|
1
|
|
50
|
|
|
9
|
timeout => exists $params{timeout} ? $params{timeout} : 5, |
17
|
|
|
|
|
|
|
), |
18
|
|
|
|
|
|
|
}, $class; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _request { |
22
|
0
|
|
|
0
|
|
|
my ($self, $method, $url, $params) = @_; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $res = $self->{ua}->$method( |
25
|
|
|
|
|
|
|
'https://camisadimona.com.br/api/' . $url, |
26
|
|
|
|
|
|
|
'api-key' => $self->{api_key}, |
27
|
0
|
0
|
|
|
|
|
'Accept' => 'application/json', |
28
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
29
|
|
|
|
|
|
|
($params ? ('Content' => encode_json($params)) : ()) |
30
|
|
|
|
|
|
|
); |
31
|
0
|
|
|
|
|
|
return decode_json($res->decoded_content); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub create_order { |
36
|
0
|
|
|
0
|
1
|
|
my ($self, $params) = @_; |
37
|
0
|
|
|
|
|
|
return $self->_request('post', 'v2/order', $params); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub list_orders { |
41
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
42
|
0
|
|
|
|
|
|
return $self->_request('get', 'v2/orders'); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub get_order { |
46
|
0
|
|
|
0
|
1
|
|
my ($self, $order_id) = @_; |
47
|
0
|
|
|
|
|
|
return $self->_request('get', 'v2/order/' . $order_id); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub get_order_tracking { |
51
|
0
|
|
|
0
|
1
|
|
my ($self, $order_id) = @_; |
52
|
0
|
|
|
|
|
|
return $self->_request('get', 'v2/order/' . $order_id . '/tracking'); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub get_order_timeline { |
56
|
0
|
|
|
0
|
1
|
|
my ($self, $order_id) = @_; |
57
|
0
|
|
|
|
|
|
return $self->_request('get', 'v2/order/' . $order_id . '/timeline'); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub product_availability { |
61
|
0
|
|
|
0
|
1
|
|
my ($self, $sku) = @_; |
62
|
0
|
|
|
|
|
|
return $self->_request('get', 'v2/sku/' . $sku . '/availability'); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub quote_shipping { |
66
|
0
|
|
|
0
|
0
|
|
my ($self, $params) = @_; |
67
|
0
|
|
|
|
|
|
return $self->_request('post', 'v2/shipping', $params); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
__END__ |