APIClient/Request/HTTPBase.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 4 totaltotal 89.4% 34 / 38 CC 2 SCAR 1.8
CC
2
Cov
100%
parse_http_response
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« APIClient/Authn/Password2FA.pm ↑ Summary APIClient/Authn.pm »
1 package cPanel::APIClient::Request::HTTPBase;
2  
3 # Copyright 2020 cPanel, L. L. C.
4 # All rights reserved.
5 # http://cpanel.net
6 #
7 # This is free software; you can redistribute it and/or modify it under the
8 # same terms as Perl itself. See L<perlartistic>.
9  
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 3 ▶use cPanel::APIClient::Utils::JSON ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶use cPanel::APIClient::X ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 8 ▶sub get_http_method {
Subroutine get_http_method: called CC=1 SCAR=0.0
Pod undocumented
17 8 return 'POST';
18 }
19  
20 8 ▶sub get_http_headers {
Subroutine get_http_headers: called CC=1 SCAR=0.0
Pod undocumented
21 8 return [ 'Content-Type' => 'application/x-www-form-urlencoded' ];
22 }
23  
24 6 ▶sub parse_http_response {
Subroutine parse_http_response: called CC=2 SCAR=6.9
Pod undocumented
25 6 my ( $self, $resp_obj, $resp_body ) = @_;
26  
27 6 ▶ if ( $resp_obj->code() !~ m<\A2> ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($resp_obj->code =~ /\A2/) 1 5 6
28 1 die cPanel::APIClient::X->create( 'HTTP', $resp_obj->as_string() . $/ . $resp_body );
29 }
30  
31 5 my $resp_struct = cPanel::APIClient::Utils::JSON::decode($resp_body);
32  
33 5 return $self->HTTP_RESPONSE_CLASS()->new(
34 $self->_EXTRACT_RESPONSE($resp_struct),
35 );
36 }
37  
38 2 ▶sub create_transport_error {
Subroutine create_transport_error: called CC=1 SCAR=0.0
Pod undocumented
39 2 my ( $self, $description, @properties_kv ) = @_;
40  
41 2 die cPanel::APIClient::X->create( 'SubTransport', $description );
42 }
43  
44 5 ▶sub _EXTRACT_RESPONSE {
Subroutine _EXTRACT_RESPONSE: called CC=1 SCAR=0.0
45 5 return $_[1];
46 }
47  
48 3 1;
« APIClient/Authn/Password2FA.pm ↑ Summary APIClient/Authn.pm »