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
ConstructorDescriptionExchangeRateApiInfoProvider
(@NonNull org.springframework.web.reactive.function.client.WebClient webClient) -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendBase
(org.springframework.web.util.UriComponentsBuilder builder, Optional<String> requestedBaseCurrency) void
appendSymbols
(org.springframework.web.util.UriComponentsBuilder builder) protected boolean
boolean
The 3rd party url to call for exchange rate information.Parameter to use for constructing the base query.Value to use if baseCurrency is not specified, using null will use the exchangeRateApi default (currently Euro).getLatestExchangeRates
(Optional<String> requestedBaseCurrency) Called by CurrencyConversionService.Parameter to use to restrict currencies to convert toUsed as a base parameter value if one is not provided.protected String
@NonNull org.springframework.web.reactive.function.client.WebClient
int
hashCode()
void
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.toString()
-
Constructor Details
-
ExchangeRateApiInfoProvider
public ExchangeRateApiInfoProvider(@NonNull @NonNull org.springframework.web.reactive.function.client.WebClient webClient)
-
-
Method Details
-
getLatestExchangeRates
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:
-
getUrl
-
appendBase
-
appendSymbols
public void appendSymbols(org.springframework.web.util.UriComponentsBuilder builder) -
getWebClient
@NonNull public @NonNull org.springframework.web.reactive.function.client.WebClient getWebClient() -
getApiUrl
The 3rd party url to call for exchange rate information. -
getBaseParameter
Parameter to use for constructing the base query. -
getBaseValue
Value to use if baseCurrency is not specified, using null will use the exchangeRateApi default (currently Euro). -
getSymbolsParameter
Parameter to use to restrict currencies to convert to -
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
The 3rd party url to call for exchange rate information. -
setBaseParameter
Parameter to use for constructing the base query. -
setBaseValue
Value to use if baseCurrency is not specified, using null will use the exchangeRateApi default (currently Euro). -
setSymbolsParameter
Parameter to use to restrict currencies to convert to -
setSymbolsValue
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
-
canEqual
-
hashCode
public int hashCode() -
toString
-