Class ManageCartEndpoint

java.lang.Object
com.broadleafcommerce.cartoperation.web.endpoint.ManageCartEndpoint

@FrameworkRestController @FrameworkMapping("/cart") public class ManageCartEndpoint extends Object
Author:
Nick Crum (ncrum)
  • Field Details

  • Constructor Details

  • Method Details

    • createCart

      @FrameworkPostMapping(consumes="application/json") public com.broadleafcommerce.cart.client.domain.Cart createCart(@RequestBody CartCreationRequest cartCreationRequest, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getCart

      @Deprecated public com.broadleafcommerce.cart.client.domain.Cart getCart(@PathVariable String cartId, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Deprecated.
      Deprecated as of 1.7.0-GA. Use getCart(String, String, CustomerRef, ContextInfo). The cartVersion should not be included as it is irrelevant for reads. It's only relevant for cart-modification requests.
    • getMyCarts

      @Policy(permissionRoots={"CUSTOMER","CUSTOMER_PROFILE"}) @FrameworkGetMapping(params="all=true") public org.springframework.data.domain.Page<com.broadleafcommerce.cart.client.domain.Cart> getMyCarts(cz.jirutka.rsql.parser.ast.Node filters, @PageableDefault(size=50,sort="contextId",direction=ASC) org.springframework.data.domain.Pageable page, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getCart

      @FrameworkGetMapping("/{cartId}") public com.broadleafcommerce.cart.client.domain.Cart getCart(@PathVariable String cartId, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • transferCart

      @FrameworkPostMapping("/{cartId}/transfer") public com.broadleafcommerce.cart.client.domain.Cart transferCart(@PathVariable String cartId, Integer cartVersion, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • setDefaultCart

      @FrameworkPostMapping("/{cartId}/make-default") public com.broadleafcommerce.cart.client.domain.Cart setDefaultCart(@PathVariable String cartId, Integer cartToMakeDefaultVersion, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • priceCart

      @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.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • addItemToCart

      @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.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • updateItemInCart

      @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.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • updateStatus

      @FrameworkPatchMapping(value="/{cartId}/status", consumes="application/json") public com.broadleafcommerce.cart.client.domain.Cart updateStatus(@PathVariable String cartId, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, @RequestBody UpdateCartStatusRequest request)
    • removeItemFromCart

      @FrameworkDeleteMapping("/{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.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • addManyItemsToCart

      @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.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • removeManyItemsFromCart

      @Deprecated @FrameworkDeleteMapping("/{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.order.common.domain.CustomerRef customer, @ContextOperation 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.
    • removeFromCartInBulk

      @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.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, @RequestBody Set<String> cartItemIds)
    • addItemListsToCart

      @FrameworkPostMapping(value="/{cartId}/item-lists", consumes="application/json") public ItemListAddToCartResponse addItemListsToCart(@PathVariable String cartId, @RequestBody AddItemListToCartRequest addItemListToCartRequest, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • addOfferCodeToCart

      @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.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • removeOfferCodeFromCart

      @FrameworkDeleteMapping("/{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.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • addAttributeToCart

      @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.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • removeAttributeFromCart

      @FrameworkDeleteMapping("/{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.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • resolveCartForRead

      protected com.broadleafcommerce.cart.client.domain.Cart resolveCartForRead(String cartId, @Nullable Integer cartVersion, @Nullable com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • resolveCartForUpdate

      @Deprecated(since="1.8.0", forRemoval=true) protected com.broadleafcommerce.cart.client.domain.Cart resolveCartForUpdate(String cartId, @Nullable Integer cartVersion, @Nullable com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • resolveCart

      protected com.broadleafcommerce.cart.client.domain.Cart resolveCart(@NonNull String cartId, @Nullable com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • protectCartOperationForGuest

      @Deprecated 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.
      Type Parameters:
      T - the response type
      Parameters:
      operation - the operation to execute as a supplier
      initialCart - the initial cart
      guestToken - the guest token
      contextInfo - the context info
      cartExtractor - extracts the cart from the result
      Returns:
      the response
    • protectCartOperationForGuest

      @Deprecated 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.
      Parameters:
      operation - the operation to execute as a supplier
      initialCart - the initial cart
      guestToken - the guest token
      contextInfo - the context info
      Returns:
      the response
    • protectCartOperationForGuest

      protected <T> T protectCartOperationForGuest(Function<com.broadleafcommerce.cart.client.domain.Cart,T> operation, com.broadleafcommerce.cart.client.domain.Cart initialCart, String guestToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Helper method to validate the guest token, protect the resolved cart, & execute the operation.
      Type Parameters:
      T - the response type
      Parameters:
      operation - the operation to execute as a function
      initialCart - the initial cart
      guestToken - the guest token
      contextInfo - the context info
      Returns:
      the response
    • validateGuestTokenIfNecessary

      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.
      Parameters:
      cart - the cart
      guestToken - the guest token
      contextInfo - the context info
    • protectGuestCartIfNecessary

      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.

      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.

      Parameters:
      cart - the cart
      guestToken - the guest token
    • protectGuestCartIfNecessary

      protected com.broadleafcommerce.cart.client.domain.Cart protectGuestCartIfNecessary(com.broadleafcommerce.cart.client.domain.Cart cart, String guestToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      If the provided cart is a guest cart, and there is no guest token, then this will produce a cloned guest cart, excluding any customer data.
      Parameters:
      cart - the cart
      guestToken - the guest token
      contextInfo - the context info
      Returns:
      the protected cart
    • cartNotFoundMessage

      protected String cartNotFoundMessage(String cartId)
    • getCartResolverService

      protected CartResolverService getCartResolverService()
    • getCartOperationService

      protected CartOperationService getCartOperationService()
    • getCartTransferService

      protected CartTransferService getCartTransferService()
    • getCartVersionValidationService

      protected CartVersionValidationService getCartVersionValidationService()
    • getGuestCartProtectionService

      protected GuestCartProtectionService getGuestCartProtectionService()
    • getGuestCartTokenValidator

      protected GuestCartTokenValidator getGuestCartTokenValidator()
    • getItemListAddToCartService

      protected ItemListAddToCartService getItemListAddToCartService()