# `Money.ExchangeRates.Retriever`
[🔗](https://github.com/kipcole9/money/blob/v6.0.0-rc.0/lib/money/exchange_rates/exchange_rates_retriever.ex#L1)

Implements a `GenServer` to retrieve exchange rates from
a configured retrieveal module on a periodic or on demand basis.

By default exchange rates are retrieved from [Open Exchange Rates](http://openexchangerates.org).

The default period of execution is 5 minutes (300_000 milliseconds). The
period of retrieval is configured in `config.exs` or the appropriate
environment configuration.  For example:

    config :ex_money,
      retrieve_every: 300_000

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `config`

Return the current configuration of the Exchange Rates
Retrieval service

# `delete`

Delete the exchange rates retrieval service

The service can be started again with `start/1`

# `historic_rates`

Forces retrieval of historic exchange rates for a single date

* `date` is a date returned by `Date.new/3` or any struct with the
  elements `:year`, `:month` and `:day` or

* a `Date.Range.t` created by `Date.range/2` that specifies a
  range of dates to retrieve

Returns:

* `{:ok, rates}` if exchange rates request is successfully sent.

* `{:error, reason}` if the request cannot be send.

Sends a message ot the exchange rate retrieval worker to request
historic rates for a specified date or range be retrieved and
stored.

This function does not return exchange rates, for that see
`Money.ExchangeRates.latest_rates/0` or
`Money.ExchangeRates.historic_rates/1`.

# `historic_rates`

Forces retrieval of historic exchange rates for a range of dates

* `from` is a date returned by `Date.new/3` or any struct with the
  elements `:year`, `:month` and `:day`.

* `to` is a date returned by `Date.new/3` or any struct with the
  elements `:year`, `:month` and `:day`.

Returns:

* `{:ok, rates}` if exchange rates request is successfully sent.

* `{:error, reason}` if the request cannot be send.

Sends a message to the exchange rate retrieval process for each
date in the range `from`..`to` to request historic rates be
retrieved.

# `latest_rates`

Forces retrieval of the latest exchange rates

Sends a message ot the exchange rate retrieval worker to request
current rates be retrieved and stored.

Returns:

* `{:ok, rates}` if exchange rates request is successfully sent.

* `{:error, reason}` if the request cannot be send.

This function does not return exchange rates, for that see
`Money.ExchangeRates.latest_rates/0` or
`Money.ExchangeRates.historic_rates/1`.

# `reconfigure`

Updated the configuration for the Exchange Rate
Service

# `restart`

Restart the exchange rates retrieval service

# `retrieve_rates`

Retrieve exchange rates from an external HTTP
service.

This function is primarily intended for use by
an exchange rates api module.

# `start`

Starts the exchange rates retrieval service

# `stop`

Stop the exchange rates retrieval service.

The service can be restarted with `restart/0`.

---

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