line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Easypost::Label; |
2
|
|
|
|
|
|
|
$Net::Easypost::Label::VERSION = '0.21'; |
3
|
6
|
|
|
6
|
|
40
|
use Moo; |
|
6
|
|
|
|
|
1141
|
|
|
6
|
|
|
|
|
43
|
|
4
|
|
|
|
|
|
|
with qw(Net::Easypost::Resource); |
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
2081
|
use Carp qw(croak); |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
364
|
|
7
|
6
|
|
|
6
|
|
34
|
use Net::Easypost::Request; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
2145
|
|
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
|
|
549
|
sub _build_role { 'label' } |
51
|
|
|
|
|
|
|
sub _build_fieldnames { |
52
|
5
|
|
|
5
|
|
26523
|
return [qw/tracking_code url filetype filename/]; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub save { |
56
|
2
|
|
|
2
|
1
|
2233
|
my ($self) = @_; |
57
|
|
|
|
|
|
|
|
58
|
2
|
50
|
|
|
|
79
|
$self->image |
59
|
|
|
|
|
|
|
unless $self->has_image; |
60
|
|
|
|
|
|
|
|
61
|
2
|
50
|
|
|
|
317
|
open my $fh, ">:raw", $self->filename |
62
|
|
|
|
|
|
|
or croak "Couldn't save " . $self->filename . ": $!"; |
63
|
|
|
|
|
|
|
|
64
|
2
|
|
|
|
|
8
|
print {$fh} $self->image; |
|
2
|
|
|
|
|
108
|
|
65
|
2
|
|
|
|
|
267
|
close($fh); |
66
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
25
|
return 1; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub clone { |
71
|
1
|
|
|
1
|
1
|
10
|
my $self = shift; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
return Net::Easypost::Label->new( |
74
|
5
|
|
|
|
|
40
|
map { $_ => $self->$_ } |
75
|
5
|
|
|
|
|
30
|
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__ |