blib/lib/Paws/Net/QueryCaller.pm

filter: Statementstmt 100% 87 / 87 Branchbran 93.3% 28 / 30 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 3 totaltotal 96.1% 125 / 130 CC 22 SCAR 25.0
CC
22
Cov
98%
_to_querycaller_params
19.0
generate_content_from_parameters
2.0
array_flatten_string
2.0
CRAP 12.2
« blib/lib/Paws/Net/JsonCaller.pm ↑ Summary blib/lib/Paws/MQ.pm »
1 package Paws::Net::QueryCaller;
2 12 ▶ use Paws;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 12 ▶ use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶ use HTTP::Request::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶ use POSIX qw(strftime);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 12 ▶ use Paws::Net::XMLResponse;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 has response_to_object => (
10 is => 'ro',
11 262 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
12 262 Paws::Net::XMLResponse->new;
13 }
14 12 );
15  
16 19 ▶ sub array_flatten_string {
Subroutine array_flatten_string: called CC=2 SCAR=6.9
Pod undocumented
17 19 my $self = shift;
18 19 ▶ return ($self->flattened_arrays)?'%s.%d':'%s.member.%d';
Branch: 1 branch
BranchTrueFalseTotal
$self->flattened_arrays ? : 8 11 19
19 }
20  
21 # converts the objects that represent the call into parameters that the API can understand
22 35 ▶ sub _to_querycaller_params {
Subroutine _to_querycaller_params: called CC=19 SCAR=29.4
23 35 my ($self, $params) = @_;
24 35 my %p;
25 35 foreach my $att (grep { $_ !~ m/^_/ } $params->meta->get_attribute_list) {
26 161 ▶ my $key = $params->meta->get_attribute($att)->does('Paws::API::Attribute::Trait::NameInRequest')?$params->meta->get_attribute($att)->request_name:$att;
Branch: 1 branch
BranchTrueFalseTotal
$params->meta->get_attribute($att)->does('Paws::API::Attribute::Trait::NameInRequest') ? : 9 152 161
27 161 ▶ if (defined $params->$att) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params->$att) 57 104 161
28 57 my $att_type = $params->meta->get_attribute($att)->type_constraint;
29  
30 57 ▶ if (Paws->is_internal_type($att_type)) {
Branch: 5 branches
BranchTrueFalseTotal
if ('Paws'->is_internal_type($att_type)) { } 37 20 57
elsif ($att_type =~ /^ArrayRef\[(.*)\]/) { } 10 10 20
elsif ($params->$att->does('Paws::API::StrToObjMapParser')) { } 1 9 10
elsif ($params->$att->does('Paws::API::StrToNativeMapParser')) { } 1 8 9
elsif ($params->$att->does('Paws::API::MapParser')) { } 1 7 8
31 37 ▶ if ($att_type eq 'Bool') {
Branch: 1 branch
BranchTrueFalseTotal
if ($att_type eq 'Bool') { } 1 36 37
32 1 ▶ $p{ $key } = ($params->{$att} == 1) ? 'true' : 'false';
Branch: 1 branch
BranchTrueFalseTotal
$params->{$att} == 1 ? : 1 0 1
33 } else {
34 36 $p{ $key } = $params->{$att};
35 }
36 } elsif ($att_type =~ m/^ArrayRef\[(.*)\]/) {
37 10 ▶ if (scalar @{ $params->$att } == 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @{$params->$att;} == 0) { } 1 9 10
elsif ('Paws'->is_internal_type("$1")) { } 7 2 9
38 1 $p{ $att } = '';
39 } elsif (Paws->is_internal_type("$1")){
40 7 my $i = 1;
41 7 foreach my $value (@{ $params->$att }){
42 9 $p{ sprintf($self->array_flatten_string, $key, $i) } = $value;
43 9 $i++
44 }
45 } else {
46 2 my $i = 1;
47 2 foreach my $value (@{ $params->$att }){
48 3 my %complex_value = $self->_to_querycaller_params($value);
49 3 map { $p{ sprintf($self->array_flatten_string . ".%s", $key, $i, $_) } = $complex_value{$_} } keys %complex_value;
50 3 $i++
51 }
52 }
53 } elsif ($params->$att->does('Paws::API::StrToObjMapParser')) {
54 1 my $i = 1;
55 1 foreach my $map_key (keys %{ $params->$att->Map }){
56 1 $p{ "$key.$i.Name" } = $map_key;
57 1 my %complex_value = $self->_to_querycaller_params($params->$att->Map->{ $map_key });
58 1 map { $p{ "$key.$i.Value.$_" } = $complex_value{$_} } keys %complex_value;
59 1 $i++;
60 }
61 } elsif ($params->$att->does('Paws::API::StrToNativeMapParser')) {
62 1 my $i = 1;
63 1 foreach my $map_key (keys %{ $params->$att->Map }){
64 1 $p{ "$key.entry.$i.key" } = $map_key;
65 1 $p{ "$key.entry.$i.value" } = $params->$att->Map->{ $map_key };
66 1 $i++;
67 }
68 } elsif ($params->$att->does('Paws::API::MapParser')){
69 1 my $i = 1;
70 1 foreach my $map_key (sort $params->$att->meta->get_attribute_list){
71 20 ▶ next if (not defined $params->$att->$map_key);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $params->$att->$map_key 17 3 20
72 3 $p{ "$key.$i.Name" } = $map_key;
73 3 $p{ "$key.$i.Value" } = $params->$att->$map_key;
74 3 $i++;
75 }
76 } else {
77 7 my %complex_value = $self->_to_querycaller_params($params->$att);
78 7 map { $p{ "$key.$_" } = $complex_value{$_} } keys %complex_value;
79 }
80 }
81 }
82 35 return %p;
83 }
84  
85 24 ▶ sub generate_content_from_parameters {
Subroutine generate_content_from_parameters: called CC=2 SCAR=7.0
Pod undocumented
86 24 my ($self, $request) = @_;
87  
88 24 $request->headers->content_type('application/x-www-form-urlencoded');
89 24 my $url = URI->new('http:');
90 24 $url->query_form($request->parameters);
91 24 my $content = $url->query;
92 # HTML/4.01 says that line breaks are represented as "CR LF" pairs (i.e., `%0D%0A')
93 24 ▶ $content =~ s/(?<!%0D)%0A/%0D%0A/g if (defined $content);
Branch: 1 branch
BranchTrueFalseTotal
if defined $content 24 0 24
94 24 return $content;
95 }
96  
97 24 ▶ sub prepare_request_for_call {
Subroutine prepare_request_for_call: called CC=2 SCAR=6.9
Pod undocumented
98 24 my ($self, $call) = @_;
99  
100 24 my $request = Paws::Net::APIRequest->new();
101  
102 24 $request->url($self->_api_endpoint . '/');
103 24 $request->uri('/');
104 24 $request->method('POST');
105  
106 24 $request->parameters({ Action => $call->_api_call,
107 Version => $self->version,
108 $self->_to_querycaller_params($call)
109 });
110  
111 24 ▶ if (not $self->does('Paws::Net::V2Signature')){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->does("Paws::Net::V2Signature")) 22 2 24
112 22 $request->content($self->generate_content_from_parameters($request));
113 }
114  
115 24 $self->sign($request);
116  
117 24 return $request;
118 }
119 12 1;
« blib/lib/Paws/Net/JsonCaller.pm ↑ Summary blib/lib/Paws/MQ.pm »