line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Easypost::Label; |
2
|
|
|
|
|
|
|
$Net::Easypost::Label::VERSION = '0.23'; |
3
|
6
|
|
|
6
|
|
32
|
use Moo; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
34
|
|
4
|
|
|
|
|
|
|
with qw(Net::Easypost::Resource); |
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
1703
|
use Carp qw(croak); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
255
|
|
7
|
6
|
|
|
6
|
|
30
|
use Net::Easypost::Request; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
2432
|
|
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
|
|
91
|
sub _build_operation { '' } |
50
|
5
|
|
|
5
|
|
490
|
sub _build_role { 'label' } |
51
|
|
|
|
|
|
|
sub _build_fieldnames { |
52
|
5
|
|
|
5
|
|
27411
|
return [qw/tracking_code url filetype filename/]; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub save { |
56
|
2
|
|
|
2
|
1
|
1832
|
my ($self) = @_; |
57
|
|
|
|
|
|
|
|
58
|
2
|
50
|
|
|
|
55
|
$self->image |
59
|
|
|
|
|
|
|
unless $self->has_image; |
60
|
|
|
|
|
|
|
|
61
|
2
|
50
|
|
|
|
247
|
open my $fh, ">:raw", $self->filename |
62
|
|
|
|
|
|
|
or croak "Couldn't save " . $self->filename . ": $!"; |
63
|
|
|
|
|
|
|
|
64
|
2
|
|
|
|
|
9
|
print {$fh} $self->image; |
|
2
|
|
|
|
|
98
|
|
65
|
2
|
|
|
|
|
272
|
close($fh); |
66
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
24
|
return 1; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub clone { |
71
|
1
|
|
|
1
|
1
|
10
|
my $self = shift; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
return Net::Easypost::Label->new( |
74
|
5
|
|
|
|
|
39
|
map { $_ => $self->$_ } |
75
|
5
|
|
|
|
|
29
|
grep { defined $self->$_ } |
76
|
1
|
|
|
|
|
2
|
'id', @{ $self->fieldnames } |
|
1
|
|
|
|
|
5
|
|
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__ |