package WebService::OANDA::ExchangeRates;
use JSON::XS;
use LWP::UserAgent;
use Moo;
use Types::Standard qw{ ArrayRef Int Str StrMatch };
use Type::Utils qw{ declare as where coerce from via enum};
u
if $type->has_coercion;
if ( ! $type->check($val) ) {
$val = JSON::XS::encode_json($val) if ref $val;
die "invalid value: $key = ($val)";
}
return $ua;
}
# GET /currencies.json
sub get_currencies {
my $self = shift;
my %params = @_;
my $response = $self->_get_request('currencies.json', \%params);
# convert arrayref
package WebService::OANDA::ExchangeRates::Response;
use Moo;
use HTTP::Response;
use JSON::XS qw{decode_json};
use Try::Tiny;
has http_response => (
is => 'rw',
handles => {
is_suc
s => 'rw' );
sub BUILD {
my $self = shift;
my $data;
try {
$data = JSON::XS::decode_json( $self->raw_data );
}
catch {
$data = {
code => undef,
ent(%s): $%s', $self->raw_data, $_
)
};
# if we failed to decode the json on a successful query, we'll consider
# this an outlier and force a 500
if ($self