line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Lob; |
2
|
|
|
|
|
|
|
$WebService::Lob::VERSION = '0.0105'; |
3
|
3
|
|
|
3
|
|
395854
|
use Moo; |
|
3
|
|
|
|
|
49615
|
|
|
3
|
|
|
|
|
1330
|
|
4
|
|
|
|
|
|
|
with 'WebService::BaseClientRole'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# VERSION |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
19482
|
use aliased 'WebService::Lob::Exception::AddressNotFound'; |
|
3
|
|
|
|
|
3003
|
|
|
3
|
|
|
|
|
32
|
|
9
|
3
|
|
|
3
|
|
317
|
use aliased 'WebService::Lob::Exception::AddressMissingInformation'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
23
|
|
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
14474
|
use Function::Parameters ':strict'; |
|
3
|
|
|
|
|
12193
|
|
|
3
|
|
|
|
|
24
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has '+base_url' => ( default => 'https://api.lob.com/v1' ); |
14
|
|
|
|
|
|
|
has api_key => ( is => 'ro', required => 1 ); |
15
|
|
|
|
|
|
|
has states_uri => ( is => 'ro', default => '/states' ); |
16
|
|
|
|
|
|
|
has countries_uri => ( is => 'ro', default => '/countries' ); |
17
|
|
|
|
|
|
|
has verify_uri => ( is => 'ro', default => '/verify' ); |
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
|
0
|
|
|
method BUILD { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
$self->ua->credentials('api.lob.com:443', '', $self->api_key, ''); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
0
|
|
|
method get_states { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
my $result = $self->get($self->states_uri); |
25
|
0
|
0
|
|
|
|
|
return $result->{data} if $result; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
0
|
|
|
method get_countries { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $result = $self->get($self->countries_uri); |
30
|
0
|
0
|
|
|
|
|
return $result->{data} if $result; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
method verify_address( |
34
|
|
|
|
|
|
|
Str :$address_line1, |
35
|
|
|
|
|
|
|
Str :$address_line2 = '', |
36
|
|
|
|
|
|
|
Str :$address_city, |
37
|
|
|
|
|
|
|
Str :$address_state, |
38
|
|
|
|
|
|
|
Str :$address_zip, |
39
|
|
|
|
|
|
|
Str :$address_country |
40
|
|
|
|
|
|
|
) { |
41
|
|
|
|
|
|
|
my $result = $self->post($self->verify_uri, { |
42
|
|
|
|
|
|
|
address_line1 => $address_line1, |
43
|
|
|
|
|
|
|
address_line2 => $address_line2, |
44
|
|
|
|
|
|
|
address_city => $address_city, |
45
|
|
|
|
|
|
|
address_state => $address_state, |
46
|
|
|
|
|
|
|
address_zip => $address_zip, |
47
|
|
|
|
|
|
|
address_country => $address_country, |
48
|
|
|
|
|
|
|
}); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
AddressNotFound->throw unless $result; |
51
|
|
|
|
|
|
|
AddressMissingInformation->throw( message => $result->{message} ) |
52
|
|
|
|
|
|
|
if $result->{message}; |
53
|
|
|
|
|
|
|
return $result->{address}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |