NAME

WebService::OANDA::ExchangeRates::Response - the response object from all API calls in WebService::OANDA::ExchangeRates.

SYNOPSIS

my $api = WebService::OANDA::ExchangeRates->new(api_key => 'YOUR_API_KEY');

my $response = $api->get_rates(
    base_currency => 'USD',
    quote         => [ qw{ EUR CAD } ],
);

if ($response->is_success) {
    print $response->data->{base_currency}, "\n";
}
else {
    print $respone->error_message, "\n";
}

DESCRIPTION

This module is used as the result generated by any API method called in WebService::OANDA::ExchangeRates. It automatically deserializes the data into a native Perl data structure and provides information about the request and response via an instance of HTTP::Response. You should never need to instantiate this directly as it will be provided.

METHODS

Constructor

$response = WebService::OANDA::ExchangeRates::Response->new( http_response => $http_response_object );

Constructor takes just an HTTP::Response object which will attempt to deserialize the JSON into a native data structure.

data

Contains the deserialized data structure of the API request.

error_code

A convenience method. If the response was an error, returns the contents of $response->data->{code}.

error_message

A convenience method. If the response was an error, returns the contents of $response->data->{message}.

http_response

Accessor for the HTTP::Response object generated by the API request.

http_status

Convenience method to access $response->http_response->code to determine the HTTP status code.

is_error

is_success

Convenience methods that proxy through to the same methods of the $response->http_response instance.

raw_data

Convenience method to examine the raw serialized data returned by the API. A proxied request to $response->http_response->content.

SEE ALSO

SUPPORT

Bug/Feature requests

Please file a ticket at the repository for this code on github at:

https://github.com/oanda/perl-webservice-oanda-exchangerates

AUTHOR

Dave Doyle <ddoyle@oanda.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by OANDA Corporation.

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