blib/lib/IO/Iron/Connector.pm

filter: Statementstmt 33.1% 75 / 226 Branchbran 0.0% 0 / 56 Conditioncond 0.0% 0 / 33 MC/DCmcdc 0.0% 0 / 19 Subroutinesub 79.1% 19 / 24 Podpod 100% 3 / 3 totaltotal 26.8% 97 / 361 SCAR 68.0
CC
44
Cov
24%
perform_http_action
272.0
__ANON__
210.0
perform_iron_action
132.0
CRAP 900.3
↑ Summary blib/lib/IO/Iron/IronMQ/Client.pm »
1 package IO::Iron::Connector;
2  
3 ## no critic (Documentation::RequirePodAtEnd)
4 ## no critic (Documentation::RequirePodSections)
5 ## no critic (RegularExpressions::RequireExtendedFormatting)
6 ## no critic (RegularExpressions::RequireLineBoundaryMatching)
7 ## no critic (RegularExpressions::ProhibitEscapedMetacharacters)
8  
9 3 ▶use 5.010_000;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # Global creator
14 BEGIN {
15 3 ▶ use parent qw( IO::Iron::ConnectorBase ); # Inheritance
Subroutine BEGIN: called CC=1 SCAR=0.0
16 }
17  
18 # Global destructor
19 ▶END {
Subroutine END: called CC=1 SCAR=0.0
20 }
21  
22  
23 # ABSTRACT: REST API Connector, HTTP interface class.
24  
25 3 our $VERSION = '0.13'; # VERSION: generated by DZP::OurPkgVersion
26  
27  
28  
29 3 ▶use Log::Any qw{$log};
Subroutine BEGIN: called CC=1 SCAR=0.0
30 3 require JSON::MaybeXS;
31 3 ▶use Data::UUID ();
Subroutine BEGIN: called CC=1 SCAR=0.0
32 3 ▶use Hash::Util 0.06 qw{lock_keys lock_keys_plus unlock_keys legal_keys};
Subroutine BEGIN: called CC=1 SCAR=0.0
33 3 ▶use Carp::Assert;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 3 ▶use Carp::Assert::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 3 ▶use English '-no_match_vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
37 3 ▶use REST::Client ();
Subroutine BEGIN: called CC=1 SCAR=0.0
38 3 ▶use URI::Escape qw{uri_escape_utf8};
Subroutine BEGIN: called CC=1 SCAR=0.0
39 3 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 3 ▶use Scalar::Util qw{blessed looks_like_number};
Subroutine BEGIN: called CC=1 SCAR=0.0
41 use Exception::Class (
42 3 'IronHTTPCallException' => {
43 fields => ['status_code', 'response_message'],
44 }
45 3 ▶ );
Subroutine BEGIN: called CC=1 SCAR=0.0
46  
47 # CONSTANTS
48  
49 3 ▶use Const::Fast;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 3 const my $HTTP_CODE_OK_MIN => 200;
51 3 const my $HTTP_CODE_OK_MAX => 299;
52 3 const my $HTTP_CODE_SERVICE_UNAVAILABLE => 503;
53 3 const my $HTTP_CONTENT_TYPE_JSON => q{application/json; charset=utf-8};
54  
55  
56 sub new {
57 3 ▶ my ($class) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
58 3 $log->tracef('Entering new(%s)', $class);
59 3 my $self = IO::Iron::ConnectorBase->new();
60 # Add more keys to the self hash.
61 my @self_keys = (
62 'client', # REST client timeout (for REST calls accessing Iron services).
63 'mime_boundary', # The boundary string separating parts in multipart REST messages.
64 3 legal_keys(%{$self}),
65 );
66 3 unlock_keys(%{$self});
67 3 bless $self, $class;
68 3 lock_keys(%{$self}, @self_keys);
69  
70 # Set up REST client
71 3 my $client = REST::Client->new();
72 3 $self->{'client'} = $client;
73  
74 # Create MIME multipart message boundary string
75 3 my $ug = Data::UUID->new();
76 3 my $uuid1 = $ug->create();
77 3 $self->{'mime_boundary'} = 'MIME_BOUNDARY_' . (substr $ug->to_string($uuid1), 1, 20); ## no critic (ValuesAndExpressions::ProhibitMagicNumbers)
78  
79 3 $log->infof('Iron Connector created with REST::Client as HTTP user agent.');
80 3 $log->tracef('Exiting new: %s', $self);
81 3 return $self;
82 }
83  
84  
85 # TODO check why previous message (coded content) is in the next message!
86 sub perform_iron_action { ## no critic (Subroutines::ProhibitExcessComplexity)
87 0 ▶ my ($self, $iron_action, $params) = @_;
Subroutine perform_iron_action: not called CC=11 SCAR=48.8
Pod documented
88 0 ▶ if(!defined $params) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $params) 0 0 0
89 0 $params = {};
90 }
91 0 $log->tracef('Entering Connector:perform_iron_action(%s, %s)', $iron_action, $params);
92  
93 0 my $href = $iron_action->{'href'};
94 0 my $action_verb = $iron_action->{'action'};
95 0 my $return_type = $iron_action->{'return'};
96 0 my $retry = $iron_action->{'retry'};
97 0 my $require_body = $iron_action->{'require_body'};
98 0 ▶ my $paged = $iron_action->{'paged'} ? $iron_action->{'paged'} : 0;
Branch: 1 branch
BranchTrueFalseTotal
$iron_action->{'paged'} ? : 0 0 0
99 0 ▶ my $per_page = $iron_action->{'per_page'} ? $iron_action->{'per_page'} : 0;
Branch: 1 branch
BranchTrueFalseTotal
$iron_action->{'per_page'} ? : 0 0 0
100 0 my $url_params = q{};
101 0 ▶ if(exists $iron_action->{'url_params'} && ref $iron_action->{'url_params'} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $iron_action->{"url_params"} and ref $iron_action->{"url_params"} eq "HASH") 0 0 0
Condition0%0/3
exists $iron_action->{"url_params"} and ref $iron_action->{"url_params"} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $iron_action->{"url_params"} and ref $iron_action->{"url_params"} eq "HASH"
exists $iron_action->{"url_params"} ref $iron_action->{"url_params"} eq "HASH"
Truth table0%0/3
A and B
A= exists $iron_action->{"url_params"}B= ref $iron_action->{"url_params"} eq "HASH"
ABresult
0X0
100
111
102 0 foreach (keys %{$iron_action->{'url_params'}}) {
103 0 $log->tracef('perform_iron_action(): url_param:%s', $_);
104 0 ▶ if ($params->{'{'.$_.'}'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$params{'{' . $_ . '}'}) 0 0 0
105 0 $url_params .= "$_={$_}&";
106 }
107 }
108 0 $url_params = substr $url_params, 0, (length $url_params) - 1;
109 }
110 0 ▶ if ($url_params) {
Branch: 1 branch
BranchTrueFalseTotal
if ($url_params) 0 0 0
111 0 $href .= (q{?} . $url_params);
112 }
113 0 my $content_type = $iron_action->{'content_type'};
114 0 $params->{'content_type'} = $content_type;
115 0 $params->{'return_type'} = $return_type;
116 0 $log->tracef('href before value substitution:\'%s\'.', $href);
117 0 foreach my $value_key (sort keys %{$params}) {
118 0 my $value = $params->{$value_key};
119 0 $log->tracef('Param key:%s; value=%s;', $value_key, $value);
120 0 $href =~ s/$value_key/$value/gs;
121 };
122 0 $log->tracef('href after value substitution:\'%s\'.', $href);
123  
124 0 my ($http_status_code, $returned_msg);
125 0 my $keep_on_trying = 1;
126 0 ▶ while($keep_on_trying) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep_on_trying) 0 0 0
127 0 $keep_on_trying = 0;
128 try {
129 assert(
130 ($require_body == 1 && defined $params->{'body'} && ref $params->{'body'} eq 'HASH')
131 0 ▶ || ($require_body == 0 && !defined $params->{'body'})
Subroutine __ANON__: not called CC=14 SCAR=53.5
Condition0%0/12
$require_body == 1 && defined $params->{'body'} && ref $params->{'body'} eq 'HASH' || $require_body == 0 && !defined($params->{'body'})
l!l&&r!l&&!r
000
$require_body == 1 and defined $params->{"body"} and ref $params->{"body"} eq "HASH"
!ll&&!rl&&r
000
$require_body == 1 and defined $params->{"body"}
!ll&&!rl&&r
000
$require_body == 0 and not defined $params->{"body"}
!ll&&!rl&&r
000
MC/DC0%0/5
$require_body == 1 && defined $params->{'body'} && ref $params->{'body'} eq 'HASH' || $require_body == 0 && !defined($params->{'body'})
$require_body == 1 defined $params->{"body"} ref $params->{"body"} eq "HASH" $require_body == 0 not defined $params->{"body"}
Truth table0%0/10
A and B and C || D and not(E)
A= $require_body == 1B= defined $params->{"body"}C= ref $params->{"body"} eq "HASH"D= $require_body == 0E= not defined $params->{"body"}
ABCDEresult
111XX1
0XX111
10X111
110111
0XX0X0
0XX100
10X0X0
10X100
1100X0
110100
132 );
133 0 assert_in($action_verb, ['GET','PATCH','PUT','POST','DELETE','OPTIONS','HEAD'], 'action_verb is a valid HTTP verb.');
134 0 assert_nonblank( $params->{'{Protocol}'}, 'params->{Protocol} is defined and not blank.' );
135 0 assert_nonblank( $params->{'{Port}'}, 'params->{Port} is defined and not blank.' );
136 0 assert_nonblank( $params->{'{Host}'}, 'params->{Host} is defined and not blank.' );
137 0 assert_nonblank( $params->{'{Project ID}'}, 'params->{Project ID} is defined and not blank.' );
138 0 assert_nonblank( $params->{'{API Version}'}, 'params->{API Version} is defined and not blank.' );
139 0 assert_nonblank( $params->{'authorization_token'}, 'params->{authorization_token} is defined and not blank.' );
140 0 assert_nonblank( $params->{'http_client_timeout'}, 'params->{http_client_timeout} is defined and not blank.' );
141 0 ▶ my $url_escape_these_fields = defined $iron_action->{'url_escape'} ? $iron_action->{'url_escape'} : {};
Branch: 1 branch
BranchTrueFalseTotal
defined $iron_action->{'url_escape'} ? : 0 0 0
142 0 foreach my $field_name (keys %{$url_escape_these_fields}) {
143 0 ▶ if (defined $params->{$field_name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params->{$field_name}) 0 0 0
144 0 $params->{$field_name} = uri_escape_utf8($params->{$field_name});
145 }
146 }
147 #
148 0 ▶ if($paged) {
Branch: 1 branch
BranchTrueFalseTotal
if ($paged) { } 0 0 0
149 0 $log->debugf('A paged query.');
150 0 my @returned_msgs;
151 0 my ($http_status_code_temp, $returned_msg_temp);
152 0 my $page_number = 0;
153 0 while(1) {
154 0 my $page_href = $href;
155 0 $log->debugf('A paged query. Href:\'%s\'', $page_href);
156 0 ▶ $page_href .= ($href =~ /\?/gsx ? q{&} : q{?}) . 'per_page='.$per_page.'&page='.$page_number;
Branch: 1 branch
BranchTrueFalseTotal
$href =~ /\?/gsx ? : 0 0 0
157 0 ($http_status_code_temp, $returned_msg_temp) =
158 $self->perform_http_action($action_verb, $page_href, $params);
159 0 my $return_list = $returned_msg_temp;
160 0 my ($return_type_def, $list_hash_key) = (split m/:/s, $return_type);
161 0 ▶ $return_list = $returned_msg_temp->{$list_hash_key}
Branch: 1 branch
BranchTrueFalseTotal
if $return_type_def eq "LIST" and defined $list_hash_key 0 0 0
Condition0%0/3
$return_type_def eq "LIST" and defined $list_hash_key
!ll&&!rl&&r
000
MC/DC0%0/2
$return_type_def eq "LIST" and defined $list_hash_key
$return_type_def eq "LIST" defined $list_hash_key
Truth table0%0/3
A and B
A= $return_type_def eq "LIST"B= defined $list_hash_key
ABresult
0X0
100
111
162 if $return_type_def eq 'LIST' && defined $list_hash_key; ## no critic (ControlStructures::ProhibitPostfixControls)
163 0 push @returned_msgs, @{$return_list};
164 0 ▶ if( scalar @{$return_list} == 0 || @{$return_list} < $per_page ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$return_list;} == 0 or @{$return_list;} < $per_page) 0 0 0
Condition0%0/3
scalar @{$return_list;} == 0 or @{$return_list;} < $per_page
l!l&&r!l&&!r
000
MC/DC0%0/2
scalar @{$return_list;} == 0 or @{$return_list;} < $per_page
scalar @{$return_list;} == 0 @{$return_list;} < $per_page
Truth table0%0/3
A or B
A= scalar @{$return_list;} == 0B= @{$return_list;} < $per_page
ABresult
1X1
011
000
165 0 last;
166 }
167 0 $page_number++;
168 }
169 0 $http_status_code = $http_status_code_temp;
170 0 $returned_msg = \@returned_msgs;
171 }
172 else {
173 0 ($http_status_code, $returned_msg) = $self->perform_http_action($action_verb, $href, $params);
174 }
175 }
176 catch {
177 0 ▶ $log->debugf('perform_iron_action(): Caught exception:\'%s\'.', $_);
Subroutine __ANON__: not called CC=6 SCAR=37.4
178 0 ▶ croak $_ unless blessed $_ && $_->can('rethrow'); ## no critic (ControlStructures::ProhibitPostfixControls)
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($_) and $_->can("rethrow") 0 0 0
Condition0%0/3
builtin::blessed($_) and $_->can("rethrow")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($_) and $_->can("rethrow")
builtin::blessed($_) $_->can("rethrow")
Truth table0%0/3
A and B
A= builtin::blessed($_)B= $_->can("rethrow")
ABresult
0X0
100
111
179 0 ▶ if ( $_->isa('IronHTTPCallException') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->isa('IronHTTPCallException')) { } 0 0 0
180 0 ▶ if( $_->status_code == $HTTP_CODE_SERVICE_UNAVAILABLE ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->status_code == $HTTP_CODE_SERVICE_UNAVAILABLE) { } 0 0 0
181 # 503 Service Unavailable. Clients should implement exponential backoff to retry the request.
182 0 ▶ $keep_on_trying = 1 if ($retry == 1); ## no critic (ControlStructures::ProhibitPostfixControls)
Branch: 1 branch
BranchTrueFalseTotal
if $retry == 1 0 0 0
183 # TODO Fix this temporary solution for backoff to retry the request.
184 }
185 else {
186 0 $log->debugf('perform_iron_action(): rethrow the exception.', $_);
187 0 $_->rethrow;
188 }
189 }
190 else {
191 0 $_->rethrow;
192 }
193 0 };
194 # Module::Pluggable here?
195 }
196 0 $log->tracef('Exiting Connector:perform_iron_action(): %s', $returned_msg );
197 0 return $http_status_code, $returned_msg;
198 }
199  
200  
201  
202 sub perform_http_action {
203 0 ▶ my ($self, $action_verb, $href, $params) = @_;
Subroutine perform_http_action: not called CC=16 SCAR=56.1
Pod documented
204 0 my $client = $self->{'client'};
205 0 my $json = JSON::MaybeXS->new(utf8 => 1, pretty => 1);
206 # TODO assert href is URL
207 0 assert_in($action_verb, ['GET','PATCH','PUT','POST','DELETE','OPTIONS','HEAD'], 'action_verb is a valid HTTP verb.');
208 0 assert_exists($params, ['http_client_timeout', 'authorization_token'], 'params contains items http_client_timeout and authorization_token.');
209 0 assert_integer($params->{'http_client_timeout'}, 'params->{\'http_client_timeout\'} is integer.');
210 0 assert_nonblank($params->{'authorization_token'}, 'params->{\'authorization_token\'} is a non-blank string.');
211 0 $log->tracef('Entering Connector:perform_http_action(%s, %s, %s)', $action_verb, $href, $params);
212 #
213 # HTTP request attributes
214 0 my $timeout = $params->{'http_client_timeout'};
215 0 my $request_body;
216 # Headers
217 0 ▶ my $content_type = defined($params->{'content_type'}) ? $params->{'content_type'} : $HTTP_CONTENT_TYPE_JSON;
Branch: 1 branch
BranchTrueFalseTotal
defined $params->{'content_type'} ? : 0 0 0
218 0 my $authorization = 'OAuth ' . $params->{'authorization_token'};
219 #
220 0 ▶ if($content_type =~ /multipart/is) {
Branch: 1 branch
BranchTrueFalseTotal
if ($content_type =~ /multipart/is) { } 0 0 0
221 0 ▶ my $body_content = $params->{'body'} ? $params->{'body'} : { }; # Else use an empty hash for body.
Branch: 1 branch
BranchTrueFalseTotal
$params->{'body'} ? : 0 0 0
222 0 my $file_as_zip = $params->{'body'}->{'file'};
223 0 delete $params->{'body'}->{'file'};
224 0 my $encoded_body_content = $json->encode($body_content);
225 0 my $boundary = $self->{'mime_boundary'};
226 0 $content_type = "multipart/form-data; boundary=$boundary";
227 0 my $file_name = $params->{'body'}->{'file_name'} . '.zip';
228 #$request_body = 'MIME-Version: 1.0' . "\n";
229 #$request_body .= 'Content-Length: ' . $req_content_length . "\n";
230 #$request_body .= 'Content-Type: ' . $req_content_type . "\n";
231 0 $request_body = q{--} . $boundary . "\n";
232 0 $request_body .= 'Content-Disposition: ' . 'form-data; name="data"' . "\n";
233 0 $request_body .= 'Content-Type: ' . 'text/plain; charset=utf-8' . "\n";
234 0 $request_body .= "\n";
235 0 $request_body .= $encoded_body_content . "\n";
236 0 $request_body .= "\n";
237 0 $request_body .= q{--} . $boundary . "\n";
238 0 $request_body .= 'Content-Disposition: ' . 'form-data; name="file"; filename="' . $file_name . q{"} . "\n";
239 0 $request_body .= 'Content-Type: ' . 'application/zip' . "\n";
240 0 $request_body .= 'Content-Transfer-Encoding: base64' . "\n";
241 0 $request_body .= "\n";
242 0 $request_body .= $file_as_zip . "\n";
243 0 $request_body .= q{--} . $boundary . q{--} . "\n";
244 }
245 else {
246 0 ▶ my $body_content = $params->{'body'} ? $params->{'body'} : { }; # Else use an empty hash for body.
Branch: 1 branch
BranchTrueFalseTotal
$params->{'body'} ? : 0 0 0
247 0 $log->debugf('About to jsonize the body:\'%s\'', $body_content);
248 0 foreach (keys %{$body_content}) {
249 # Gimmick to ensure the proper jsonization of numbers
250 # Otherwise numbers might end up as strings.
251 0 ▶ $body_content->{$_} += 0 if looks_like_number $body_content->{$_}; ## no critic (ControlStructures::ProhibitPostfixControls)
Branch: 1 branch
BranchTrueFalseTotal
if &looks_like_number($body_content->{$_}) 0 0 0
252 }
253 0 my $encoded_body_content = $json->encode($body_content);
254 0 $log->debugf('Jsonized body:\'%s\'', $encoded_body_content);
255 0 $request_body = $encoded_body_content;
256 }
257 0 $client->setTimeout($timeout);
258 0 $log->tracef('client: %s; action=%s; href=%s;', $client, $action_verb, $href);
259 0 $log->debugf('REST Request: [verb=%s; href=%s; body=%s; Headers: Content-Type=%s; Authorization=%s]', $action_verb, $href, $request_body, $content_type, $authorization);
260 0 $client->request($action_verb, $href, $request_body,
261 {
262 'Content-Type' => $content_type,
263 'Authorization' => $authorization,
264 });
265 # RETURN:
266 0 $log->debugf('Returned HTTP response code:%s', $client->responseCode());
267 0 $log->tracef('Returned HTTP response:%s', $client->responseContent());
268 0 ▶ if( $client->responseCode() >= $HTTP_CODE_OK_MIN && $client->responseCode() <= $HTTP_CODE_OK_MAX ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($client->responseCode >= $HTTP_CODE_OK_MIN and $client->responseCode <= $HTTP_CODE_OK_MAX) { } 0 0 0
Condition0%0/3
$client->responseCode >= $HTTP_CODE_OK_MIN and $client->responseCode <= $HTTP_CODE_OK_MAX
!ll&&!rl&&r
000
MC/DC0%0/2
$client->responseCode >= $HTTP_CODE_OK_MIN and $client->responseCode <= $HTTP_CODE_OK_MAX
$client->responseCode >= $HTTP_CODE_OK_MIN $client->responseCode <= $HTTP_CODE_OK_MAX
Truth table0%0/3
A and B
A= $client->responseCode >= $HTTP_CODE_OK_MINB= $client->responseCode <= $HTTP_CODE_OK_MAX
ABresult
0X0
100
111
269 # 200 OK: Successful GET; 201 Created: Successful POST
270 0 $log->tracef('HTTP Response code: %d, %s', $client->responseCode(), 'Successful!');
271 0 my $decoded_body_content;
272 0 ▶ if(defined $params->{'return_type'} && $params->{'return_type'} eq 'BINARY') {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $params->{'return_type'} and $params->{'return_type'} eq 'BINARY') { } 0 0 0
elsif (defined $params->{'return_type'} and $params->{'return_type'} eq 'PLAIN_TEXT') { } 0 0 0
Condition0%0/3
defined $params->{"return_type"} and $params->{"return_type"} eq "BINARY"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $params->{"return_type"} and $params->{"return_type"} eq "BINARY"
defined $params->{"return_type"} $params->{"return_type"} eq "BINARY"
Truth table0%0/3
A and B
A= defined $params->{"return_type"}B= $params->{"return_type"} eq "BINARY"
ABresult
0X0
100
111
273 0 $log->tracef('Returned HTTP response header Content-Disposition:%s', $client->responseHeader('Content-Disposition'));
274 0 my $filename;
275 0 ▶ if($client->responseHeader ('Content-Disposition') =~ /filename=(.+)$/s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($client->responseHeader("Content-Disposition") =~ /filename=(.+)$/s) 0 0 0
276 0 ▶ $filename = $1 ? $1 : '[Unknown filename]';
Branch: 1 branch
BranchTrueFalseTotal
$1 ? : 0 0 0
277 }
278 0 $decoded_body_content = { 'file' => $client->responseContent(), 'file_name' => $filename };
279 }
280 ▶ elsif(defined $params->{'return_type'} && $params->{'return_type'} eq 'PLAIN_TEXT') {
Condition0%0/3
defined $params->{"return_type"} and $params->{"return_type"} eq "PLAIN_TEXT"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $params->{"return_type"} and $params->{"return_type"} eq "PLAIN_TEXT"
defined $params->{"return_type"} $params->{"return_type"} eq "PLAIN_TEXT"
Truth table0%0/3
A and B
A= defined $params->{"return_type"}B= $params->{"return_type"} eq "PLAIN_TEXT"
ABresult
0X0
100
111
281 0 $decoded_body_content = $client->responseContent();
282 }
283 else {
284 0 $decoded_body_content = $json->decode( $client->responseContent() );
285 }
286 0 $log->tracef('Exiting Connector:perform_http_action(): %s, %s', $client->responseCode(), $decoded_body_content );
287 0 return $client->responseCode(), $decoded_body_content;
288 }
289 else {
290 0 $log->tracef('HTTP Response code: %d, %s', $client->responseCode(), 'Failure!');
291 0 my $decoded_body_content;
292 try {
293 0 ▶ $decoded_body_content = $json->decode( $client->responseContent() );
Subroutine __ANON__: not called CC=1 SCAR=6.9
294 0 };
295 0 ▶ my $response_message = $decoded_body_content ? $decoded_body_content->{'msg'} : $client->responseContent();
Branch: 1 branch
BranchTrueFalseTotal
$decoded_body_content ? : 0 0 0
296 0 $log->tracef('Throwing exception in perform_http_action(): status_code=%s, response_message=%s', $client->responseCode(), $response_message );
297 0 IronHTTPCallException->throw(
298 status_code => $client->responseCode(),
299 response_message => $response_message,
300 error => 'IronHTTPCallException: status_code=' . $client->responseCode()
301 . ' response_message=' . $response_message,
302 );
303 }
304 0 return; # Control does not reach this point.
305 }
306  
307 3 1;
308  
309 __END__
↑ Summary blib/lib/IO/Iron/IronMQ/Client.pm »