Class LatestRates

java.lang.Object
net.thauvin.erik.frankfurter.LatestRates

public class LatestRates extends Object
Represents the latest exchange rates based on a specific base currency, date, and symbols.
Since:
0.9.0
Author:
Erik C. Thauvin
  • Method Details

    • amount

      @NotNull public @NotNull Double amount()
      Retrieves the amount of the latest exchange rate or time series.
      Returns:
      a double representing the amount
    • base

      @NotNull public @NotNull String base()
      Retrieves the base currency for the current rates or time series.
      Returns:
      a non-null string representing the base currency
    • date

      @NotNull public @NotNull Optional<LocalDate> date()
      Retrieves the date associated with the latest exchange rates, if one was specified.

      Returns an empty Optional when no date was set, in which case the API will use the latest available trading date.

      Returns:
      an Optional containing the LocalDate, or empty if not set
    • exchangeRates

      @NotNull public @NotNull ExchangeRates exchangeRates() throws IOException, URISyntaxException, JsonSyntaxException
      Retrieves 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 ExchangeRates object.

      Note on interruption: If an InterruptedException is thrown, this method re-throws it after restoring the thread's interrupt status. Callers should handle or propagate it accordingly.

      Returns:
      an instance of ExchangeRates containing the base currency, date, and exchange rates
      Throws:
      IOException - if an error occurs during the API request or response handling
      URISyntaxException - if the URI syntax is invalid
      JsonSyntaxException - if the JSON response from the API does not match the expected format
    • symbols

      @NotNull public @NotNull List<String> symbols()
      Retrieves the list of currency symbols associated with the rates.
      Returns:
      a mutable defensive copy of the currency symbol list; never null