NAME
WebService::MyGengo::Response - An response from the myGengo API
DESCRIPTION
Wraps a HTTP::Response received from the API with extra functionality.
SYNOPSIS
# Responses usually created for you by WebService::MyGengo::Client
my $http_res = $user_agent->request( $some_request );
my $res = WebService::MyGengo::Response->new( $http_res );
# Some deserialized data structure from the API
my $struct = $res->response_struct; # ref($struct) eq 'HASH'
ATTRIBUTES
response_struct
Returns the deserialized response structure for successful API calls as a hashref.
If the API response is not a hash it will be wrapped into a hash as `{ elements => \@elements }` for consistency.
If the response was a failure, returns undef.
error_code|code
The API-specific error code from the Response.
If the API request was successful, returns undef.
If the API returned an error, returns the API error code.
If the HTTP::Response is_error, or no API payload is available, returns 0.
The raw HTTP response is available via `$response->_raw_response`.
message
The API-specific error message from the Response.
If the API request was successful, returns "OK".
If the API returned an error response, returns the API error message.
If the HTTP::Response is_error, or no API payload is available, returns the status_line from the raw response.
The raw HTTP response is available via `$response->_raw_response`.
_raw_response
The original HTTP::Response object.
METHODS
is_success
If the original response is_success, then also check for errors in the response payload.
Otherwise, return false.
is_error
Returns the opposite of is_success
AUTHOR
Nathaniel Heinrichs
LICENSE
Copyright (c) 2011, Nathaniel Heinrichs <nheinric-at-cpan.org>. All rights reserved.
This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.