| 1 | package Paws::Net::JsonResponse; | ||||||||||||||||||||||||||||||||||||
| 2 | 13 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 3 | 13 | ▶ | use JSON::MaybeXS; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 4 | 13 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 5 | 13 | ▶ | use Paws::Exception; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 6 | 13 | ▶ | use feature 'state'; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||
| 8 | 92 | ▶ | sub process { | ||||||||||||||||||||||||||||||||||
|
Subroutine
process: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 9 | 92 | my ($self, $call_object, $response) = @_; | |||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||
| 11 | 92 | ▶ | if ($response->has_header('x-amz-crc32')) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 12 | 3 | require String::CRC32; | |||||||||||||||||||||||||||||||||||
| 13 | 3 | my $crc = String::CRC32::crc32($response->content); | |||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | return Paws::Exception->new( | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 15 | code => 'Crc32Error', | ||||||||||||||||||||||||||||||||||||
| 16 | message => 'Content CRC32 mismatch', | ||||||||||||||||||||||||||||||||||||
| 17 | request_id => $response->header('x-amzn-requestid'), | ||||||||||||||||||||||||||||||||||||
| 18 | ) if ($crc != $response->header('x-amz-crc32')); | ||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||
| 21 | 92 | ▶ | if ( $response->status >= 300 ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 22 | 34 | return $self->error_to_exception($call_object, $response); | |||||||||||||||||||||||||||||||||||
| 23 | } else { | ||||||||||||||||||||||||||||||||||||
| 24 | 58 | return $self->response_to_object($call_object, $response); | |||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||
| 28 | 84 | ▶ | sub unserialize_response { | ||||||||||||||||||||||||||||||||||
|
Subroutine
unserialize_response: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 29 | 84 | my ($self, $response) = @_; | |||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||
| 31 | 84 | ▶ | return {} if (not defined $response->content or $response->content eq ''); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $response->content or $response->content eq ""
MC/DC100%2/2
not defined $response->content or $response->content eq ""
not defined $response->content
$response->content eq ""
Truth table100%3/3
not(A) or B
A= not defined $response->contentB= $response->content eq ""
| |||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||
| 33 | 73 | my $struct = eval { decode_json( $response->content ) }; | |||||||||||||||||||||||||||||||||||
| 34 | 73 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 35 | 5 | return Paws::Exception->throw( | |||||||||||||||||||||||||||||||||||
| 36 | message => $@, | ||||||||||||||||||||||||||||||||||||
| 37 | code => 'InvalidContent', | ||||||||||||||||||||||||||||||||||||
| 38 | request_id => '', | ||||||||||||||||||||||||||||||||||||
| 39 | http_status => $response->status, | ||||||||||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||
| 42 | 68 | return $struct; | |||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||
| 45 | 34 | ▶ | sub error_to_exception { | ||||||||||||||||||||||||||||||||||
|
Subroutine
error_to_exception: called CC=8 SCAR=21.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 46 | 34 | my ($self, $call_object, $response) = @_; | |||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||
| 48 | 34 | my $struct = $self->unserialize_response( $response ); | |||||||||||||||||||||||||||||||||||
| 49 | 30 | my ($message, $request_id); | |||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||
| 51 | 30 | ▶ | my $code = $struct->{__type} // 'InvalidContent'; | ||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$struct->{"__type"} // "InvalidContent"
MC/DC100%1/1
$struct->{"__type"} // "InvalidContent"
$struct->{"__type"}
Truth table100%2/2
A
A= $struct->{"__type"}
| |||||||||||||||||||||||||||||||||||||
| 52 | 30 | ▶ | if ($code =~ m/#/) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 53 | 2 | $code = (split /#/, $code)[1]; | |||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||
| 56 | 30 | ▶ | if (exists $struct->{message}){ | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 57 | 12 | ▶ | $message = $struct->{message} // ''; | ||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$struct->{"message"} // ""
MC/DC0%0/1
$struct->{"message"} // ""
$struct->{"message"}
Truth table50%1/2
A
A= $struct->{"message"}
| |||||||||||||||||||||||||||||||||||||
| 58 | } elsif (exists $struct->{Message}){ | ||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | $message = $struct->{Message} // ''; | ||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$struct->{"Message"} // ""
MC/DC0%0/1
$struct->{"Message"} // ""
$struct->{"Message"}
Truth table0%0/2
A
A= $struct->{"Message"}
| |||||||||||||||||||||||||||||||||||||
| 60 | } else { | ||||||||||||||||||||||||||||||||||||
| 61 | 18 | $message = $code; | |||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||
| 64 | 30 | ▶ | $request_id = $response->header('x-amzn-requestid') // ''; | ||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$response->header("x-amzn-requestid") // ""
MC/DC0%0/1
$response->header("x-amzn-requestid") // ""
$response->header("x-amzn-requestid")
Truth table50%1/2
A
A= $response->header("x-amzn-requestid")
| |||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||
| 66 | 30 | Paws::Exception->new( | |||||||||||||||||||||||||||||||||||
| 67 | message => $message, | ||||||||||||||||||||||||||||||||||||
| 68 | code => $code, | ||||||||||||||||||||||||||||||||||||
| 69 | request_id => $request_id, | ||||||||||||||||||||||||||||||||||||
| 70 | http_status => $response->status, | ||||||||||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||
| 74 | 4 | ▶ | sub handle_response_strtonativemap { | ||||||||||||||||||||||||||||||||||
|
Subroutine
handle_response_strtonativemap: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 75 | 4 | my ($self, $att_class, $value) = @_; | |||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||
| 77 | 4 | ▶ | if (not defined $value){ | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 78 | 0 | return $att_class->new(Map => {}); | |||||||||||||||||||||||||||||||||||
| 79 | } else { | ||||||||||||||||||||||||||||||||||||
| 80 | 4 | return $att_class->new(Map => $value); | |||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||
| 84 | 9 | ▶ | sub handle_response_strtoobjmap { | ||||||||||||||||||||||||||||||||||
|
Subroutine
handle_response_strtoobjmap: called CC=6 SCAR=18.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 85 | 9 | my ($self, $att_class, $value) = @_; | |||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||
| 87 | 9 | my $is_array = 0; | |||||||||||||||||||||||||||||||||||
| 88 | 9 | my $inner_class; | |||||||||||||||||||||||||||||||||||
| 89 | 9 | my $class = $att_class->meta->get_attribute('Map')->type_constraint->name; | |||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||
| 91 | 9 | ▶ | if (my ($array_type) = ($class =~ m/^HashRef\[ArrayRef\[(.*)\]\]$/)){ | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 92 | 3 | $inner_class = $array_type; | |||||||||||||||||||||||||||||||||||
| 93 | 3 | $is_array = 1; | |||||||||||||||||||||||||||||||||||
| 94 | } elsif (my ($inner_type) = ($class =~ m/^HashRef\[(.*)\]$/)) { | ||||||||||||||||||||||||||||||||||||
| 95 | 6 | $inner_class = $inner_type; | |||||||||||||||||||||||||||||||||||
| 96 | 6 | $is_array = 0; | |||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||
| 99 | 9 | Paws->load_class("$inner_class"); | |||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||
| 101 | 9 | ▶ | if ($is_array) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 102 | 3 | ▶ | if (not defined $value){ | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 103 | 0 | return $att_class->new(Map => {}); | |||||||||||||||||||||||||||||||||||
| 104 | } else { | ||||||||||||||||||||||||||||||||||||
| 105 | return $att_class->new(Map => { | ||||||||||||||||||||||||||||||||||||
| 106 | 3 | map { my $k = $_; ($k => [ map { $self->new_from_result_struct($inner_class, $_) } @{ $value->{ $k } } ] ) } keys %$value | |||||||||||||||||||||||||||||||||||
| 107 | }); | ||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||
| 109 | } else { | ||||||||||||||||||||||||||||||||||||
| 110 | 6 | ▶ | if (not defined $value){ | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 111 | 0 | return $att_class->new(Map => {}); | |||||||||||||||||||||||||||||||||||
| 112 | } else { | ||||||||||||||||||||||||||||||||||||
| 113 | return $att_class->new(Map => { | ||||||||||||||||||||||||||||||||||||
| 114 | 6 | map { ($_ => $self->new_from_result_struct($inner_class, $value->{ $_ }) ) } keys %$value | |||||||||||||||||||||||||||||||||||
| 115 | }); | ||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||
| 120 | 115 | ▶ | sub new_from_result_struct { | ||||||||||||||||||||||||||||||||||
|
Subroutine
new_from_result_struct: called CC=39 SCAR=39.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 121 | 115 | my ($self, $class, $result) = @_; | |||||||||||||||||||||||||||||||||||
| 122 | 115 | my %args; | |||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||
| 124 | 115 | ▶ | if (do { state %d; $d{$class} //= $class->does('Paws::API::StrToObjMapParser')}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$d{$class} //= $class->does("Paws::API::StrToObjMapParser")
MC/DC0%0/2
$d{$class} //= $class->does("Paws::API::StrToObjMapParser")
$d{$class}
$class->does("Paws::API::StrToObjMapParser")
Truth table66%2/3
A //= B
A= $d{$class}B= $class->does("Paws::API::StrToObjMapParser")
| |||||||||||||||||||||||||||||||||||||
| 125 | 2 | return $self->handle_response_strtoobjmap($class, $result); | |||||||||||||||||||||||||||||||||||
| 126 | 113 | ▶ | } elsif (do { state %d; $d{$class} //= $class->does('Paws::API::StrToNativeMapParser')}) { | ||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$d{$class} //= $class->does("Paws::API::StrToNativeMapParser")
MC/DC0%0/2
$d{$class} //= $class->does("Paws::API::StrToNativeMapParser")
$d{$class}
$class->does("Paws::API::StrToNativeMapParser")
Truth table66%2/3
A //= B
A= $d{$class}B= $class->does("Paws::API::StrToNativeMapParser")
| |||||||||||||||||||||||||||||||||||||
| 127 | 0 | return $self->handle_response_strtonativemap($class, $result); | |||||||||||||||||||||||||||||||||||
| 128 | } else { | ||||||||||||||||||||||||||||||||||||
| 129 | 113 | ▶ | foreach my $att (do { state %d; @{$d{$class} //= [$class->meta->get_attribute_list]}}) { | ||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$d{$class} //= [$class->meta->get_attribute_list]
MC/DC100%1/1
$d{$class} //= [$class->meta->get_attribute_list]
$d{$class}
Truth table100%2/2
A
A= $d{$class}
| |||||||||||||||||||||||||||||||||||||
| 130 | 731 | ▶ | next if (not my $meta = do { state %d; exists $d{$class}{$att} ? $d{$class}{$att} : $d{$class}{$att} = $class->meta->get_attribute($att)}); | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||
| 132 | 731 | ▶ | my $key = do { state %d; $d{$class}{$att} //= $meta->does('NameInRequest') } ? $meta->request_name : | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$d{$class}{$att} //= $meta->does("NameInRequest")
MC/DC0%0/2
$d{$class}{$att} //= $meta->does("NameInRequest")
$d{$class}{$att}
$meta->does("NameInRequest")
Truth table66%2/3
A //= B
A= $d{$class}{$att}B= $meta->does("NameInRequest")
| |||||||||||||||||||||||||||||||||||||
| 133 | 731 | ▶ | do { state %d; $d{$class}{$att} //= $meta->does('ParamInHeader') } ? lc($meta->header_name) : $att; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$d{$class}{$att} //= $meta->does("ParamInHeader")
MC/DC0%0/2
$d{$class}{$att} //= $meta->does("ParamInHeader")
$d{$class}{$att}
$meta->does("ParamInHeader")
Truth table66%2/3
A //= B
A= $d{$class}{$att}B= $meta->does("ParamInHeader")
| |||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||
| 135 | 731 | my $att_type = $meta->type_constraint; | |||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||
| 137 | # use Data::Dumper; | ||||||||||||||||||||||||||||||||||||
| 138 | # print STDERR "USING KEY: $key\n"; | ||||||||||||||||||||||||||||||||||||
| 139 | # print STDERR "$att IS A '$att_type' TYPE\n"; | ||||||||||||||||||||||||||||||||||||
| 140 | # print STDERR "VALUE: " . Dumper($result); | ||||||||||||||||||||||||||||||||||||
| 141 | # my $extracted_val = $result->{ $key }; | ||||||||||||||||||||||||||||||||||||
| 142 | # print STDERR "RESULT >>> $extracted_val\n"; | ||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||
| 144 | # We'll consider that an attribute without brackets [] isn't an array type | ||||||||||||||||||||||||||||||||||||
| 145 | 731 | ▶ | if ($att_type !~ m/\[.*\]$/) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 146 | 575 | my $value = $result->{ $key }; | |||||||||||||||||||||||||||||||||||
| 147 | 575 | my $value_ref = ref($value); | |||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||
| 149 | 575 | ▶ | if ($att_type =~ m/\:\:/) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 150 | # Make the att_type stringify for module loading | ||||||||||||||||||||||||||||||||||||
| 151 | 130 | Paws->load_class("$att_type"); | |||||||||||||||||||||||||||||||||||
| 152 | 130 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 153 | 29 | ▶ | if (not $value_ref) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 154 | 0 | $args{ $att } = $value; | |||||||||||||||||||||||||||||||||||
| 155 | } else { | ||||||||||||||||||||||||||||||||||||
| 156 | 29 | my $att_class = $att_type->class; | |||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||
| 158 | 29 | ▶ | if (do { state %d; $d{$att_class} //= $att_class->does('Paws::API::StrToObjMapParser')}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
$d{$att_class} //= $att_class->does("Paws::API::StrToObjMapParser")
MC/DC0%0/2
$d{$att_class} //= $att_class->does("Paws::API::StrToObjMapParser")
$d{$att_class}
$att_class->does("Paws::API::StrToObjMapParser")
Truth table66%2/3
A //= B
A= $d{$att_class}B= $att_class->does("Paws::API::StrToObjMapParser")
| |||||||||||||||||||||||||||||||||||||
| 159 | 6 | $args{ $att } = $self->handle_response_strtoobjmap($att_class, $value); | |||||||||||||||||||||||||||||||||||
| 160 | 23 | ▶ | } elsif (do { state %d; $d{$att_class} //= $att_class->does('Paws::API::StrToNativeMapParser')}) { | ||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$d{$att_class} //= $att_class->does("Paws::API::StrToNativeMapParser")
MC/DC0%0/2
$d{$att_class} //= $att_class->does("Paws::API::StrToNativeMapParser")
$d{$att_class}
$att_class->does("Paws::API::StrToNativeMapParser")
Truth table66%2/3
A //= B
A= $d{$att_class}B= $att_class->does("Paws::API::StrToNativeMapParser")
| |||||||||||||||||||||||||||||||||||||
| 161 | 4 | $args{ $att } = $self->handle_response_strtonativemap($att_class, $value); | |||||||||||||||||||||||||||||||||||
| 162 | 19 | ▶ | } elsif (do { state %d; $d{$att_class} //= $att_class->does('Paws::API::MapParser')}) { | ||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$d{$att_class} //= $att_class->does("Paws::API::MapParser")
MC/DC0%0/2
$d{$att_class} //= $att_class->does("Paws::API::MapParser")
$d{$att_class}
$att_class->does("Paws::API::MapParser")
Truth table66%2/3
A //= B
A= $d{$att_class}B= $att_class->does("Paws::API::MapParser")
| |||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $xml_keys = $att_class->xml_keys; | |||||||||||||||||||||||||||||||||||
| 164 | 0 | my $xml_values = $att_class->xml_values; | |||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||
| 166 | 0 | $args{ $att } = $att_class->new(map { ($_->{ $xml_keys } => $_->{ $xml_values }) } @$value); | |||||||||||||||||||||||||||||||||||
| 167 | } else { | ||||||||||||||||||||||||||||||||||||
| 168 | 19 | $args{ $att } = $self->new_from_result_struct($att_class, $value); | |||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||
| 172 | } else { | ||||||||||||||||||||||||||||||||||||
| 173 | 445 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 174 | 253 | ▶ | if ($att_type eq 'Bool') { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 175 | 9 | ▶ | if ($value eq 'true') { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||
| 176 | 8 | $args{ $att } = 1; | |||||||||||||||||||||||||||||||||||
| 177 | } elsif ($value eq 'false') { | ||||||||||||||||||||||||||||||||||||
| 178 | 1 | $args{ $att } = 0; | |||||||||||||||||||||||||||||||||||
| 179 | } elsif ($value == 1) { | ||||||||||||||||||||||||||||||||||||
| 180 | 0 | $args{ $att } = 1; | |||||||||||||||||||||||||||||||||||
| 181 | } else { | ||||||||||||||||||||||||||||||||||||
| 182 | 0 | $args{ $att } = 0; | |||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||
| 184 | } else { | ||||||||||||||||||||||||||||||||||||
| 185 | 244 | $args{ $att } = $value; | |||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||
| 189 | } elsif (my ($type) = ($att_type =~ m/^ArrayRef\[(.*)\]$/)) { | ||||||||||||||||||||||||||||||||||||
| 190 | 118 | my $value = $result->{ $att }; | |||||||||||||||||||||||||||||||||||
| 191 | 118 | ▶ | $value = $result->{ $key } if (not defined $value and $key ne $att); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $value and $key ne $att
MC/DC100%2/2
not defined $value and $key ne $att
not defined $value
$key ne $att
Truth table100%3/3
not(A) and B
A= not defined $valueB= $key ne $att
| |||||||||||||||||||||||||||||||||||||
| 192 | 118 | my $value_ref = ref($value); | |||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||
| 194 | 118 | ▶ | if ($type =~ m/\:\:/) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 195 | 71 | Paws->load_class($type); | |||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||
| 197 | 71 | ▶ | if (do { state %d; $d{$type} //= $type->does('Paws::API::StrToObjMapParser')}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
$d{$type} //= $type->does("Paws::API::StrToObjMapParser")
MC/DC0%0/2
$d{$type} //= $type->does("Paws::API::StrToObjMapParser")
$d{$type}
$type->does("Paws::API::StrToObjMapParser")
Truth table66%2/3
A //= B
A= $d{$type}B= $type->does("Paws::API::StrToObjMapParser")
| |||||||||||||||||||||||||||||||||||||
| 198 | 2 | $args{ $att } = [ map { $self->handle_response_strtoobjmap($type, $_) } @$value ]; | |||||||||||||||||||||||||||||||||||
| 199 | 69 | ▶ | } elsif (do { state %d; $d{$type} //= $type->does('Paws::API::StrToNativeMapParser')}) { | ||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$d{$type} //= $type->does("Paws::API::StrToNativeMapParser")
MC/DC0%0/2
$d{$type} //= $type->does("Paws::API::StrToNativeMapParser")
$d{$type}
$type->does("Paws::API::StrToNativeMapParser")
Truth table66%2/3
A //= B
A= $d{$type}B= $type->does("Paws::API::StrToNativeMapParser")
| |||||||||||||||||||||||||||||||||||||
| 200 | 0 | $args{ $att } = [ map { $self->handle_response_strtonativemap($type, $_) } @$value ]; | |||||||||||||||||||||||||||||||||||
| 201 | 69 | ▶ | } elsif (do { state %d; $d{$type} //= $type->does('Paws::API::MapParser')}) { | ||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$d{$type} //= $type->does("Paws::API::MapParser")
MC/DC0%0/2
$d{$type} //= $type->does("Paws::API::MapParser")
$d{$type}
$type->does("Paws::API::MapParser")
Truth table66%2/3
A //= B
A= $d{$type}B= $type->does("Paws::API::MapParser")
| |||||||||||||||||||||||||||||||||||||
| 202 | 0 | die "MapParser Type in an Array. Please implement me"; | |||||||||||||||||||||||||||||||||||
| 203 | } else { | ||||||||||||||||||||||||||||||||||||
| 204 | 69 | $args{ $att } = [ map { $self->new_from_result_struct($type, $_) } @$value ]; | |||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||
| 206 | } else { | ||||||||||||||||||||||||||||||||||||
| 207 | 47 | ▶ | if (defined $value){ | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 208 | 5 | $args{ $att } = $value; | |||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||
| 213 | 113 | $class->new(%args); | |||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||
| 217 | 58 | ▶ | sub response_to_object { | ||||||||||||||||||||||||||||||||||
|
Subroutine
response_to_object: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 218 | 58 | my ($self, $call_object, $response) = @_; | |||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||
| 220 | 58 | $call_object = $call_object->meta->name; | |||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||
| 222 | 58 | ▶ | my $returns = (defined $call_object->_returns) && ($call_object->_returns ne 'Paws::API::Response'); | ||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $call_object->_returns && $call_object->_returns ne 'Paws::API::Response'
MC/DC50%1/2
defined $call_object->_returns && $call_object->_returns ne 'Paws::API::Response'
defined $call_object->_returns
$call_object->_returns ne 'Paws::API::Response'
Truth table66%2/3
A && B
A= defined $call_object->_returnsB= $call_object->_returns ne 'Paws::API::Response'
| |||||||||||||||||||||||||||||||||||||
| 223 | 58 | ▶ | my $ret_class = $returns ? $call_object->_returns : 'Paws::API::Response'; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 224 | 58 | Paws->load_class($ret_class); | |||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||
| 226 | 58 | my $headers = $response->headers; | |||||||||||||||||||||||||||||||||||
| 227 | 58 | ▶ | my $request_id = $headers->{'x-amz-request-id'} || $headers->{'x-amzn-requestid'}; | ||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$headers->{'x-amz-request-id'} || $headers->{'x-amzn-requestid'}
MC/DC100%2/2
$headers->{'x-amz-request-id'} || $headers->{'x-amzn-requestid'}
$headers->{'x-amz-request-id'}
$headers->{'x-amzn-requestid'}
Truth table100%3/3
A || B
A= $headers->{'x-amz-request-id'}B= $headers->{'x-amzn-requestid'}
| |||||||||||||||||||||||||||||||||||||
| 228 | # AWS has sent duplicate headers x-amx-request-id headers on some services. See issue 324 for more info | ||||||||||||||||||||||||||||||||||||
| 229 | 58 | ▶ | $request_id = (ref($request_id) eq 'ARRAY') ? $request_id->[0] : $request_id; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||
| 231 | 58 | ▶ | return Paws::API::Response->new(_request_id => $request_id) if (not $returns); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||
| 233 | 50 | my $unserialized_struct = $self->unserialize_response( $response ); | |||||||||||||||||||||||||||||||||||
| 234 | 49 | $unserialized_struct->{ _request_id } = $request_id; | |||||||||||||||||||||||||||||||||||
| 235 | 49 | my $o_result = $self->new_from_result_struct($call_object->_returns, $unserialized_struct); | |||||||||||||||||||||||||||||||||||
| 236 | 49 | return $o_result; | |||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||
| 239 | 13 | 1; | |||||||||||||||||||||||||||||||||||