APIClient/Request/WHM1.pm

filter: Statementstmt 62.1% 23 / 37 Branchbran 50.0% 2 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 58.3% 7 / 12 Podpod 0.0% 0 / 6 totaltotal 51.5% 33 / 64 CC 4 SCAR 6.9
CC
4
Cov
59%
get_cli_command
3.3
new
2.5
HTTP_RESPONSE_CLASS
2.0
CRAP 2.0
« APIClient/X/API.pm ↑ Summary APIClient/Utils/FormArray.pm »
1 package cPanel::APIClient::Request::WHM1;
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 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use parent qw( cPanel::APIClient::Request::HTTPBase );
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use cPanel::APIClient::Utils::JSON ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use cPanel::APIClient::Response::WHM1 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 0 ▶sub HTTP_RESPONSE_CLASS { return 'cPanel::APIClient::Response::WHM1' }
Subroutine HTTP_RESPONSE_CLASS: not called CC=1 SCAR=6.9
Pod undocumented
19  
20 1 ▶sub new {
Subroutine new: called CC=2 SCAR=9.2
Pod undocumented
21 1 my ( $class, $func, $args_hr, $metaargs_hr ) = @_;
22  
23 1 ▶ if ($metaargs_hr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($metaargs_hr) 0 1 1
24 0 my %args_copy = %$args_hr;
25 0 _parse_metaargs( $metaargs_hr, \%args_copy );
26 0 $args_hr = \%args_copy;
27 }
28  
29 1 return bless [ $func, $args_hr ], $class;
30 }
31  
32 0 ▶sub get_http_url_path {
Subroutine get_http_url_path: not called CC=1 SCAR=6.9
Pod undocumented
33 0 my ($self) = @_;
34  
35 0 return "/json-api/$self->[0]";
36 }
37  
38 0 ▶sub get_http_payload {
Subroutine get_http_payload: not called CC=1 SCAR=6.9
Pod undocumented
39 0 my ($self) = @_;
40  
41 0 local $self->[1]{'api.version'} = 1;
42  
43 0 require cPanel::APIClient::Utils::HTTPRequest;
44 0 return cPanel::APIClient::Utils::HTTPRequest::encode_form( $self->[1] );
45 }
46  
47 #----------------------------------------------------------------------
48  
49 1 ▶sub get_cli_command {
Subroutine get_cli_command: called CC=3 SCAR=12.0
Pod undocumented
50 1 my ( $self, $authn ) = @_;
51  
52 1 ▶ my $username = $authn && $authn->username();
Condition33%1/3
$authn && $authn->username
!ll&&!rl&&r
100
MC/DC0%0/2
$authn && $authn->username
$authn $authn->username
Truth table33%1/3
A && B
A= $authnB= $authn->username
ABresult
0X0
100
111
53  
54 1 require cPanel::APIClient::Utils::CLIRequest;
55 return (
56 1 ▶ '/usr/local/cpanel/bin/whmapi1',
Branch: 1 branch
BranchTrueFalseTotal
$username ? : 0 1 1
57 '--output=json',
58 ( $username ? "--user=$username" : () ),
59 $self->[0],
60 cPanel::APIClient::Utils::CLIRequest::to_args( $self->[1] ),
61 );
62 }
63  
64 0 ▶sub parse_cli_response {
Subroutine parse_cli_response: not called CC=1 SCAR=6.9
Pod undocumented
65 0 my ( $self, $resp_body ) = @_;
66  
67 0 my $resp_struct = cPanel::APIClient::Utils::JSON::decode($resp_body);
68 0 return $self->HTTP_RESPONSE_CLASS()->new($resp_struct);
69 }
70  
71 #----------------------------------------------------------------------
72  
73 0 ▶sub _parse_metaargs { die 'Unimplemented' }
Subroutine _parse_metaargs: not called CC=1 SCAR=6.9
74  
75 1 1;
« APIClient/X/API.pm ↑ Summary APIClient/Utils/FormArray.pm »