line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
7
|
|
|
7
|
|
34
|
use strict; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
185
|
|
2
|
7
|
|
|
7
|
|
32
|
use warnings; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
180
|
|
3
|
7
|
|
|
7
|
|
33
|
use MRO::Compat 'c3'; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
255
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package WebService::Shippo::Resource; |
6
|
|
|
|
|
|
|
require WebService::Shippo::Request; |
7
|
7
|
|
|
7
|
|
5360
|
use URI::Encode ( 'uri_encode' ); |
|
7
|
|
|
|
|
89471
|
|
|
7
|
|
|
|
|
464
|
|
8
|
7
|
|
|
7
|
|
5330
|
use MIME::Base64; |
|
7
|
|
|
|
|
4690
|
|
|
7
|
|
|
|
|
501
|
|
9
|
7
|
|
|
7
|
|
47
|
use base ( 'WebService::Shippo::Object' ); |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
538
|
|
10
|
7
|
|
|
7
|
|
40
|
use constant DEFAULT_API_SCHEME => 'https'; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
477
|
|
11
|
7
|
|
|
7
|
|
40
|
use constant DEFAULT_API_HOST => 'api.goshippo.com'; |
|
7
|
|
|
|
|
42
|
|
|
7
|
|
|
|
|
330
|
|
12
|
7
|
|
|
7
|
|
36
|
use constant DEFAULT_API_PORT => '443'; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
317
|
|
13
|
7
|
|
|
7
|
|
35
|
use constant DEFAULT_API_VERSION => 'v1'; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
4813
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
{ |
16
|
|
|
|
|
|
|
my $value = undef; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub api_private_token |
19
|
|
|
|
|
|
|
{ |
20
|
0
|
|
|
0
|
0
|
0
|
my ( $class, $new_value ) = @_; |
21
|
0
|
0
|
|
|
|
0
|
return $value unless @_ > 1; |
22
|
0
|
|
|
|
|
0
|
$value = $new_value; |
23
|
0
|
|
|
|
|
0
|
return $class; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
my $value = undef; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub api_public_token |
31
|
|
|
|
|
|
|
{ |
32
|
0
|
|
|
0
|
0
|
0
|
my ( $class, $new_value ) = @_; |
33
|
0
|
0
|
|
|
|
0
|
return $value unless @_ > 1; |
34
|
0
|
|
|
|
|
0
|
$value = $new_value; |
35
|
0
|
|
|
|
|
0
|
return $class; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
{ |
40
|
|
|
|
|
|
|
my $value = undef; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub api_key |
43
|
|
|
|
|
|
|
{ |
44
|
6
|
|
|
6
|
0
|
546
|
my ( $class, $new_value ) = @_; |
45
|
6
|
50
|
|
|
|
40
|
return $value unless @_ > 1; |
46
|
0
|
|
|
|
|
|
$value = $new_value; |
47
|
0
|
0
|
|
|
|
|
Shippo::Request->headers->{Authorization} = "ShippoToken $value" |
48
|
|
|
|
|
|
|
if $value; |
49
|
0
|
|
|
|
|
|
return $class; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
{ |
54
|
|
|
|
|
|
|
my @value = (); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub api_credentials |
57
|
|
|
|
|
|
|
{ |
58
|
0
|
|
|
0
|
0
|
|
my ( $class, $user, $pass ) = @_; |
59
|
0
|
0
|
|
|
|
|
return @value unless @_ > 1; |
60
|
0
|
|
|
|
|
|
@value = ( $user, $pass ); |
61
|
0
|
0
|
|
|
|
|
if ( @value ) { |
62
|
0
|
|
|
|
|
|
my $header = 'Basic ' . encode_base64( join ':', @value ); |
63
|
0
|
|
|
|
|
|
Shippo::Request->headers->{Authorization} = $header; |
64
|
|
|
|
|
|
|
} |
65
|
0
|
|
|
|
|
|
return $class; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
0
|
0
|
|
sub api_scheme { DEFAULT_API_SCHEME } |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
0
|
0
|
|
sub api_host { DEFAULT_API_HOST } |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
0
|
0
|
|
sub api_port { DEFAULT_API_PORT } |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
0
|
0
|
|
sub api_base_path { DEFAULT_API_VERSION } |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub api_endpoint |
78
|
|
|
|
|
|
|
{ |
79
|
0
|
|
|
0
|
0
|
|
my $scheme = api_scheme(); |
80
|
0
|
|
|
|
|
|
my $port = api_port(); |
81
|
0
|
|
|
|
|
|
my $path = api_base_path; |
82
|
0
|
|
|
|
|
|
my $value = $scheme . '://' . api_host(); |
83
|
0
|
0
|
0
|
|
|
|
$value .= ':' . $port |
|
|
|
0
|
|
|
|
|
84
|
|
|
|
|
|
|
unless $port && $port eq '443' && $scheme eq 'https'; |
85
|
0
|
|
|
|
|
|
$value .= '/'; |
86
|
0
|
0
|
|
|
|
|
$value .= $path . '/' |
87
|
|
|
|
|
|
|
if $path; |
88
|
0
|
|
|
|
|
|
return $value; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub url |
92
|
|
|
|
|
|
|
{ |
93
|
0
|
|
|
0
|
0
|
|
my ( $class, $id ) = @_; |
94
|
0
|
|
|
|
|
|
my $resource = $class->api_resource; |
95
|
0
|
|
|
|
|
|
my $url = $class->api_endpoint; |
96
|
0
|
0
|
|
|
|
|
$url .= $resource . '/' |
97
|
|
|
|
|
|
|
if $resource; |
98
|
0
|
0
|
0
|
|
|
|
$url .= uri_encode( $id ) . '/' |
99
|
|
|
|
|
|
|
if @_ > 1 && $id; |
100
|
0
|
|
|
|
|
|
return $url; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub id |
104
|
|
|
|
|
|
|
{ |
105
|
0
|
|
|
0
|
0
|
|
my ( $invocant ) = @_; |
106
|
0
|
0
|
|
|
|
|
return '' unless defined $invocant->{object_id}; |
107
|
0
|
|
|
|
|
|
return $invocant->{object_id}; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub is_valid |
111
|
|
|
|
|
|
|
{ |
112
|
0
|
|
|
0
|
0
|
|
my ( $invocant ) = @_; |
113
|
0
|
0
|
|
|
|
|
return '' unless defined $invocant->{object_state}; |
114
|
0
|
|
0
|
|
|
|
return $invocant->{object_state} && $invocant->{object_state} eq 'VALID'; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
BEGIN { |
118
|
7
|
|
|
7
|
|
40
|
no warnings 'once'; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
429
|
|
119
|
|
|
|
|
|
|
# Forcing the dev to always use CPAN's perferred "WebService::Shippo" |
120
|
|
|
|
|
|
|
# namespace is just cruel; allow the use of "Shippo", too. |
121
|
7
|
|
|
7
|
|
18
|
*Shippo::Resource:: = *WebService::Shippo::Resource::; |
122
|
|
|
|
|
|
|
# Other aliases |
123
|
7
|
|
|
|
|
21
|
*class_url = *url; |
124
|
7
|
|
|
|
|
195
|
*api_protocol = *api_scheme; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
1; |