# `Forex.Fetcher`
[🔗](https://github.com/greven/forex/blob/1.1.2/lib/forex/fetcher.ex#L1)

The `Forex.Fetcher` module is responsible for fetching the exchange rates
from the cache or the feed on periodic intervals or on demand.

The exchange rates are fetched from the cache if the cache is enabled and
the cache is not stale. Otherwise, the exchange rates are fetched from the
feed and stored in the cache.

By default, the exchange rates are fetched from the feed every 12 hours as
the European Central Bank (ECB) updates the reference rates at around 16:00 CET
every working day. This can be configured by setting the `:schedular_interval`
option in the `Forex` application environment or by passing it as an option
when starting the `Forex.Fetcher` process.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `get`

Fetch the respective exchange rates from the cache or the feed,
based on the `key` and the `opts`.

The `key` can be one of the following atoms:

* `:latest_rates` - Fetch the latest exchange rates.
* `:last_ninety_days_rates` - Fetch the exchange rates for the last 90 days.
* `:historic_rates` - Fetch the exchange rates for a specific date.

## Options
* `:use_cache` (`t:boolean/0`) - Whether to use cached rates The default value is `true`.

* `:feed_fn` - Optional custom feed function as `{module, function, args}`

* `:schedular_interval` (`t:integer/0`) - Interval for the scheduler to fetch rates The default value is `43200000`.

# `get_options`

Get the options used to start the `Forex.Fetcher` process.

# `options`

Returns the default options for the `Forex.Fetcher` process.

# `start`

Start the `Forex.Fetcher` process with the given options.

## Options
* `:use_cache` (`t:boolean/0`) - Whether to use cached rates The default value is `true`.

* `:feed_fn` - Optional custom feed function as `{module, function, args}`

* `:schedular_interval` (`t:integer/0`) - Interval for the scheduler to fetch rates The default value is `43200000`.

# `start_link`

Start the `Forex.Fetcher` process linked to the current process
with the given options.

## Options
* `:use_cache` (`t:boolean/0`) - Whether to use cached rates The default value is `true`.

* `:feed_fn` - Optional custom feed function as `{module, function, args}`

* `:schedular_interval` (`t:integer/0`) - Interval for the scheduler to fetch rates The default value is `43200000`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
