Forex.Feed (Forex v0.2.1)

View Source

This module is responsible for fetching the latest exchange rates from the European Central Bank (ECB) and parsing the XML response.

The ECB provides three different feeds:

For each feed, this module provides a function to fetch the rates and parse the response, respectively, latest_rates/1, last_ninety_days_rates/1, and historic_rates/1.

Summary

Functions

The API module to use for fetching the exchange rates, by default uses the HTTP API. The API module must implement the Forex.Feed.API behaviour.

The base URL for the European Central Bank (ECB) exchange rate feeds.

Fetches the historic exchange rates from the European Central Bank (ECB).

Fetches the exchange rates for the last ninety days from the European Central Bank (ECB).

Fetches the latest exchange rates from the European Central Bank (ECB).

The path for the different exchange rate feeds, corresponding to each different feed provided by the European Central Bank (ECB).

Functions

api_mod()

The API module to use for fetching the exchange rates, by default uses the HTTP API. The API module must implement the Forex.Feed.API behaviour.

This is useful for testing purposes, where you can provide a mock API module or for using a different API module, for example, an API module that uses a different HTTP client.

base_url()

The base URL for the European Central Bank (ECB) exchange rate feeds.

historic_rates(options \\ [])

@spec historic_rates(keyword()) :: {:ok, [map()]} | {:error, {module(), term()}}

Fetches the historic exchange rates from the European Central Bank (ECB).

last_ninety_days_rates(options \\ [])

@spec last_ninety_days_rates(keyword()) ::
  {:ok, [map()]} | {:error, {module(), term()}}

Fetches the exchange rates for the last ninety days from the European Central Bank (ECB).

latest_rates(options \\ [])

@spec latest_rates(keyword()) :: {:ok, map()} | {:error, {module(), term()}}

Fetches the latest exchange rates from the European Central Bank (ECB).

path(atom)

The path for the different exchange rate feeds, corresponding to each different feed provided by the European Central Bank (ECB).