Finance::Currency::FiatX::Role::Source - Role for FiatX sources
This document describes version 0.006 of Finance::Currency::FiatX::Role::Source (from Perl distribution Finance-Currency-FiatX), released on 2018-06-24.
All routines must return enveloped result.
[$status, $reason, $payload, \%extra]
This result is analogous to an HTTP response; in fact $status mostly uses HTTP response codes. $reason is analogous to HTTP status message. $payload is the actual content (optional if $status is error status). %extra is optional and analogous to HTTP response headers to specify flags or attributes or other metadata.
$reason
$payload
$status
%extra
Some examples of enveloped result:
[200, "OK", 14000] [404, "Not found"]
For more details about enveloped result, see Rinci::function.
Usage:
get_all_spot_rates() -> [$status, $reason, $payload [ , \%extra ] ]
Return spot rate for all currency pairs available for this sources. If the source provides a way to list all supported rates in a single API call or webpage, then this routine should return them. Otherwise, this routine should return status 412, e.g.
[501, "Source does not offer a way to list all spot rates"]
Result payload is an array of hashes, where each hash must contain these keys: pair (str in the format of <from_currency>/<to_currency>, e.g. USD/IDR), rate (num, the rate), mtime (Unix epoch, last updated time for the rate, according to the source). type ("buy" or "sell").
pair
<from_currency>/<to_currency>
USD/IDR
rate
mtime
type
Return spot (the latest) rate for a currency pair.
get_spot_rate($from, $to, $type) -> [$status, $reason, $payload [ , \%extra ] ]
$from and $to are currency codes, $type is either "buy" or "sell". If a source does not support the currency pair, routine must return status 501.
$from
$to
$type
Result payload is hash that must contain these keys: pair (str in the format of <from_currency>/<to_currency>, e.g. USD/IDR), rate (num, the rate), mtime (Unix epoch, last updated time for the rate, according to the source). type ("buy" or "sell").
get_historical_rates($from, $to, $from_date, $to_date) -> [$status, $reason, $payload [ , \%extra ] ]
If source does not support historical rates, routine must return status 501.
Please report all bug reports or feature requests to mailto:stevenharyanto@gmail.com.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2018 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Finance::Currency::FiatX, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Finance::Currency::FiatX
CPAN shell
perl -MCPAN -e shell install Finance::Currency::FiatX
For more information on module installation, please visit the detailed CPAN module installation guide.