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 Summary
Constructors Constructor Description ExchangeRateApiInfoProvider(@NonNull org.springframework.web.reactive.function.client.WebClient webClient)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendBase(org.springframework.web.util.UriComponentsBuilder builder, Optional<String> requestedBaseCurrency)
void
appendSymbols(org.springframework.web.util.UriComponentsBuilder builder)
protected boolean
canEqual(Object other)
boolean
equals(Object o)
String
getApiUrl()
The 3rd party url to call for exchange rate information.String
getBaseParameter()
Parameter to use for constructing the base query.String
getBaseValue()
Value to use if baseCurrency is not specified, using null will use the exchangeRateApi default (currently Euro).ExchangeRateInfo
getLatestExchangeRates(Optional<String> requestedBaseCurrency)
Called by CurrencyConversionService.String
getSymbolsParameter()
Parameter to use to restrict currencies to convert toString
getSymbolsValue()
Used as a base parameter value if one is not provided.protected String
getUrl(Optional<String> requestedBaseCurrency)
@NonNull org.springframework.web.reactive.function.client.WebClient
getWebClient()
int
hashCode()
void
setApiUrl(String apiUrl)
The 3rd party url to call for exchange rate information.void
setBaseParameter(String baseParameter)
Parameter to use for constructing the base query.void
setBaseValue(String baseValue)
Value to use if baseCurrency is not specified, using null will use the exchangeRateApi default (currently Euro).void
setSymbolsParameter(String symbolsParameter)
Parameter to use to restrict currencies to convert tovoid
setSymbolsValue(String symbolsValue)
Used as a base parameter value if one is not provided.String
toString()
-
-
-
Method Detail
-
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 interfaceExchangeRateInfoProvider
- Returns:
-
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"
-
canEqual
protected boolean canEqual(Object other)
-
-