| 1 | package cPanel::APIClient::Response::UAPI; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | =encoding utf-8 | ||||||||||
| 7 | |||||||||||
| 8 | =head1 NAME | ||||||||||
| 9 | |||||||||||
| 10 | cPanel::APIClient::Response::UAPI | ||||||||||
| 11 | |||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||
| 13 | |||||||||||
| 14 | See L<cPanel::APIClient::Service::cpanel>. | ||||||||||
| 15 | |||||||||||
| 16 | =head1 DESCRIPTION | ||||||||||
| 17 | |||||||||||
| 18 | This class represents a response to a cPanel UAPI request. | ||||||||||
| 19 | |||||||||||
| 20 | =cut | ||||||||||
| 21 | |||||||||||
| 22 | #---------------------------------------------------------------------- | ||||||||||
| 23 | |||||||||||
| 24 | 2 | ▶ | use parent qw( cPanel::APIClient::Response ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | 2 | ▶ | use Call::Context; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | #---------------------------------------------------------------------- | ||||||||||
| 29 | |||||||||||
| 30 | =head1 METHODS | ||||||||||
| 31 | |||||||||||
| 32 | =head2 $yn = I<OBJ>->succeeded() | ||||||||||
| 33 | |||||||||||
| 34 | Returns a boolean that indicates whether the request succeeded. | ||||||||||
| 35 | |||||||||||
| 36 | =cut | ||||||||||
| 37 | |||||||||||
| 38 | 4 | ▶ | sub succeeded { | ||||||||
|
Subroutine
succeeded: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 39 | 4 | my ($self) = @_; | |||||||||
| 40 | |||||||||||
| 41 | 4 | ▶ | return $self->{'status'} ? 1 : 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | =head2 $scalar = I<OBJ>->get_data() | ||||||||||
| 45 | |||||||||||
| 46 | Returns the response’s payload. If that payload is a structure, | ||||||||||
| 47 | then a reference to that structure is returned. | ||||||||||
| 48 | |||||||||||
| 49 | =cut | ||||||||||
| 50 | |||||||||||
| 51 | 7 | ▶ | sub get_data { | ||||||||
|
Subroutine
get_data: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 52 | 7 | my ($self) = @_; | |||||||||
| 53 | |||||||||||
| 54 | 7 | ▶ | die "Request failed; cannot get_data()!" if !$self->{'status'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | |||||||||||
| 56 | 7 | return $self->{'data'}; | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | =head2 $str = I<OBJ>->get_errors_as_string() | ||||||||||
| 60 | |||||||||||
| 61 | Returns a single string with all of the response’s errors concatenated. | ||||||||||
| 62 | |||||||||||
| 63 | =cut | ||||||||||
| 64 | |||||||||||
| 65 | 1 | ▶ | sub get_errors_as_string { | ||||||||
|
Subroutine
get_errors_as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 66 | 1 | my ($self) = @_; | |||||||||
| 67 | |||||||||||
| 68 | 1 | return join( $/, $self->get_errors() ); | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | =head2 @errs = I<OBJ>->get_errors() | ||||||||||
| 72 | |||||||||||
| 73 | Returns a list of all the response’s errors. | ||||||||||
| 74 | |||||||||||
| 75 | Must be called in list context. | ||||||||||
| 76 | |||||||||||
| 77 | =cut | ||||||||||
| 78 | |||||||||||
| 79 | 5 | ▶ | sub get_errors { | ||||||||
|
Subroutine
get_errors: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 80 | 5 | my ($self) = @_; | |||||||||
| 81 | |||||||||||
| 82 | 5 | return $self->_get_list('errors'); | |||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | =head2 @warnings = I<OBJ>->get_warnings() | ||||||||||
| 86 | |||||||||||
| 87 | Like C<get_errors()> but returns warnings. | ||||||||||
| 88 | |||||||||||
| 89 | =cut | ||||||||||
| 90 | |||||||||||
| 91 | 4 | ▶ | sub get_warnings { | ||||||||
|
Subroutine
get_warnings: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 92 | 4 | my ($self) = @_; | |||||||||
| 93 | |||||||||||
| 94 | 4 | return $self->_get_list('warnings'); | |||||||||
| 95 | } | ||||||||||
| 96 | |||||||||||
| 97 | =head2 @messages = I<OBJ>->get_messages() | ||||||||||
| 98 | |||||||||||
| 99 | Like C<get_errors()> but returns informational messages. | ||||||||||
| 100 | |||||||||||
| 101 | =cut | ||||||||||
| 102 | |||||||||||
| 103 | 4 | ▶ | sub get_messages { | ||||||||
|
Subroutine
get_messages: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 104 | 4 | my ($self) = @_; | |||||||||
| 105 | |||||||||||
| 106 | 4 | return $self->_get_list('messages'); | |||||||||
| 107 | } | ||||||||||
| 108 | |||||||||||
| 109 | #---------------------------------------------------------------------- | ||||||||||
| 110 | |||||||||||
| 111 | 13 | ▶ | sub _get_list { | ||||||||
|
Subroutine
_get_list: called CC=2 SCAR=7.0
| |||||||||||
| 112 | 13 | my ( $self, $name ) = @_; | |||||||||
| 113 | |||||||||||
| 114 | 13 | Call::Context::must_be_list(); | |||||||||
| 115 | |||||||||||
| 116 | 13 | ▶ | return $self->{$name} ? @{ $self->{$name} } : (); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 117 | } | ||||||||||
| 118 | |||||||||||
| 119 | =head1 LICENSE | ||||||||||
| 120 | |||||||||||
| 121 | Copyright 2020 cPanel, L. L. C. All rights reserved. L<http://cpanel.net> | ||||||||||
| 122 | |||||||||||
| 123 | This is free software; you can redistribute it and/or modify it under the | ||||||||||
| 124 | same terms as Perl itself. See L<perlartistic>. | ||||||||||
| 125 | |||||||||||
| 126 | =cut | ||||||||||
| 127 | |||||||||||
| 128 | 2 | 1; | |||||||||