ExchangeRateProvider

world.money.conversion.ExchangeRateProvider

A trait for providing exchange rates.

This is the central SPI (Service Provider Interface) for currency conversion. Users can implement this trait to fetch exchange rates from any source, such as a web API, a database, or a local file.

Well-behaved implementations should handle finding direct rates (e.g., EUR -> USD), inverse rates (if only USD -> EUR is available), and potentially chained or cross-rates (e.g., KES -> ZAR via USD).

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

Retrieves the exchange rate for the given ConversionQuery.

Retrieves the exchange rate for the given ConversionQuery.

Value parameters

query

The query specifying the base and term currencies.

Attributes

Returns

Right with a ConversionRate if a rate is found, or Left with a world.money.errors.ConversionError if the rate cannot be determined.