NAME
    Finance::Currency::FiatX - Fiat currency exchange rate library

VERSION
    This document describes version 0.005 of Finance::Currency::FiatX (from
    Perl distribution Finance-Currency-FiatX), released on 2018-06-19.

SYNOPSIS
    See fiatx from App::fiatx for an example on how to use this module.

DESCRIPTION
    FiatX is a library/application to convert one fiat currency to another
    using several backend modules ("sources",
    "Finance::Currency::FiatX::Source::*", which in turns usually utilize
    "Finance::Currency::Convert::*") and store the rates in DBI database for
    caching.

FUNCTIONS
  get_all_spot_rates
    Usage:

     get_all_spot_rates(%args) -> [status, msg, result, meta]

    Get all spot rates from a source.

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   dbh => *obj*

    *   max_age_cache => *posint* (default: 14400)

        Above this age (in seconds), we retrieve rate from remote source
        again.

    *   source* => *str* (default: ":any")

        Ask for a specific remote source.

        If you want a specific remote source, you can specify it here. The
        default is ':any' which is to pick the first source that returns a
        recent enough current rate.

        Other special values: ":highest" to return highest rate of all
        sources, ":lowest" to return lowest rate of all sources, ':newest'
        to return rate from source with the newest last update time,
        ':oldest' to return rate from source with the oldest last update
        time, ':average' to return arithmetic average of all sources.

    *   table_prefix => *str* (default: "fiatx_")

    Returns an enveloped result (an array).

    First element (status) is an integer containing HTTP status code (200
    means OK, 4xx caller error, 5xx function error). Second element (msg) is
    a string containing error message, or 'OK' if status is 200. Third
    element (result) is optional, the actual result. Fourth element (meta)
    is called result metadata and is optional, a hash that contains extra
    information.

    Return value: (any)

  get_spot_rate
    Usage:

     get_spot_rate(%args) -> [status, msg, result, meta]

    Get spot (latest) rate.

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   dbh => *obj*

    *   from* => *currency::code*

    *   max_age_cache => *posint* (default: 14400)

        Above this age (in seconds), we retrieve rate from remote source
        again.

    *   source => *str* (default: ":any")

        Ask for a specific remote source.

        If you want a specific remote source, you can specify it here. The
        default is ':any' which is to pick the first source that returns a
        recent enough current rate.

        Other special values: ":highest" to return highest rate of all
        sources, ":lowest" to return lowest rate of all sources, ':newest'
        to return rate from source with the newest last update time,
        ':oldest' to return rate from source with the oldest last update
        time, ':average' to return arithmetic average of all sources.

    *   table_prefix => *str* (default: "fiatx_")

    *   to* => *currency::code*

    *   type => *str* (default: "sell")

        Which rate is wanted? e.g. sell, buy.

    Returns an enveloped result (an array).

    First element (status) is an integer containing HTTP status code (200
    means OK, 4xx caller error, 5xx function error). Second element (msg) is
    a string containing error message, or 'OK' if status is 200. Third
    element (result) is optional, the actual result. Fourth element (meta)
    is called result metadata and is optional, a hash that contains extra
    information.

    Return value: (any)

BUGS
    Please report all bug reports or feature requests to
    <mailto:stevenharyanto@gmail.com>.

SEE ALSO
    "Finance::Currency::Convert::*" modules.

AUTHOR
    perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE
    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.

