| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Easypost::Address; |
|
2
|
|
|
|
|
|
|
$Net::Easypost::Address::VERSION = '0.20'; |
|
3
|
6
|
|
|
6
|
|
37
|
use Carp qw/croak/; |
|
|
6
|
|
|
|
|
16
|
|
|
|
6
|
|
|
|
|
263
|
|
|
4
|
6
|
|
|
6
|
|
2520
|
use JSON::MaybeXS; |
|
|
6
|
|
|
|
|
46755
|
|
|
|
6
|
|
|
|
|
404
|
|
|
5
|
6
|
|
|
6
|
|
53
|
use Scalar::Util; |
|
|
6
|
|
|
|
|
15
|
|
|
|
6
|
|
|
|
|
652
|
|
|
6
|
|
|
|
|
|
|
use overload |
|
7
|
5
|
|
|
5
|
|
2403
|
'""' => sub { $_[0]->as_string }, |
|
8
|
4
|
|
|
4
|
|
2150
|
'0+' => sub { Scalar::Util::refaddr($_[0]) }, |
|
9
|
6
|
|
|
6
|
|
762
|
fallback => 1; |
|
|
6
|
|
|
|
|
17
|
|
|
|
6
|
|
|
|
|
61
|
|
|
10
|
6
|
|
|
6
|
|
3984
|
use Types::Standard qw(Bool Enum HashRef InstanceOf Str Undef); |
|
|
6
|
|
|
|
|
602698
|
|
|
|
6
|
|
|
|
|
110
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
6
|
|
|
6
|
|
15774
|
use Moo; |
|
|
6
|
|
|
|
|
69428
|
|
|
|
6
|
|
|
|
|
39
|
|
|
14
|
|
|
|
|
|
|
with qw/Net::Easypost::PostOnBuild/; |
|
15
|
|
|
|
|
|
|
with qw/Net::Easypost::Resource/; |
|
16
|
6
|
|
|
6
|
|
11036
|
use namespace::autoclean; |
|
|
6
|
|
|
|
|
73098
|
|
|
|
6
|
|
|
|
|
39
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has [qw/street1 |
|
19
|
|
|
|
|
|
|
street2 |
|
20
|
|
|
|
|
|
|
city |
|
21
|
|
|
|
|
|
|
state |
|
22
|
|
|
|
|
|
|
zip |
|
23
|
|
|
|
|
|
|
country |
|
24
|
|
|
|
|
|
|
carrier_facility |
|
25
|
|
|
|
|
|
|
name |
|
26
|
|
|
|
|
|
|
company |
|
27
|
|
|
|
|
|
|
phone |
|
28
|
|
|
|
|
|
|
email |
|
29
|
|
|
|
|
|
|
federal_tax_id |
|
30
|
|
|
|
|
|
|
state_tax_id/ |
|
31
|
|
|
|
|
|
|
] => ( |
|
32
|
|
|
|
|
|
|
is => 'rw', |
|
33
|
|
|
|
|
|
|
isa => Str|Undef |
|
34
|
|
|
|
|
|
|
); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has 'residential' => ( |
|
37
|
|
|
|
|
|
|
is => 'rw', |
|
38
|
|
|
|
|
|
|
isa => Bool|InstanceOf['JSON::PP::Boolean'], |
|
39
|
|
|
|
|
|
|
coerce => sub { $_[0] ? JSON->true : JSON->false } |
|
40
|
|
|
|
|
|
|
); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has 'verifications' => ( |
|
43
|
|
|
|
|
|
|
is => 'rw', |
|
44
|
|
|
|
|
|
|
isa => HashRef |
|
45
|
|
|
|
|
|
|
); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has 'verify_adress' => ( |
|
48
|
|
|
|
|
|
|
is => 'rw', |
|
49
|
|
|
|
|
|
|
isa => Enum[qw/zip4 delivery/] |
|
50
|
|
|
|
|
|
|
); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _build_fieldnames { |
|
53
|
|
|
|
|
|
|
return [ |
|
54
|
31
|
|
|
31
|
|
91898
|
qw/ |
|
55
|
|
|
|
|
|
|
street1 |
|
56
|
|
|
|
|
|
|
street2 |
|
57
|
|
|
|
|
|
|
city |
|
58
|
|
|
|
|
|
|
state |
|
59
|
|
|
|
|
|
|
zip |
|
60
|
|
|
|
|
|
|
country |
|
61
|
|
|
|
|
|
|
residential |
|
62
|
|
|
|
|
|
|
carrier_facility |
|
63
|
|
|
|
|
|
|
name |
|
64
|
|
|
|
|
|
|
company |
|
65
|
|
|
|
|
|
|
phone |
|
66
|
|
|
|
|
|
|
email |
|
67
|
|
|
|
|
|
|
federal_tax_id |
|
68
|
|
|
|
|
|
|
state_tax_id |
|
69
|
|
|
|
|
|
|
/ |
|
70
|
|
|
|
|
|
|
]; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
31
|
|
|
31
|
|
5497
|
sub _build_role { 'address' } |
|
74
|
31
|
|
|
31
|
|
1776
|
sub _build_operation { '/addresses' } |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub clone { |
|
77
|
3
|
|
|
3
|
1
|
3938
|
my ($self) = @_; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
return Net::Easypost::Address->new( |
|
80
|
20
|
|
|
|
|
517
|
map { $_ => $self->$_ } |
|
81
|
3
|
|
|
|
|
11
|
grep { defined $self->$_ } @{ $self->fieldnames } |
|
|
42
|
|
|
|
|
1310
|
|
|
|
3
|
|
|
|
|
24
|
|
|
82
|
|
|
|
|
|
|
); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub serialize { |
|
86
|
31
|
|
|
31
|
0
|
105
|
my ($self) = @_; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# want a hashref of e.g., address[name] => foo from all defined attributes |
|
89
|
|
|
|
|
|
|
# verify[]=zip4|delivery - verify an address |
|
90
|
|
|
|
|
|
|
return { |
|
91
|
|
|
|
|
|
|
# (defined $self->verify_address ? "verify[]" => $self->verify : ()), |
|
92
|
178
|
|
|
|
|
4229
|
(map { $self->role . "[$_]" => $self->$_ } |
|
93
|
31
|
|
|
|
|
89
|
grep { defined $self->$_ } @{ $self->fieldnames }) |
|
|
434
|
|
|
|
|
11714
|
|
|
|
31
|
|
|
|
|
131
|
|
|
94
|
|
|
|
|
|
|
}; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub as_string { |
|
98
|
5
|
|
|
5
|
1
|
13
|
my ($self) = @_; |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
return join "\n", |
|
101
|
13
|
|
|
|
|
265
|
(map { $self->$_ } |
|
102
|
20
|
|
|
|
|
582
|
grep { defined $self->$_ } qw(name phone street1 street2)), |
|
103
|
|
|
|
|
|
|
join " ", |
|
104
|
13
|
|
|
|
|
320
|
(map { $self->$_ } |
|
105
|
5
|
|
|
|
|
15
|
grep { defined $self->$_ } qw(city state zip)); |
|
|
15
|
|
|
|
|
677
|
|
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub merge { |
|
109
|
9
|
|
|
9
|
1
|
60
|
my ($self, $old, $fields) = @_; |
|
110
|
|
|
|
|
|
|
|
|
111
|
11
|
|
|
|
|
346
|
map { $self->$_($old->$_) } |
|
112
|
9
|
|
|
|
|
33
|
grep { defined $old->$_ } |
|
|
19
|
|
|
|
|
573
|
|
|
113
|
|
|
|
|
|
|
@$fields; |
|
114
|
|
|
|
|
|
|
|
|
115
|
9
|
|
|
|
|
659
|
return $self; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub verify { |
|
119
|
9
|
|
|
9
|
1
|
273
|
my ($self) = @_; |
|
120
|
|
|
|
|
|
|
|
|
121
|
9
|
|
|
|
|
137
|
my $verify_response = |
|
122
|
|
|
|
|
|
|
$self->requester->get( |
|
123
|
|
|
|
|
|
|
join '/', $self->operation, $self->id, 'verify' |
|
124
|
|
|
|
|
|
|
); |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
croak 'Unable to verify address, failed with message: ' |
|
127
|
|
|
|
|
|
|
. $verify_response->{error} |
|
128
|
9
|
100
|
|
|
|
90
|
if $verify_response->{error}; |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
my $new_address = Net::Easypost::Address->new( |
|
131
|
|
|
|
|
|
|
$verify_response->{address} |
|
132
|
8
|
|
|
|
|
421
|
); |
|
133
|
|
|
|
|
|
|
|
|
134
|
8
|
|
|
|
|
231
|
return $new_address->merge($self, [qw(phone name)]); |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
__END__ |