| 1 | package WebService::SmartyStreets; | ||||||||||||||||||||||||||||||||||||||||
| 2 | 3 | $WebService::SmartyStreets::VERSION = '0.0105'; | |||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | with 'WebService::Client'; | |||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||
| 6 | # VERSION | ||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use aliased 'WebService::SmartyStreets::Exception::AddressNotFound'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use aliased 'WebService::SmartyStreets::Exception::AddressMissingInformation'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use Method::Signatures; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | has auth_id => ( is => 'ro', required => 1 ); | |||||||||||||||||||||||||||||||||||||||
| 15 | 3 | has auth_token => ( is => 'ro', required => 1 ); | |||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||
| 17 | has '+base_url' => ( | ||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 20 | 1 | my $uri = URI->new('https://api.smartystreets.com/street-address'); | |||||||||||||||||||||||||||||||||||||||
| 21 | 1 | $uri->query_form( | |||||||||||||||||||||||||||||||||||||||
| 22 | 'auth-id' => $self->auth_id, | ||||||||||||||||||||||||||||||||||||||||
| 23 | 'auth-token' => $self->auth_token, | ||||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | return $uri->as_string; | |||||||||||||||||||||||||||||||||||||||
| 26 | }, | ||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | ); | |||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | ▶ | method verify_address( | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
verify_address: called CC=25 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||
| 30 | 6 | ▶ | Str :$street!, | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$Method::Signatures::mutc{"cache"}{"Str"} ||= "Method::Signatures"->_make_constraint("Str")
MC/DC0%0/2
$Method::Signatures::mutc{"cache"}{"Str"} ||= "Method::Signatures"->_make_constraint("Str")
$Method::Signatures::mutc{"cache"}{"Str"}
"Method::Signatures"->_make_constraint("Str")
Truth table66%2/3
A ||= B
A= $Method::Signatures::mutc{"cache"}{"Str"}B= "Method::Signatures"->_make_constraint("Str")
| |||||||||||||||||||||||||||||||||||||||||
| 31 | 5 | ▶ | Str :$street2 = '', | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$Method::Signatures::mutc{"cache"}{"Str"} ||= "Method::Signatures"->_make_constraint("Str")
MC/DC0%0/2
$Method::Signatures::mutc{"cache"}{"Str"} ||= "Method::Signatures"->_make_constraint("Str")
$Method::Signatures::mutc{"cache"}{"Str"}
"Method::Signatures"->_make_constraint("Str")
Truth table33%1/3
A ||= B
A= $Method::Signatures::mutc{"cache"}{"Str"}B= "Method::Signatures"->_make_constraint("Str")
| |||||||||||||||||||||||||||||||||||||||||
| 32 | 5 | ▶ | Str :$city!, | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$Method::Signatures::mutc{"cache"}{"Str"} ||= "Method::Signatures"->_make_constraint("Str")
MC/DC0%0/2
$Method::Signatures::mutc{"cache"}{"Str"} ||= "Method::Signatures"->_make_constraint("Str")
$Method::Signatures::mutc{"cache"}{"Str"}
"Method::Signatures"->_make_constraint("Str")
Truth table33%1/3
A ||= B
A= $Method::Signatures::mutc{"cache"}{"Str"}B= "Method::Signatures"->_make_constraint("Str")
| |||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | ▶ | Str :$state!, | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$Method::Signatures::mutc{"cache"}{"Str"} ||= "Method::Signatures"->_make_constraint("Str")
MC/DC0%0/2
$Method::Signatures::mutc{"cache"}{"Str"} ||= "Method::Signatures"->_make_constraint("Str")
$Method::Signatures::mutc{"cache"}{"Str"}
"Method::Signatures"->_make_constraint("Str")
Truth table33%1/3
A ||= B
A= $Method::Signatures::mutc{"cache"}{"Str"}B= "Method::Signatures"->_make_constraint("Str")
| |||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | ▶ | Str :$zipcode = '', | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$Method::Signatures::mutc{"cache"}{"Str"} ||= "Method::Signatures"->_make_constraint("Str")
MC/DC0%0/2
$Method::Signatures::mutc{"cache"}{"Str"} ||= "Method::Signatures"->_make_constraint("Str")
$Method::Signatures::mutc{"cache"}{"Str"}
"Method::Signatures"->_make_constraint("Str")
Truth table33%1/3
A ||= B
A= $Method::Signatures::mutc{"cache"}{"Str"}B= "Method::Signatures"->_make_constraint("Str")
| |||||||||||||||||||||||||||||||||||||||||
| 35 | 3 | ▶ | Int :$candidates = 2 | ||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition66%2/3
$Method::Signatures::mutc{"cache"}{"Int"} ||= "Method::Signatures"->_make_constraint("Int")
MC/DC0%0/2
$Method::Signatures::mutc{"cache"}{"Int"} ||= "Method::Signatures"->_make_constraint("Int")
$Method::Signatures::mutc{"cache"}{"Int"}
"Method::Signatures"->_make_constraint("Int")
Truth table66%2/3
A ||= B
A= $Method::Signatures::mutc{"cache"}{"Int"}B= "Method::Signatures"->_make_constraint("Int")
| |||||||||||||||||||||||||||||||||||||||||
| 36 | ) { | ||||||||||||||||||||||||||||||||||||||||
| 37 | 3 | my $results = $self->post($self->base_url, [{ | |||||||||||||||||||||||||||||||||||||||
| 38 | street => $street, | ||||||||||||||||||||||||||||||||||||||||
| 39 | street2 => $street2, | ||||||||||||||||||||||||||||||||||||||||
| 40 | city => $city, | ||||||||||||||||||||||||||||||||||||||||
| 41 | state => $state, | ||||||||||||||||||||||||||||||||||||||||
| 42 | zipcode => $zipcode, | ||||||||||||||||||||||||||||||||||||||||
| 43 | candidates => $candidates, | ||||||||||||||||||||||||||||||||||||||||
| 44 | }]); | ||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | AddressNotFound->throw unless $results and @$results; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$results and @$results
MC/DC0%0/2
$results and @$results
$results
@$results
Truth table0%0/3
A and B
A= $resultsB= @$results
| |||||||||||||||||||||||||||||||||||||||||
| 47 | AddressMissingInformation->throw if @$results == 1 | ||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | and $results->[0]{analysis}{dpv_match_code} eq 'D'; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@$results == 1 and $results->[0]{"analysis"}{"dpv_match_code"} eq "D"
MC/DC0%0/2
@$results == 1 and $results->[0]{"analysis"}{"dpv_match_code"} eq "D"
@$results == 1
$results->[0]{"analysis"}{"dpv_match_code"} eq "D"
Truth table0%0/3
A and B
A= @$results == 1B= $results->[0]{"analysis"}{"dpv_match_code"} eq "D"
| |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||
| 50 | return [ | ||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | map {{ | |||||||||||||||||||||||||||||||||||||||
| 52 | street => $_->{delivery_line_1}, | ||||||||||||||||||||||||||||||||||||||||
| 53 | (street2 => $_->{delivery_line_2}) x!! $_->{delivery_line_2}, | ||||||||||||||||||||||||||||||||||||||||
| 54 | city => $_->{components}{city_name}, | ||||||||||||||||||||||||||||||||||||||||
| 55 | state => $_->{components}{state_abbreviation}, | ||||||||||||||||||||||||||||||||||||||||
| 56 | zipcode => $_->{components}{zipcode} . '-' . $_->{components}{plus4_code}, | ||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | }} @$results | |||||||||||||||||||||||||||||||||||||||
| 58 | ]; | ||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||
| 62 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||
| 64 | __END__ | ||||||||||||||||||||||||||||||||||||||||