| 1 | package WWW::PagerDuty; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Exporter; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use JSON; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | our @EXPORT_OK = qw(new trigger resolve); | |||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use constant SERVICE_URL => "https://events.pagerduty.com/generic/2010-04-15/create_event.json"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use constant TRIGGER_KEY => 'trigger'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use constant RESOLVE_KEY => 'resolve'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | our $VERSION = 0.2; | |||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | sub error($$) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | my ($self, $errstr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | my $result = { errors => [] }; | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | push (@{$result->{errors}}, $errstr); | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | ▶ | sub new($$) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=18.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | my ($self, $params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ▶ | return $self->error('Error: not enough parameters provided') if (!(defined $params) or ref $params ne 'HASH'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $params or ref $params ne "HASH"
MC/DC50%1/2
not defined $params or ref $params ne "HASH"
not defined $params
ref $params ne "HASH"
Truth table66%2/3
not(A) or B
A= not defined $paramsB= ref $params ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | ▶ | return $self->error("Error: $@") if $@; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | ▶ | return $self->error('Error: service_key *must* be defined') if (!defined $params->{service_key}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | my $lwp = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | eval '$lwp = LWP::UserAgent->new()'; | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | return $self->error('Error: could not instantiate LWP Object') if $@; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | $self = bless { | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | url => SERVICE_URL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | user_agent => $lwp, | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | trigger_key => TRIGGER_KEY, | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | resolve_key => RESOLVE_KEY, | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | service_key => $params->{service_key}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | incident_key => $params->{incident_key} | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | }, "WWW::PagerDuty"; | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub trigger($$) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trigger: not called CC=22 SCAR=62.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my ($self, $params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | return $self->error('Error: not called correctly') if (!(defined $self) or ref $self ne 'WWW::PagerDuty'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $self or ref $self ne "WWW::PagerDuty"
MC/DC0%0/2
not defined $self or ref $self ne "WWW::PagerDuty"
not defined $self
ref $self ne "WWW::PagerDuty"
Truth table0%0/3
not(A) or B
A= not defined $selfB= ref $self ne "WWW::PagerDuty"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | return $self->error('Error: parameters not passed') if (!(defined $params) or ref $params ne 'HASH'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $params or ref $params ne "HASH"
MC/DC0%0/2
not defined $params or ref $params ne "HASH"
not defined $params
ref $params ne "HASH"
Truth table0%0/3
not(A) or B
A= not defined $paramsB= ref $params ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | return $self->error('Error: incident_key *must* be passed') if (!(defined $params->{incident_key}) and !(defined $self->{incident_key})); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $params->{"incident_key"} or defined $self->{"incident_key"}
MC/DC0%0/2
defined $params->{"incident_key"} or defined $self->{"incident_key"}
defined $params->{"incident_key"}
defined $self->{"incident_key"}
Truth table0%0/3
A or B
A= defined $params->{"incident_key"}B= defined $self->{"incident_key"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | return $self->error('Error: description *must* be passed') if !(defined $params->{description}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $details = $params->{details}; | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if (defined $params->{details} && ref $params->{details} eq 'SCALAR') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $params->{"details"} and ref $params->{"details"} eq "SCALAR"
MC/DC0%0/2
defined $params->{"details"} and ref $params->{"details"} eq "SCALAR"
defined $params->{"details"}
ref $params->{"details"} eq "SCALAR"
Truth table0%0/3
A and B
A= defined $params->{"details"}B= ref $params->{"details"} eq "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | $details = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 'additional_info' => $params->{details} | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | ▶ | } elsif (defined $params->{details} && ref $params->{details} eq 'HASH') { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $params->{"details"} and ref $params->{"details"} eq "HASH"
MC/DC0%0/2
defined $params->{"details"} and ref $params->{"details"} eq "HASH"
defined $params->{"details"}
ref $params->{"details"} eq "HASH"
Truth table0%0/3
A and B
A= defined $params->{"details"}B= ref $params->{"details"} eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $details = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | my $request_body = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 'service_key' => $self->{service_key}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 'incident_key' => (defined $params->{incident_key}) ? $params->{incident_key} : $self->{incident_key}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 'event_type' => $self->{trigger_key}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 'description' => $params->{description}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | 'details' => $details | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my $return_body = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $data = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | $data = eval { JSON::encode_json($request_body); }; | |||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if ($data) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $return_body = eval { $self->{user_agent}->post($self->{url}, Content_Type => 'application/json', Content => $data); }; | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if (defined $return_body) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my $result = JSON::decode_json($return_body->decoded_content); | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if (defined $result && ref $result eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $result and ref $result eq "HASH"
MC/DC0%0/2
defined $result and ref $result eq "HASH"
defined $result
ref $result eq "HASH"
Truth table0%0/3
A and B
A= defined $resultB= ref $result eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if (defined $result->{errors} && ref $result->{errors} eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $result->{"errors"} and ref $result->{"errors"} eq "ARRAY"
MC/DC0%0/2
defined $result->{"errors"} and ref $result->{"errors"} eq "ARRAY"
defined $result->{"errors"}
ref $result->{"errors"} eq "ARRAY"
Truth table0%0/3
A and B
A= defined $result->{"errors"}B= ref $result->{"errors"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | push(@{$result->{errors}}, $@); | |||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | return $return_body; | |||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } elsif($@) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | return $self->error("Error: $@"); | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | return $self->error('Error: response body was not returned'); | |||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } elsif ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | return $self->error("Error: $@"); | |||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | sub resolve($$) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve: not called CC=30 SCAR=68.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my ($self, $params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | return WWW::PagerDuty::error(undef, "Error: calling convention not followed") if !(defined $self) and ref $self ne 'WWW::PagerDuty'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $self and ref $self ne "WWW::PagerDuty"
MC/DC0%0/2
not defined $self and ref $self ne "WWW::PagerDuty"
not defined $self
ref $self ne "WWW::PagerDuty"
Truth table0%0/3
not(A) and B
A= not defined $selfB= ref $self ne "WWW::PagerDuty"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | return $self->error("Error: no parameters passed") if (!(defined $params) or ref $params ne 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $params or ref $params ne "HASH"
MC/DC0%0/2
not defined $params or ref $params ne "HASH"
not defined $params
ref $params ne "HASH"
Truth table0%0/3
not(A) or B
A= not defined $paramsB= ref $params ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | return $self->error("Error: not initialized correctly, service_key *must* be defined") if !(defined $self->{service_key}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | return $self->error("Error: incident_key *must* be passed") if !($self->{incident_key}) and !($params->{incident_key}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"incident_key"} or $params->{"incident_key"}
MC/DC0%0/2
$self->{"incident_key"} or $params->{"incident_key"}
$self->{"incident_key"}
$params->{"incident_key"}
Truth table0%0/3
A or B
A= $self->{"incident_key"}B= $params->{"incident_key"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | return $self->error("Error: description *must* be defined") if !($params->{description}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $details = $params->{details}; | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if (defined $details) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if (ref $details eq 'SCALAR') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $details = { | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | additional_information => $details | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } elsif (ref $details eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $details = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | my $request_body = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | service_key => (defined $params->{service_key}) ? $params->{service_key} : $self->{service_key}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | incident_key => (defined $params->{service_key}) ? $params->{incident_key} : $self->{incident_key}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | event_type => $self->{resolve_key}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | description => $params->{details}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | details => $details | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $request_body_json = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $request_body_json = eval { JSON::encode_json($request_body); }; | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if (defined $request_body_json && $request_body_json && !$@) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
defined $request_body_json and $request_body_json and not $@
defined $request_body_json and $request_body_json
MC/DC0%0/3
defined $request_body_json and $request_body_json and not $@
defined $request_body_json
$request_body_json
not $@
Truth table0%0/4
A and B and not(C)
A= defined $request_body_jsonB= $request_body_jsonC= not $@
| |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $http_response_body = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $http_response_body = eval { $self->{user_agent}->post($self->{url}, Content_Type => 'application/json', Content => $request_body_json); }; | |||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | if (defined $http_response_body && !$@) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
defined $http_response_body and not $@
MC/DC0%0/2
defined $http_response_body and not $@
defined $http_response_body
not $@
Truth table0%0/3
A and not(B)
A= defined $http_response_bodyB= not $@
| |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my $http_response = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $http_response = eval { JSON::decode_json($http_response_body->decoded_content); }; | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if (defined $http_response) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if (ref $http_response eq 'HASH' && defined $http_response->{errors} && ref $http_response->{errors} eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
ref $http_response eq "HASH" and defined $http_response->{"errors"} and ref $http_response->{"errors"} eq "ARRAY"
ref $http_response eq "HASH" and defined $http_response->{"errors"}
MC/DC0%0/3
ref $http_response eq "HASH" and defined $http_response->{"errors"} and ref $http_response->{"errors"} eq "ARRAY"
ref $http_response eq "HASH"
defined $http_response->{"errors"}
ref $http_response->{"errors"} eq "ARRAY"
Truth table0%0/4
A and B and C
A= ref $http_response eq "HASH"B= defined $http_response->{"errors"}C= ref $http_response->{"errors"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | push(@{$http_response->{errors}}, $@); | |||||||||||||||||||||||||||||||||||||||||||||
| 182 | ▶ | } elsif (ref $http_response eq 'HASH' && !defined $http_response->{errors}) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $http_response eq "HASH" and not defined $http_response->{"errors"}
MC/DC0%0/2
ref $http_response eq "HASH" and not defined $http_response->{"errors"}
ref $http_response eq "HASH"
not defined $http_response->{"errors"}
Truth table0%0/3
A and not(B)
A= ref $http_response eq "HASH"B= not defined $http_response->{"errors"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $http_response->{errors} = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | push(@{$http_response->{errors}}, $@); | |||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | return $http_response; | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | ▶ | } elsif (defined $http_response_body && $@) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $http_response_body and $@
MC/DC0%0/2
defined $http_response_body and $@
defined $http_response_body
$@
Truth table0%0/3
A and B
A= defined $http_response_bodyB= $@
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | return { errors => ["Error: $@"], http_response_body => $http_response_body }; | |||||||||||||||||||||||||||||||||||||||||||||
| 192 | } elsif ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | return $self->error("Error: $@"); | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } elsif ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | return $self->error("Error: $@"); | |||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 2 | 1 | |||||||||||||||||||||||||||||||||||||||||||||