APIClient/Service.pm

filter: Statementstmt 70.0% 14 / 20 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 66.6% 2 / 3 totaltotal 66.6% 20 / 30 CC 2 SCAR 9.8
CC
2
Cov
64%
cancel
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.7
« APIClient/Transport/MojoUserAgent.pm ↑ Summary APIClient/Transport/HTTPSync.pm »
1 package cPanel::APIClient::Service;
2  
3 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =encoding utf-8
7  
8 =head1 NAME
9  
10 cPanel::APIClient::Service - base class for service objects
11  
12 =head1 SYNOPSIS
13  
14 See L<cPanel::APIClient> for example usage.
15  
16 =head1 DESCRIPTION
17  
18 This is a base class for objects that represent access to
19 a specific service with a specific configuration.
20  
21 =cut
22  
23 #----------------------------------------------------------------------
24  
25 8 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
26 8 my ( $class, $transporter, $authn ) = @_;
27  
28 8 my %self = (
29 transporter => $transporter,
30 authn => $authn,
31 );
32  
33 8 return bless \%self, $class;
34 }
35  
36 =head1 METHODS
37  
38 =head2 $name = I<OBJ>->service_name()
39  
40 Returns the name (e.g., C<cpanel>, C<whm>) of the service that I<OBJ>
41 accesses.
42  
43 =cut
44  
45 6 ▶sub service_name {
Subroutine service_name: called CC=1 SCAR=0.0
Pod documented
46 6 my ($self) = @_;
47  
48 6 my $name = ref($self);
49 6 $name =~ s<.+::><>;
50  
51 6 return $name;
52 }
53  
54 =head2 I<OBJ>->cancel( @ARGUMENTS )
55  
56 Cancels an API call. If the configured transport mechanism
57 cannot cancel requests, an exception is thrown.
58  
59 See your transport mechanism’s documentation for details about
60 what @ARGUMENTS should be and what this method returns.
61  
62 =cut
63  
64 0 ▶sub cancel {
Subroutine cancel: not called CC=2 SCAR=17.9
Pod documented
65 0 my ( $self, @cancel_args ) = @_;
66  
67 0 my $transport_obj = $self->{'transporter'};
68  
69 0 ▶ if ( !$self->can('cancel') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->can("cancel")) 0 0 0
70 0 my $transport_class = ref $transport_obj;
71 0 die "$transport_class cannot cancel() a request!";
72 }
73  
74 0 return $transport_obj->cancel(@cancel_args);
75 }
76  
77 =head1 LICENSE
78  
79 Copyright 2020 cPanel, L. L. C. All rights reserved. L<http://cpanel.net>
80  
81 This is free software; you can redistribute it and/or modify it under the
82 same terms as Perl itself. See L<perlartistic>.
83  
84 =cut
85  
86 12 1;
« APIClient/Transport/MojoUserAgent.pm ↑ Summary APIClient/Transport/HTTPSync.pm »