| 1 | package Net::Async::Webservice::DHL::Address; | ||||||||||||||
| 2 | 4 | ▶ | use Moo; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 4 | ▶ | use 5.010; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 4 | ▶ | use Types::Standard qw(Str Int Bool StrictNum); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 4 | ▶ | use Net::Async::Webservice::DHL::Types ':types'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 4 | our $VERSION = '1.2.2'; # VERSION | |||||||||||||
| 7 | |||||||||||||||
| 8 | # ABSTRACT: an address for DHL | ||||||||||||||
| 9 | |||||||||||||||
| 10 | |||||||||||||||
| 11 | 4 | for my $l (1..3) { | |||||||||||||
| 12 | 12 | has "line$l" => ( | |||||||||||||
| 13 | is => 'ro', | ||||||||||||||
| 14 | isa => Str, | ||||||||||||||
| 15 | required => 0, | ||||||||||||||
| 16 | ); | ||||||||||||||
| 17 | } | ||||||||||||||
| 18 | |||||||||||||||
| 19 | |||||||||||||||
| 20 | 4 | has city => ( | |||||||||||||
| 21 | is => 'ro', | ||||||||||||||
| 22 | isa => Str, | ||||||||||||||
| 23 | required => 0, | ||||||||||||||
| 24 | ); | ||||||||||||||
| 25 | |||||||||||||||
| 26 | |||||||||||||||
| 27 | 4 | has division => ( | |||||||||||||
| 28 | is => 'ro', | ||||||||||||||
| 29 | isa => Str, | ||||||||||||||
| 30 | required => 0, | ||||||||||||||
| 31 | ); | ||||||||||||||
| 32 | |||||||||||||||
| 33 | |||||||||||||||
| 34 | 4 | has postal_code => ( | |||||||||||||
| 35 | is => 'ro', | ||||||||||||||
| 36 | isa => Str, | ||||||||||||||
| 37 | required => 0, | ||||||||||||||
| 38 | ); | ||||||||||||||
| 39 | |||||||||||||||
| 40 | |||||||||||||||
| 41 | 4 | has country_code => ( | |||||||||||||
| 42 | is => 'ro', | ||||||||||||||
| 43 | isa => CountryCode, | ||||||||||||||
| 44 | required => 1, | ||||||||||||||
| 45 | ); | ||||||||||||||
| 46 | |||||||||||||||
| 47 | |||||||||||||||
| 48 | 4 | has country_name => ( | |||||||||||||
| 49 | is => 'ro', | ||||||||||||||
| 50 | isa => Str, | ||||||||||||||
| 51 | required => 0, | ||||||||||||||
| 52 | ); | ||||||||||||||
| 53 | |||||||||||||||
| 54 | |||||||||||||||
| 55 | 8 | ▶ | sub as_hash { | ||||||||||||
|
Subroutine
as_hash: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||
| 56 | 8 | my ($self,$shape) = @_; | |||||||||||||
| 57 | 26 | ▶ | my $if = sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||
| 58 | 26 | my ($method,$key) = @_; | |||||||||||||
| 59 | 26 | ▶ | if ($self->$method) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 60 | 16 | return ( $key => $self->$method ); | |||||||||||||
| 61 | } | ||||||||||||||
| 62 | 10 | return; | |||||||||||||
| 63 | 8 | }; | |||||||||||||
| 64 | |||||||||||||||
| 65 | 8 | ▶ | if ($shape eq 'capability') { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 66 | return { | ||||||||||||||
| 67 | 6 | $if->(postal_code => 'Postalcode'), | |||||||||||||
| 68 | $if->(city => 'City'), | ||||||||||||||
| 69 | CountryCode => $self->country_code, | ||||||||||||||
| 70 | }; | ||||||||||||||
| 71 | } | ||||||||||||||
| 72 | elsif ($shape eq 'route') { | ||||||||||||||
| 73 | return { | ||||||||||||||
| 74 | 2 | $if->(line1 => 'Address1'), | |||||||||||||
| 75 | $if->(line2 => 'Address2'), | ||||||||||||||
| 76 | $if->(line3 => 'Address3'), | ||||||||||||||
| 77 | $if->(postal_code => 'PostalCode'), | ||||||||||||||
| 78 | $if->(city => 'City'), | ||||||||||||||
| 79 | $if->(division => 'Division'), | ||||||||||||||
| 80 | CountryCode => $self->country_code, | ||||||||||||||
| 81 | CountryName => '', # the value is required, but an empty | ||||||||||||||
| 82 | # string will do | ||||||||||||||
| 83 | $if->(country_name => 'CountryName'), | ||||||||||||||
| 84 | }; | ||||||||||||||
| 85 | }; | ||||||||||||||
| 86 | } | ||||||||||||||
| 87 | |||||||||||||||
| 88 | 4 | 1; | |||||||||||||
| 89 | |||||||||||||||
| 90 | __END__ | ||||||||||||||