@FrameworkRestController @FrameworkMapping(value="/cart") public class ManageCartEndpoint extends Object
Constructor and Description |
---|
ManageCartEndpoint(CartResolverService cartResolverService,
CartOperationService cartOperationService,
CartTransferService cartTransferService,
CartVersionValidationService cartVersionValidationService,
GuestCartProtectionService guestCartProtectionService,
GuestCartTokenValidator guestCartTokenValidator,
ItemListAddToCartService itemListAddToCartService) |
Modifier and Type | Method and Description |
---|---|
com.broadleafcommerce.cart.client.domain.Cart |
addAttributeToCart(String cartId,
AddAttributeRequest addAttributeRequest,
boolean price,
Integer cartVersion,
String guestToken,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
ItemListAddToCartResponse |
addItemListsToCart(String cartId,
AddItemListToCartRequest addItemListToCartRequest,
Integer cartVersion,
String guestToken,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
com.broadleafcommerce.cart.client.domain.Cart |
addItemToCart(String cartId,
AddItemRequest addItemRequest,
boolean price,
Integer cartVersion,
String guestToken,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
BulkAddToCartResponse |
addManyItemsToCart(String cartId,
List<AddItemRequest> addItemRequests,
boolean price,
Integer cartVersion,
String guestToken,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
AddCodeToCartResponse |
addOfferCodeToCart(String cartId,
AddCodeRequest addCodeRequest,
boolean price,
Integer cartVersion,
String guestToken,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
protected String |
cartNotFoundMessage(String cartId) |
com.broadleafcommerce.cart.client.domain.Cart |
createCart(CartCreationRequest cartCreationRequest,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
com.broadleafcommerce.cart.client.domain.Cart |
getCart(String cartId,
Integer cartVersion,
String guestToken,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
protected CartOperationService |
getCartOperationService() |
protected CartResolverService |
getCartResolverService() |
protected CartTransferService |
getCartTransferService() |
protected CartVersionValidationService |
getCartVersionValidationService() |
protected GuestCartProtectionService |
getGuestCartProtectionService() |
protected GuestCartTokenValidator |
getGuestCartTokenValidator() |
protected ItemListAddToCartService |
getItemListAddToCartService() |
com.broadleafcommerce.cart.client.domain.Cart |
priceCart(String cartId,
PriceCartRequest priceCartRequest,
Integer cartVersion,
String guestToken,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
protected com.broadleafcommerce.cart.client.domain.Cart |
protectCartOperationForGuest(Supplier<com.broadleafcommerce.cart.client.domain.Cart> operation,
com.broadleafcommerce.cart.client.domain.Cart initialCart,
String guestToken,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Delegates to
protectCartOperationForGuest(Supplier, Cart, String, ContextInfo, Function) with the
expectation that the operation returns a Cart and the extractor is a simple identity
function. |
protected <T> T |
protectCartOperationForGuest(Supplier<T> operation,
com.broadleafcommerce.cart.client.domain.Cart initialCart,
String guestToken,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo,
Function<T,com.broadleafcommerce.cart.client.domain.Cart> cartExtractor)
Helper method to validate the guest token, execute the operation, extract the resulting cart,
protect the resulting cart, and finally returning the response.
|
protected void |
protectGuestCartIfNecessary(com.broadleafcommerce.cart.client.domain.Cart cart,
String guestToken)
If the provided cart is a guest cart, and there is no guest token, this will clear out any
customer information from the cart.
|
com.broadleafcommerce.cart.client.domain.Cart |
removeAttributeFromCart(String cartId,
String attributeKey,
boolean price,
Integer cartVersion,
String guestToken,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
com.broadleafcommerce.cart.client.domain.Cart |
removeFromCartInBulk(String cartId,
boolean price,
Integer cartVersion,
String guestToken,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo,
Set<String> cartItemIds) |
com.broadleafcommerce.cart.client.domain.Cart |
removeItemFromCart(String cartId,
String cartItemId,
boolean price,
Integer cartVersion,
String guestToken,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
com.broadleafcommerce.cart.client.domain.Cart |
removeManyItemsFromCart(String cartId,
Collection<String> cartItemIds,
boolean price,
Integer cartVersion,
String guestToken,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.
Use
removeFromCartInBulk(String, boolean, Integer, String, CustomerRef, ContextInfo, Set) .
This will allow much longer lists of IDs without worrying about whether the URL
is too long and corrects the HTTP method semantics by using POST since we're not
actually deleting a resource at the URL. |
com.broadleafcommerce.cart.client.domain.Cart |
removeOfferCodeFromCart(String cartId,
String offerCode,
boolean price,
Integer cartVersion,
String guestToken,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
protected com.broadleafcommerce.cart.client.domain.Cart |
resolveCart(String cartId,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
protected com.broadleafcommerce.cart.client.domain.Cart |
resolveCartForRead(String cartId,
Integer cartVersion,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
protected com.broadleafcommerce.cart.client.domain.Cart |
resolveCartForUpdate(String cartId,
Integer cartVersion,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
com.broadleafcommerce.cart.client.domain.Cart |
transferCart(String cartId,
Integer cartVersion,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
com.broadleafcommerce.cart.client.domain.Cart |
updateItemInCart(String cartId,
String cartItemId,
UpdateItemRequest updateItemRequest,
boolean price,
Integer cartVersion,
String guestToken,
com.broadleafcommerce.cart.client.domain.CustomerRef customer,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
protected void |
validateGuestTokenIfNecessary(com.broadleafcommerce.cart.client.domain.Cart cart,
String guestToken,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
If the provided cart is a guest cart, this will attempt to validate the guest token for the
cart.
|
public static final String BASE_URI
public ManageCartEndpoint(CartResolverService cartResolverService, CartOperationService cartOperationService, CartTransferService cartTransferService, CartVersionValidationService cartVersionValidationService, GuestCartProtectionService guestCartProtectionService, GuestCartTokenValidator guestCartTokenValidator, ItemListAddToCartService itemListAddToCartService)
@FrameworkPostMapping(consumes="application/json") public com.broadleafcommerce.cart.client.domain.Cart createCart(@RequestBody CartCreationRequest cartCreationRequest, com.broadleafcommerce.cart.client.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
@FrameworkGetMapping(value="/{cartId}") public com.broadleafcommerce.cart.client.domain.Cart getCart(@PathVariable String cartId, Integer cartVersion, String guestToken, com.broadleafcommerce.cart.client.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
@FrameworkPostMapping(value="/{cartId}/transfer") public com.broadleafcommerce.cart.client.domain.Cart transferCart(@PathVariable String cartId, Integer cartVersion, com.broadleafcommerce.cart.client.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
@FrameworkPostMapping(value="/{cartId}/pricing", consumes="application/json") public com.broadleafcommerce.cart.client.domain.Cart priceCart(@PathVariable String cartId, @RequestBody PriceCartRequest priceCartRequest, Integer cartVersion, String guestToken, com.broadleafcommerce.cart.client.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
@FrameworkPostMapping(value="/{cartId}/items", consumes="application/json") public com.broadleafcommerce.cart.client.domain.Cart addItemToCart(@PathVariable String cartId, @RequestBody AddItemRequest addItemRequest, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.cart.client.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
@FrameworkPatchMapping(value="/{cartId}/items/{cartItemId}", consumes="application/json") public com.broadleafcommerce.cart.client.domain.Cart updateItemInCart(@PathVariable String cartId, @PathVariable String cartItemId, @RequestBody UpdateItemRequest updateItemRequest, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.cart.client.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
@FrameworkDeleteMapping(value="/{cartId}/items/{cartItemId}") public com.broadleafcommerce.cart.client.domain.Cart removeItemFromCart(@PathVariable String cartId, @PathVariable String cartItemId, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.cart.client.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
@FrameworkPostMapping(value="/{cartId}/bulk-items", consumes="application/json") public BulkAddToCartResponse addManyItemsToCart(@PathVariable String cartId, @RequestBody List<AddItemRequest> addItemRequests, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.cart.client.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
@Deprecated @FrameworkDeleteMapping(value="/{cartId}/bulk-items") public com.broadleafcommerce.cart.client.domain.Cart removeManyItemsFromCart(@PathVariable String cartId, @RequestParam Collection<String> cartItemIds, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.cart.client.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
removeFromCartInBulk(String, boolean, Integer, String, CustomerRef, ContextInfo, Set)
.
This will allow much longer lists of IDs without worrying about whether the URL
is too long and corrects the HTTP method semantics by using POST since we're not
actually deleting a resource at the URL.@FrameworkPostMapping(value="/{cartId}/bulk-items/delete", consumes="application/json") public com.broadleafcommerce.cart.client.domain.Cart removeFromCartInBulk(@PathVariable String cartId, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.cart.client.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, @RequestBody Set<String> cartItemIds)
@FrameworkPostMapping(value="/{cartId}/item-lists", consumes="application/json") public ItemListAddToCartResponse addItemListsToCart(@PathVariable String cartId, @RequestBody AddItemListToCartRequest addItemListToCartRequest, Integer cartVersion, String guestToken, com.broadleafcommerce.cart.client.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
@FrameworkPostMapping(value="/{cartId}/offer-codes", consumes="application/json") public AddCodeToCartResponse addOfferCodeToCart(@PathVariable String cartId, @RequestBody AddCodeRequest addCodeRequest, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.cart.client.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
@FrameworkDeleteMapping(value="/{cartId}/offer-codes/{offerCode}") public com.broadleafcommerce.cart.client.domain.Cart removeOfferCodeFromCart(@PathVariable String cartId, @PathVariable String offerCode, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.cart.client.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
@FrameworkPostMapping(value="/{cartId}/attributes", consumes="application/json") public com.broadleafcommerce.cart.client.domain.Cart addAttributeToCart(@PathVariable String cartId, @RequestBody AddAttributeRequest addAttributeRequest, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.cart.client.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
@FrameworkDeleteMapping(value="/{cartId}/attributes/{attributeKey}") public com.broadleafcommerce.cart.client.domain.Cart removeAttributeFromCart(@PathVariable String cartId, @PathVariable String attributeKey, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.cart.client.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected com.broadleafcommerce.cart.client.domain.Cart resolveCartForRead(String cartId, @Nullable Integer cartVersion, @Nullable com.broadleafcommerce.cart.client.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected com.broadleafcommerce.cart.client.domain.Cart resolveCartForUpdate(String cartId, @Nullable Integer cartVersion, @Nullable com.broadleafcommerce.cart.client.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected com.broadleafcommerce.cart.client.domain.Cart resolveCart(@NonNull String cartId, @Nullable com.broadleafcommerce.cart.client.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected <T> T protectCartOperationForGuest(Supplier<T> operation, com.broadleafcommerce.cart.client.domain.Cart initialCart, String guestToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Function<T,com.broadleafcommerce.cart.client.domain.Cart> cartExtractor)
T
- the response typeoperation
- the operation to execute as a supplierinitialCart
- the initial cartguestToken
- the guest tokencontextInfo
- the context infocartExtractor
- extracts the cart from the resultprotected com.broadleafcommerce.cart.client.domain.Cart protectCartOperationForGuest(Supplier<com.broadleafcommerce.cart.client.domain.Cart> operation, com.broadleafcommerce.cart.client.domain.Cart initialCart, String guestToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protectCartOperationForGuest(Supplier, Cart, String, ContextInfo, Function)
with the
expectation that the operation returns a Cart
and the extractor is a simple identity
function.operation
- the operation to execute as a supplierinitialCart
- the initial cartguestToken
- the guest tokencontextInfo
- the context infoprotected void validateGuestTokenIfNecessary(com.broadleafcommerce.cart.client.domain.Cart cart, String guestToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
cart
- the cartguestToken
- the guest tokencontextInfo
- the context infoprotected void protectGuestCartIfNecessary(com.broadleafcommerce.cart.client.domain.Cart cart, String guestToken)
Note, this method does not persist the changes to the cart, and is only intended to be used as a last step before returning the cart object.
cart
- the cartguestToken
- the guest tokenprotected CartResolverService getCartResolverService()
protected CartOperationService getCartOperationService()
protected CartTransferService getCartTransferService()
protected CartVersionValidationService getCartVersionValidationService()
protected GuestCartProtectionService getGuestCartProtectionService()
protected GuestCartTokenValidator getGuestCartTokenValidator()
protected ItemListAddToCartService getItemListAddToCartService()
Copyright © 2021. All rights reserved.