Class ExternalPricingProvider
java.lang.Object
com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
com.broadleafcommerce.cartoperation.service.provider.external.ExternalPricingProvider
- All Implemented Interfaces:
PricingProvider
- Author:
- Chad Harchar (charchar), Nathan Moore (nathandmoore)
-
Field Summary
Fields inherited from class com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
ENTITY_NOT_FOUND -
Constructor Summary
ConstructorsConstructorDescriptionExternalPricingProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CartItemPricingUtils cartItemPricingUtils, ExternalPricingProperties properties, UserTargetGenerationService userTargetGenerationService) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddUserTargets(@NonNull com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext) Deprecated, for removal: This API element is subject to removal in a future version.protected voidaddUserTargets(@NonNull com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Add customer and customer segment user targets toPriceContext.getUserTargets().protected <P extends com.broadleafcommerce.pricing.client.domain.PriceInfo>
voidattachPricingToCartItem(@NonNull com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull Collection<P> priceInfos, String variantId) protected <C extends com.broadleafcommerce.cart.client.domain.CartItem>
Set<com.broadleafcommerce.pricing.client.domain.PriceableTarget>buildPriceableTargets(@NotNull Collection<C> cartItems, Map<String, Integer> totalQuantityForTargetId) protected StringbuildPriceContextHeader(@NonNull com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext) protected com.broadleafcommerce.order.common.domain.RecurringPriceDetailbuildRecurringPrice(@NonNull com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo) Converts thePriceInfo.getRecurringPrice()into the version used byCartItem.getRecurringPrice().protected com.broadleafcommerce.order.common.domain.UsagePriceDetailbuildUsagePrice(@NonNull com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo) Converts thePriceInfo.getUsagePrice()into the version used byCartItem.getUsagePrice().protected com.broadleafcommerce.pricing.client.domain.UserTargetRefcreateUserTargetRef(String targetValue, String targetType) protected CartItemPricingUtilsprotected com.broadleafcommerce.pricing.client.domain.context.PriceContextgetPriceContext(Locale locale, javax.money.CurrencyUnit currency) protected com.broadleafcommerce.pricing.client.domain.context.PriceContextgetPriceContext(Locale locale, javax.money.CurrencyUnit currency, com.broadleafcommerce.cart.client.domain.Cart cart) protected com.broadleafcommerce.pricing.client.domain.context.PriceInfoContextgetPriceInfoContext(Set<com.broadleafcommerce.pricing.client.domain.PriceableTarget> priceableTargets) protected ExternalPricingPropertiesprotected StringgetTotalQuantityForTargetIdMap(@NonNull Collection<C> cartItems) Creates a map of the SKU or pricing key of an underlying item from a cart item to the total quantity of that item across all cart items.protected UserTargetGenerationServiceprotected booleanisDependentItem(com.broadleafcommerce.cart.client.domain.CartItem cartItem) com.broadleafcommerce.pricing.client.domain.usage.RecordPriceDataUsageResponserecordPriceDataUsages(com.broadleafcommerce.pricing.client.domain.usage.RecordPriceDataUsageRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Records the usages for prices that are limited by quantity.<C extends com.broadleafcommerce.cart.client.domain.CartItem>
List<com.broadleafcommerce.pricing.client.domain.PriceInfo>retrievePriceInfos(@NonNull Collection<C> cartItems, @NonNull com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves the prices for the provided cart items without attaching them.List<com.broadleafcommerce.cart.client.domain.CartItem>retrievePrices(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull Locale locale, @NonNull javax.money.CurrencyUnit currency, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve and attach prices for the provided cart items.<C extends com.broadleafcommerce.cart.client.domain.CartItem>
List<C>retrievePrices(@NonNull Collection<C> cartItems, @NonNull Locale locale, @NonNull javax.money.CurrencyUnit currency, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve and attach prices for the provided cart items.protected List<com.broadleafcommerce.pricing.client.domain.PriceInfo>sendCartItemPricingRequest(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext) Methods inherited from class com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
addOffsetOrPageNumber, buildNotFoundException, executeRequest, getHeaders, getObjectMapper, getTypeFactory, getWebClient, isEntityNotFound, pageableToParams, uriVars
-
Constructor Details
-
ExternalPricingProvider
public ExternalPricingProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CartItemPricingUtils cartItemPricingUtils, ExternalPricingProperties properties, UserTargetGenerationService userTargetGenerationService)
-
-
Method Details
-
retrievePrices
public List<com.broadleafcommerce.cart.client.domain.CartItem> retrievePrices(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull Locale locale, @NonNull @NonNull javax.money.CurrencyUnit currency, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PricingProviderRetrieve and attach prices for the provided cart items.- Specified by:
retrievePricesin interfacePricingProvider- Parameters:
cart- The cart that we are pricing.locale- The locale to use to match prices.currency- The currency to use to match prices.contextInfo- Context information around sandbox and multitenant state.- Returns:
- The cart items with prices attached.
-
retrievePrices
public <C extends com.broadleafcommerce.cart.client.domain.CartItem> List<C> retrievePrices(@NonNull @NonNull Collection<C> cartItems, @NonNull @NonNull Locale locale, @NonNull @NonNull javax.money.CurrencyUnit currency, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PricingProviderRetrieve and attach prices for the provided cart items.- Specified by:
retrievePricesin interfacePricingProvider- Parameters:
cartItems- The cart items that we are pricing.locale- The locale to use to match prices.currency- The currency to use to match prices.contextInfo- Context information around sandbox and multitenant state.- Returns:
- The cart items with prices attached.
-
retrievePriceInfos
public <C extends com.broadleafcommerce.cart.client.domain.CartItem> List<com.broadleafcommerce.pricing.client.domain.PriceInfo> retrievePriceInfos(@NonNull @NonNull Collection<C> cartItems, @NonNull @NonNull com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PricingProviderRetrieves the prices for the provided cart items without attaching them.- Specified by:
retrievePriceInfosin interfacePricingProvider- Parameters:
cartItems- The cart items that we are pricing.priceContext- ThePriceContextcontextInfo- Context information around sandbox and multitenant state.- Returns:
- The prices for the provided cart items
-
sendCartItemPricingRequest
protected List<com.broadleafcommerce.pricing.client.domain.PriceInfo> sendCartItemPricingRequest(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext) -
recordPriceDataUsages
public com.broadleafcommerce.pricing.client.domain.usage.RecordPriceDataUsageResponse recordPriceDataUsages(com.broadleafcommerce.pricing.client.domain.usage.RecordPriceDataUsageRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PricingProviderRecords the usages for prices that are limited by quantity.- Specified by:
recordPriceDataUsagesin interfacePricingProvider- Parameters:
request- theRecordPriceDataUsageRequestcontextInfo- Context information around sandbox and multitenant state.- Returns:
- the
RecordPriceDataUsageResponserepresenting the result of the request
-
buildPriceableTargets
protected <C extends com.broadleafcommerce.cart.client.domain.CartItem> Set<com.broadleafcommerce.pricing.client.domain.PriceableTarget> buildPriceableTargets(@NotNull @NotNull Collection<C> cartItems, Map<String, Integer> totalQuantityForTargetId) -
getServiceClient
-
getTotalQuantityForTargetIdMap
protected <C extends com.broadleafcommerce.cart.client.domain.CartItem> Map<String,Integer> getTotalQuantityForTargetIdMap(@NonNull @NonNull Collection<C> cartItems) Creates a map of the SKU or pricing key of an underlying item from a cart item to the total quantity of that item across all cart items. That is to say, if multiple of the same product are in the cart as separate line items, this method will return the combined quantity for that product as if it had only one line item.- Type Parameters:
C- Type of the CartItem in case of extensions- Parameters:
cartItems- Items in the cart- Returns:
- A map of the SKU or pricing key of an underlying item from a cart item to the total quantity of that item across all cart items.
-
buildPriceContextHeader
protected String buildPriceContextHeader(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext) -
getPriceContext
protected com.broadleafcommerce.pricing.client.domain.context.PriceContext getPriceContext(Locale locale, javax.money.CurrencyUnit currency) -
getPriceContext
protected com.broadleafcommerce.pricing.client.domain.context.PriceContext getPriceContext(Locale locale, javax.money.CurrencyUnit currency, @Nullable com.broadleafcommerce.cart.client.domain.Cart cart) -
getPriceInfoContext
protected com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext getPriceInfoContext(Set<com.broadleafcommerce.pricing.client.domain.PriceableTarget> priceableTargets) -
attachPricingToCartItem
protected <P extends com.broadleafcommerce.pricing.client.domain.PriceInfo> void attachPricingToCartItem(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull Collection<P> priceInfos, @Nullable String variantId) -
buildRecurringPrice
protected com.broadleafcommerce.order.common.domain.RecurringPriceDetail buildRecurringPrice(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo) Converts thePriceInfo.getRecurringPrice()into the version used byCartItem.getRecurringPrice().- Parameters:
priceInfo- Source of the price.- Returns:
- The converted
RecurringPriceDetail. - Since:
- Cart Operation Service 2.2.0, Release Train 2.2.0
-
buildUsagePrice
protected com.broadleafcommerce.order.common.domain.UsagePriceDetail buildUsagePrice(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo) Converts thePriceInfo.getUsagePrice()into the version used byCartItem.getUsagePrice().- Parameters:
priceInfo- Source of the price.- Returns:
- The converted
UsagePriceDetail. - Since:
- Cart Operation Service 2.2.0, Release Train 2.2.0
-
isDependentItem
protected boolean isDependentItem(com.broadleafcommerce.cart.client.domain.CartItem cartItem) -
addUserTargets
@Deprecated(forRemoval=true) protected void addUserTargets(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext) Deprecated, for removal: This API element is subject to removal in a future version.in favor ofaddUserTargets(PriceContext,ContextInfo)Add customer and customer segment user targets toPriceContext.getUserTargets(). Uses the current authentication token to determine principal and details.- Parameters:
priceContext- The priceContext to add user targets to
-
addUserTargets
protected void addUserTargets(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Add customer and customer segment user targets toPriceContext.getUserTargets(). Uses the current authentication token to determine principal and details.- Parameters:
priceContext- The priceContext to add user targets tocontextInfo- The context information with customer segments
-
createUserTargetRef
-
getCartItemPricingUtils
-
getProperties
-
getUserTargetGenerationService
-
addUserTargets(PriceContext,ContextInfo)