File Coverage

blib/lib/cPanel/APIClient/Service.pm
Criterion Covered Total %
statement 6 19 31.5
branch 0 2 0.0
condition n/a
subroutine 2 5 40.0
pod 2 3 66.6
total 10 29 34.4


line stmt bran cond sub pod time code
1             package cPanel::APIClient::Service;
2              
3 5     5   2160 use strict;
  5         13  
  5         153  
4 5     5   26 use warnings;
  5         11  
  5         1245  
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 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             sub new {
26 0     0 0   my ( $class, $transporter, $authn ) = @_;
27              
28 0           my %self = (
29             transporter => $transporter,
30             authn => $authn,
31             );
32              
33 0           return bless \%self, $class;
34             }
35              
36             =head1 METHODS
37              
38             =head2 $name = I->service_name()
39              
40             Returns the name (e.g., C, C) of the service that I
41             accesses.
42              
43             =cut
44              
45             sub service_name {
46 0     0 1   my ($self) = @_;
47              
48 0           my $name = ref($self);
49 0           $name =~ s<.+::><>;
50              
51 0           return $name;
52             }
53              
54             =head2 I->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             sub cancel {
65 0     0 1   my ( $self, @cancel_args ) = @_;
66              
67 0           my $transport_obj = $self->{'transporter'};
68              
69 0 0         if ( !$self->can('cancel') ) {
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
80              
81             This is free software; you can redistribute it and/or modify it under the
82             same terms as Perl itself. See L.
83              
84             =cut
85              
86             1;