| 1 | package Net::Async::Webservice::UPS::Response::Utils; | ||||||||||||||||||||||||||||
| 2 | 5 | $Net::Async::Webservice::UPS::Response::Utils::VERSION = '1.1.4'; | |||||||||||||||||||||||||||
| 3 | { | ||||||||||||||||||||||||||||
| 4 | 5 | $Net::Async::Webservice::UPS::Response::Utils::DIST = 'Net-Async-Webservice-UPS'; | |||||||||||||||||||||||||||
| 5 | } | ||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use Sub::Exporter -setup => { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | exports => [qw(img_if pair_if base64_if | ||||||||||||||||||||||||||||
| 11 | in_if out_if in_object_if in_object_array_if in_datetime_if | ||||||||||||||||||||||||||||
| 12 | set_implied_argument)], | ||||||||||||||||||||||||||||
| 13 | 5 | }; | |||||||||||||||||||||||||||
| 14 | 5 | ▶ | use DateTime::Format::Strptime; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use Module::Runtime 'use_module'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 5 | ▶ | use Scope::Upper qw(reap :words); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # ABSTRACT: utility functions to parse hashrefs into response objects | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 5 | my $implied_arg; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 315 | ▶ | sub set_implied_argument { | ||||||||||||||||||||||||||
|
Subroutine
set_implied_argument: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | 315 | my ($value) = @_; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 315 | $implied_arg = $value; | |||||||||||||||||||||||||||
| 27 | 315 | ▶ | reap { undef $implied_arg } UP; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 88 | ▶ | sub out_if { | ||||||||||||||||||||||||||
|
Subroutine
out_if: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | 88 | my ($key,$attr) = @_; | |||||||||||||||||||||||||||
| 33 | 88 | ▶ | if ($implied_arg->$attr) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 41 | return ($key => $implied_arg->$attr); | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | 47 | return; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 2447 | ▶ | sub in_if { | ||||||||||||||||||||||||||
|
Subroutine
in_if: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 41 | 2447 | my ($attr,$key) = @_; | |||||||||||||||||||||||||||
| 42 | 2447 | ▶ | if ($implied_arg->{$key}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 710 | return ($attr => $implied_arg->{$key}); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | 1737 | return; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 256 | ▶ | sub in_object_if { | ||||||||||||||||||||||||||
|
Subroutine
in_object_if: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | 256 | my ($attr,$key,$class) = @_; | |||||||||||||||||||||||||||
| 51 | 256 | ▶ | if ($implied_arg->{$key}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 130 | return ($attr => use_module($class)->new($implied_arg->{$key})); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | 126 | return; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 302 | ▶ | sub in_object_array_if { | ||||||||||||||||||||||||||
|
Subroutine
in_object_array_if: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 59 | 302 | my ($attr,$key,$class) = @_; | |||||||||||||||||||||||||||
| 60 | 302 | ▶ | if ($implied_arg->{$key}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 16 | my $arr = $implied_arg->{$key}; | |||||||||||||||||||||||||||
| 62 | 16 | ▶ | if (ref($arr) ne 'ARRAY') { $arr = [ $arr ] }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | return ( | ||||||||||||||||||||||||||||
| 64 | $attr => [ | ||||||||||||||||||||||||||||
| 65 | 16 | map { use_module($class)->new($_) } @$arr | |||||||||||||||||||||||||||
| 66 | ], | ||||||||||||||||||||||||||||
| 67 | ); | ||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | 286 | return; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 5 | {my $date_parser = DateTime::Format::Strptime->new( | |||||||||||||||||||||||||||
| 74 | pattern => '%Y%m%d%H%M%S', | ||||||||||||||||||||||||||||
| 75 | ); | ||||||||||||||||||||||||||||
| 76 | 1 | ▶ | sub in_datetime_if { | ||||||||||||||||||||||||||
|
Subroutine
in_datetime_if: called CC=3 SCAR=13.3
Pod
documented
| |||||||||||||||||||||||||||||
| 77 | 1 | my ($attr,$key) = @_; | |||||||||||||||||||||||||||
| 78 | 1 | ▶ | if ($implied_arg->{$key} && $implied_arg->{$key}{Date}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$implied_arg->{$key} and $implied_arg->{$key}{"Date"}
MC/DC0%0/2
$implied_arg->{$key} and $implied_arg->{$key}{"Date"}
$implied_arg->{$key}
$implied_arg->{$key}{"Date"}
Truth table33%1/3
A and B
A= $implied_arg->{$key}B= $implied_arg->{$key}{"Date"}
| |||||||||||||||||||||||||||||
| 79 | 0 | return ( $attr => $date_parser->parse_datetime($implied_arg->{$key}{Date}.$implied_arg->{$key}{Time}) ); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | 1 | return; | |||||||||||||||||||||||||||
| 82 | }} | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 5 | ▶ | sub pair_if { | ||||||||||||||||||||||||||
|
Subroutine
pair_if: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | 1047 | ▶ | return @_ if $_[1]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 658 | return; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 19 | ▶ | sub img_if { | ||||||||||||||||||||||||||
|
Subroutine
img_if: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 92 | 19 | my ($key,$hash) = @_; | |||||||||||||||||||||||||||
| 93 | 19 | ▶ | if ($hash && %{$hash}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$hash and %{$hash;}
MC/DC50%1/2
$hash and %{$hash;}
$hash
%{$hash;}
Truth table66%2/3
A and B
A= $hashB= %{$hash;}
| |||||||||||||||||||||||||||||
| 94 | 5 | require Net::Async::Webservice::UPS::Response::Image; | |||||||||||||||||||||||||||
| 95 | 5 | return ( $key => Net::Async::Webservice::UPS::Response::Image->new($hash) ) | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | 14 | return; | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 8 | ▶ | sub base64_if { | ||||||||||||||||||||||||||
|
Subroutine
base64_if: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||
| 102 | 8 | ▶ | return ($_[0],decode_base64($_[1])) if $_[1]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 8 | return; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | __END__ | ||||||||||||||||||||||||||||