Package net.thauvin.erik.frankfurter
Class LatestRates
java.lang.Object
net.thauvin.erik.frankfurter.LatestRates
Represents the latest exchange rates based on a specific base currency, date, and symbols.
- Since:
- 0.9.0
- Author:
- Erik C. Thauvin
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class to construct instances of theLatestRatesclass. -
Method Summary
Modifier and TypeMethodDescription@NotNull Doubleamount()Retrieves the amount of the latest exchange rate or time series.@NotNull Stringbase()Retrieves the base currency for the current rates or time series.date()Retrieves the date associated with the latest exchange rates, if one was specified.@NotNull ExchangeRatesRetrieves the latest exchange rates based on a specified base currency, date, and optional symbols.symbols()Retrieves the list of currency symbols associated with the rates.
-
Method Details
-
amount
Retrieves the amount of the latest exchange rate or time series.- Returns:
- a
doublerepresenting the amount
-
base
Retrieves the base currency for the current rates or time series.- Returns:
- a non-null string representing the base currency
-
date
Retrieves the date associated with the latest exchange rates, if one was specified.Returns an empty
Optionalwhen no date was set, in which case the API will use the latest available trading date. -
exchangeRates
@NotNull public @NotNull ExchangeRates exchangeRates() throws IOException, URISyntaxException, JsonSyntaxExceptionRetrieves the latest exchange rates based on a specified base currency, date, and optional symbols.This method constructs a request to the Frankfurter API, fetches the data, and parses the response into a
ExchangeRatesobject.Note on interruption: If an
InterruptedExceptionis thrown, this method re-throws it after restoring the thread's interrupt status. Callers should handle or propagate it accordingly.- Returns:
- an instance of
ExchangeRatescontaining the base currency, date, and exchange rates - Throws:
IOException- if an error occurs during the API request or response handlingURISyntaxException- if the URI syntax is invalidJsonSyntaxException- if the JSON response from the API does not match the expected format
-
symbols
Retrieves the list of currency symbols associated with the rates.- Returns:
- a mutable defensive copy of the currency symbol list; never
null
-