line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Easypost::Label; |
2
|
|
|
|
|
|
|
$Net::Easypost::Label::VERSION = '0.20'; |
3
|
6
|
|
|
6
|
|
45
|
use Moo; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
48
|
|
4
|
|
|
|
|
|
|
with qw(Net::Easypost::Resource); |
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
2477
|
use Carp qw(croak); |
|
6
|
|
|
|
|
20
|
|
|
6
|
|
|
|
|
427
|
|
7
|
6
|
|
|
6
|
|
47
|
use Net::Easypost::Request; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
2736
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'tracking_code' => ( |
10
|
|
|
|
|
|
|
is => 'ro', |
11
|
|
|
|
|
|
|
required => 1 |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'filename' => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
required => 1, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has 'filetype' => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
lazy => 1, |
22
|
|
|
|
|
|
|
default => 'image/png', |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has 'url' => ( |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
predicate => 1, |
28
|
|
|
|
|
|
|
required => 1, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has 'rate' => ( |
32
|
|
|
|
|
|
|
is => 'ro', |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has 'image' => ( |
36
|
|
|
|
|
|
|
is => 'ro', |
37
|
|
|
|
|
|
|
lazy => 1, |
38
|
|
|
|
|
|
|
predicate => 1, |
39
|
|
|
|
|
|
|
default => sub { |
40
|
|
|
|
|
|
|
my ($self) = @_; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
croak "Cannot retrieve image for " . $self->filename . " without URL" |
43
|
|
|
|
|
|
|
unless $self->has_url; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return $self->requester->get($self->url); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
5
|
|
|
5
|
|
104
|
sub _build_operation { '' } |
50
|
5
|
|
|
5
|
|
563
|
sub _build_role { 'label' } |
51
|
|
|
|
|
|
|
sub _build_fieldnames { |
52
|
5
|
|
|
5
|
|
18829
|
return [qw/tracking_code url filetype filename/]; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub save { |
56
|
2
|
|
|
2
|
1
|
2418
|
my ($self) = @_; |
57
|
|
|
|
|
|
|
|
58
|
2
|
50
|
|
|
|
55
|
$self->image |
59
|
|
|
|
|
|
|
unless $self->has_image; |
60
|
|
|
|
|
|
|
|
61
|
2
|
50
|
|
|
|
302
|
open my $fh, ">:raw", $self->filename |
62
|
|
|
|
|
|
|
or croak "Couldn't save " . $self->filename . ": $!"; |
63
|
|
|
|
|
|
|
|
64
|
2
|
|
|
|
|
10
|
print {$fh} $self->image; |
|
2
|
|
|
|
|
107
|
|
65
|
2
|
|
|
|
|
332
|
close($fh); |
66
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
22
|
return 1; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub clone { |
71
|
1
|
|
|
1
|
1
|
11
|
my $self = shift; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
return Net::Easypost::Label->new( |
74
|
5
|
|
|
|
|
42
|
map { $_ => $self->$_ } |
75
|
5
|
|
|
|
|
34
|
grep { defined $self->$_ } |
76
|
1
|
|
|
|
|
3
|
'id', @{ $self->fieldnames } |
|
1
|
|
|
|
|
3
|
|
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub serialize { |
81
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
return { |
84
|
0
|
|
|
|
|
|
map { $self->role . "[$_]" => $self->$_ } |
85
|
0
|
|
|
|
|
|
grep { defined $self->$_ } |
86
|
0
|
|
|
|
|
|
@{ $self->fieldnames } |
|
0
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
}; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |