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 voidappendBase(org.springframework.web.util.UriComponentsBuilder builder, Optional<String> requestedBaseCurrency)voidappendSymbols(org.springframework.web.util.UriComponentsBuilder builder)protected booleancanEqual(Object other)booleanequals(Object o)StringgetApiUrl()The 3rd party url to call for exchange rate information.StringgetBaseParameter()Parameter to use for constructing the base query.StringgetBaseValue()Value to use if baseCurrency is not specified, using null will use the exchangeRateApi default (currently Euro).ExchangeRateInfogetLatestExchangeRates(Optional<String> requestedBaseCurrency)Called by CurrencyConversionService.StringgetSymbolsParameter()Parameter to use to restrict currencies to convert toStringgetSymbolsValue()Used as a base parameter value if one is not provided.protected StringgetUrl(Optional<String> requestedBaseCurrency)@NonNull org.springframework.web.reactive.function.client.WebClientgetWebClient()inthashCode()voidsetApiUrl(String apiUrl)The 3rd party url to call for exchange rate information.voidsetBaseParameter(String baseParameter)Parameter to use for constructing the base query.voidsetBaseValue(String baseValue)Value to use if baseCurrency is not specified, using null will use the exchangeRateApi default (currently Euro).voidsetSymbolsParameter(String symbolsParameter)Parameter to use to restrict currencies to convert tovoidsetSymbolsValue(String symbolsValue)Used as a base parameter value if one is not provided.StringtoString()
-
-
-
Method Detail
-
getLatestExchangeRates
public ExchangeRateInfo getLatestExchangeRates(Optional<String> requestedBaseCurrency)
Description copied from interface:ExchangeRateInfoProviderCalled 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:
getLatestExchangeRatesin 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)
-
-