Class ExchangeRateApiInfoProvider

java.lang.Object
com.broadleafcommerce.pricing.provider.exchangerate.ExchangeRateApiInfoProvider
All Implemented Interfaces:
ExchangeRateInfoProvider

@ConfigurationProperties(prefix="broadleaf.pricing.exchangeapi") public class ExchangeRateApiInfoProvider extends Object implements ExchangeRateInfoProvider
This sample ExchangeRateInfoProvider uses an API endpoint to retrieve exchange data. It is modeled as an example for calling the "https://api.exchangeratesapi.io/" apis. The results of this API are not warranted anyway. This class provides an example call to the exchangeapi endpoint and is intended as an example. Implementations are responsible for evaluating the use of this API in production.
Author:
Brian Polster (bpolster)
  • Constructor Details

    • ExchangeRateApiInfoProvider

      public ExchangeRateApiInfoProvider(@NonNull @NonNull org.springframework.web.reactive.function.client.WebClient webClient)
  • Method Details

    • getLatestExchangeRates

      public ExchangeRateInfo getLatestExchangeRates(Optional<String> requestedBaseCurrency)
      Description copied from interface: ExchangeRateInfoProvider
      Called by CurrencyConversionService. Some implementations may ignore the passed in baseCurrency when returning an ExchangeRateInfo. This is useful for installations that only use a single base currency.
      Specified by:
      getLatestExchangeRates in interface ExchangeRateInfoProvider
      Returns:
    • getUrl

      protected String getUrl(Optional<String> requestedBaseCurrency)
    • appendBase

      public void appendBase(org.springframework.web.util.UriComponentsBuilder builder, Optional<String> requestedBaseCurrency)
    • appendSymbols

      public void appendSymbols(org.springframework.web.util.UriComponentsBuilder builder)
    • getWebClient

      @NonNull public @NonNull org.springframework.web.reactive.function.client.WebClient getWebClient()
    • getApiUrl

      public String getApiUrl()
      The 3rd party url to call for exchange rate information.
    • getBaseParameter

      public String getBaseParameter()
      Parameter to use for constructing the base query.
    • getBaseValue

      public String getBaseValue()
      Value to use if baseCurrency is not specified, using null will use the exchangeRateApi default (currently Euro).
    • getSymbolsParameter

      public String getSymbolsParameter()
      Parameter to use to restrict currencies to convert to
    • getSymbolsValue

      public String getSymbolsValue()
      Used as a base parameter value if one is not provided. Use a comma separated list for more than one value. "GBP" or "GPB,EUR"
    • setApiUrl

      public void setApiUrl(String apiUrl)
      The 3rd party url to call for exchange rate information.
    • setBaseParameter

      public void setBaseParameter(String baseParameter)
      Parameter to use for constructing the base query.
    • setBaseValue

      public void setBaseValue(String baseValue)
      Value to use if baseCurrency is not specified, using null will use the exchangeRateApi default (currently Euro).
    • setSymbolsParameter

      public void setSymbolsParameter(String symbolsParameter)
      Parameter to use to restrict currencies to convert to
    • setSymbolsValue

      public void setSymbolsValue(String symbolsValue)
      Used as a base parameter value if one is not provided. Use a comma separated list for more than one value. "GBP" or "GPB,EUR"
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object