The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

cPanel::APIClient::Response::WHM1

DESCRIPTION

This class represents a response to a WHM API v1 call.

METHODS

$scalar = OBJ->get_error()

Returns an error message, or undef if the API call succeeded. Note that this accommodates the case of a malformed API response and will give appropriate generic error messages in those cases.

This method is how you should determine whether an API call succeeded.

$thing = OBJ->get_data()

Returns the API payload.

This “reduces” the API payload when the raw payload from the API is a single-member hash whose only value is an array reference. So if the API’s raw data is:

    { payload => [ 'foo', 'bar' ] }

… then the return from this accessor will be:

    [ 'foo', 'bar' ]

This “reduction” only happens for this particular pattern; it doesn’t happen, for example, when the single-member hash’s value is any other data type.

$data = OBJ->get_raw_data()

Like get_data() but gives the verbatim data structure. Intended for use in proxying situations; application logic should usually prefer get_data().

@results = OBJ->parse_batch()

Interprets the API response as from the batch API call and returns a list of instances of this class that represents the elements of that response.

$messages_ar = OBJ->get_nonfatal_messages()

Returns a reference to an array of two-member arrays, thus:

    [
        [ info => 'Hey, by the way …' ],
        [ warn => 'Hey, this might cause a problem …' ],
    ]

The first value of each two-member array is either info or warn, and the value is the actual message. Note that error messages are not part of this structure; for that, use get_error().

This follows a pattern from CJT1 and CJT2.

LICENSE

Copyright 2020 cPanel, L. L. C. All rights reserved. http://cpanel.net

This is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.