java.lang.Object
com.broadleafcommerce.subscriptionoperation.web.domain.AddItemRequest
All Implemented Interfaces:
Serializable

public class AddItemRequest extends Object implements Serializable
A request DTO for adding an item to a cart.
Author:
Nathan Moore (nathandmoore)
See Also:
  • Constructor Details

    • AddItemRequest

      public AddItemRequest()
  • Method Details

    • getVariantId

      public String getVariantId()
      The id of the variant for this add item request. Used to retrieve variant information for the cart item.
      Returns:
      The id of the variant for this add item request. Used to retrieve variant information for the cart item.
    • getProductId

      public String getProductId()
      The id of the product for this add item request. Used to retrieve product information for the cart item.
      Returns:
      The id of the product for this add item request. Used to retrieve product information for the cart item.
    • getSku

      public String getSku()
      The SKU code for the item (e.g., Product or Variant).
      Returns:
      SKU code for the item
    • getItemType

      public String getItemType()
      The type of this item (e.g. Standard or Custom Quote Item). Defaults to DefaultCartItemTypes.STANDARD.
      Returns:
      type of this item
    • getQuantity

      public int getQuantity()
      The quantity of this item to be added to the Cart.
      Returns:
      The quantity of this item to be added to the Cart.
    • getOriginalSubscriptionItemQuantity

      public int getOriginalSubscriptionItemQuantity()
      The original quantity of the SubscriptionItem. This is different from quantity as quantity can be updated to "revert" the scaling based on the parent item quantity, while this field is the original SubscriptionItem quantity that is never changed.

      This field is used to revert the quantity scaling based on the parent item for the dependent item, particularly important for nested dependent item scenarios. For example, let's say we have the following nested dependent item scenario:

      In cart, we have the following cart item structure:

      • RootCartItem, quantity = 3
        • DepCartItem, quantity = 2
          • DepCartItemOfDepCartItem, quantity = 1

      Since each dependent item's quantity is scaled based on the quantity of its parent. When converted into SubscriptionItems, the quantities becomes:

      • RootItem, quantity = 3
      • DepItem, quantity = 6
      • DepItemOfDepItem, quantity = 6

      So when we are converting the SubscriptionItems into AddItemRequests, we need to revert the scaling of quantities, which can be problematic if we use quantity to de-scale the quantity in a nested dependent item scenario, as the parent's quantity is already reverted by the time it's used to revert its dependent item's quantity.

      This field is only relevant for the internal working of the system and is therefore marked with JsonIgnore.

    • getCurrency

      public javax.money.CurrencyUnit getCurrency()
      The CurrencyUnit of the item to be added to the Cart.
    • getItemAttributes

      public Map<String,Object> getItemAttributes()
      Miscellaneous attributes that should be copied to the CartItem.getAttributes() for this request.
      Returns:
      Miscellaneous attributes that should be copied to the CartItem.getAttributes() for this request.
    • getItemInternalAttributes

      public Map<String,Object> getItemInternalAttributes()
      Miscellaneous internal attributes that should be copied to the CartItem.getInternalAttributes() for this request.
      Returns:
      Miscellaneous internal attributes that should be copied to the CartItem.getInternalAttributes() for this request.
    • getItemAttributeChoices

      public Map<String,String> getItemAttributeChoices()
      Attribute choices that should be copied to CartItem.getAttributeChoices() for this request.
      Returns:
      Attribute choices that should be copied to CartItem.getAttributeChoices() for this request.
    • getCartAttributes

      public Map<String,Object> getCartAttributes()
      Attributes that should be copied to the Cart.getAttributes() for this request.
      Returns:
      Attributes that should be copied to the Cart.getAttributes() for this request.
    • getDependentCartItems

      public List<AddItemRequest> getDependentCartItems()
      A list of additional AddItemRequests that should be processed as dependent items of the resulting parent item of this current AddItemRequest.
      Returns:
      A list of additional AddItemRequests that should be processed as dependent items of the resulting parent item of this current AddItemRequest.
    • getItemChoiceKey

      public String getItemChoiceKey()
      If this AddItemRequest is one within getDependentCartItems(), this is the key to use to relate to this CartItem to a configured product item choice.
      Returns:
      The key to use to relate to this CartItem to a configured product item choice.
    • getMerchandisingContext

      public String getMerchandisingContext()
      The value that should be mapped to CartItem.getMerchandisingContext(). This holds the selector or merchandising product's id.
      Returns:
      The context of the item signifying where it's added from
    • getAdditionalAttributes

      public Map<String,Object> getAdditionalAttributes()
      Miscellaneous attributes that can be set to this request in order to inform business logic for adding a CartItem.
      Returns:
      Miscellaneous attributes that can be set to this request in order to inform business logic for adding a CartItem.
    • getTermDurationType

      public String getTermDurationType()
      The type of the term duration selected for the item, if any. Some items may have terms to allow certain pricing for the user. This indicates the type of duration, e.g., DAYS, WEEKS, MONTHS, YEARS, for the selected term. For example, choosing between paying the full price for a device (no terms) vs splitting payment over 36 months (termDurationLength of 36 and termDurationType of MONTHS).
      See Also:
      • termDurationLength
    • getTermDurationLength

      public Integer getTermDurationLength()
      The length of the term duration selected for the item, if any. Some items may have terms to allow certain pricing for the user. This indicates the length of duration for the selected term. For example, choosing between paying the full price for a device (no terms) vs splitting payment over 36 months (termDurationLength of 36 and termDurationType of MONTHS).
      See Also:
      • termDurationType
    • getRecurringPeriodFrequency

      public Integer getRecurringPeriodFrequency()
      The frequency of the recurring period, e.g., if this is 1 and recurringPeriodType is MONTHLY, then the recurring price should be charged every 1 month.
      See Also:
      • recurringPeriodType
    • getRecurringPeriodType

      public String getRecurringPeriodType()
      The period type for the recurring price, e.g. MONTHLY, QUARTERLY, ANNUALLY.
      See Also:
      • recurringPeriodFrequency
    • getVersion

      public Integer getVersion()
      The version of the cart being modified. Not needed for creation requests.
    • getNonCatalogItemDetails

      public NonCatalogItemDetails getNonCatalogItemDetails()
      Details of the item not present in a catalog.

      This is used as the cartItem in the InitiateCancelSubscriptionHandler that is added to the cart which holds subscription cancellation related details.

      See Also:
    • getPaymentStrategy

      public String getPaymentStrategy()
      Declares that payments made against a subscription are going towards the goods/services rendered in the previous vs current period.
    • setVariantId

      public void setVariantId(String variantId)
      The id of the variant for this add item request. Used to retrieve variant information for the cart item.
      Parameters:
      variantId - The id of the variant for this add item request. Used to retrieve variant information for the cart item.
    • setProductId

      public void setProductId(String productId)
      The id of the product for this add item request. Used to retrieve product information for the cart item.
      Parameters:
      productId - The id of the product for this add item request. Used to retrieve product information for the cart item.
    • setSku

      public void setSku(String sku)
      The SKU code for the item (e.g., Product or Variant).
      Parameters:
      sku - SKU code for the item
    • setItemType

      public void setItemType(String itemType)
      The type of this item (e.g. Standard or Custom Quote Item). Defaults to DefaultCartItemTypes.STANDARD.
      Parameters:
      type - type of this item
    • setQuantity

      public void setQuantity(int quantity)
      The quantity of this item to be added to the Cart.
      Parameters:
      quantity - The quantity of this item to be added to the Cart.
    • setOriginalSubscriptionItemQuantity

      public void setOriginalSubscriptionItemQuantity(int originalSubscriptionItemQuantity)
      The original quantity of the SubscriptionItem. This is different from quantity as quantity can be updated to "revert" the scaling based on the parent item quantity, while this field is the original SubscriptionItem quantity that is never changed.

      This field is used to revert the quantity scaling based on the parent item for the dependent item, particularly important for nested dependent item scenarios. For example, let's say we have the following nested dependent item scenario:

      In cart, we have the following cart item structure:

      • RootCartItem, quantity = 3
        • DepCartItem, quantity = 2
          • DepCartItemOfDepCartItem, quantity = 1

      Since each dependent item's quantity is scaled based on the quantity of its parent. When converted into SubscriptionItems, the quantities becomes:

      • RootItem, quantity = 3
      • DepItem, quantity = 6
      • DepItemOfDepItem, quantity = 6

      So when we are converting the SubscriptionItems into AddItemRequests, we need to revert the scaling of quantities, which can be problematic if we use quantity to de-scale the quantity in a nested dependent item scenario, as the parent's quantity is already reverted by the time it's used to revert its dependent item's quantity.

      This field is only relevant for the internal working of the system and is therefore marked with JsonIgnore.

    • setCurrency

      public void setCurrency(javax.money.CurrencyUnit currency)
      The CurrencyUnit of the item to be added to the Cart.
    • setItemAttributes

      public void setItemAttributes(Map<String,Object> itemAttributes)
      Miscellaneous attributes that should be copied to the CartItem.getAttributes() for this request.
      Parameters:
      itemAttributes - Miscellaneous attributes that should be copied to the CartItem.getAttributes() for this request.
    • setItemInternalAttributes

      public void setItemInternalAttributes(Map<String,Object> itemInternalAttributes)
      Miscellaneous internal attributes that should be copied to the CartItem.getInternalAttributes() for this request.
      Parameters:
      itemAttributes - Miscellaneous internal attributes that should be copied to the CartItem.getInternalAttributes() for this request.
    • setItemAttributeChoices

      public void setItemAttributeChoices(Map<String,String> itemAttributeChoices)
      Attribute choices that should be copied to CartItem.getAttributeChoices() for this request.
      Parameters:
      itemAttributeChoices - Attribute choices that should be copied to CartItem.getAttributeChoices() for this request.
    • setCartAttributes

      public void setCartAttributes(Map<String,Object> cartAttributes)
      Attributes that should be copied to the Cart.getAttributes() for this request.
      Parameters:
      cartAttributes - Attributes that should be copied to the Cart.getAttributes() for this request.
    • setDependentCartItems

      public void setDependentCartItems(List<AddItemRequest> dependentCartItems)
      A list of additional AddItemRequests that should be processed as dependent items of the resulting parent item of this current AddItemRequest.
      Parameters:
      dependentCartItems - A list of additional AddItemRequests that should be processed as dependent items of the resulting parent item of this current AddItemRequest.
    • setItemChoiceKey

      public void setItemChoiceKey(String itemChoiceKey)
      If this AddItemRequest is one within getDependentCartItems(), this is the key to use to relate to this CartItem to a configured product item choice.
      Parameters:
      itemChoiceKey - The key to use to relate to this CartItem to a configured product item choice.
    • setMerchandisingContext

      public void setMerchandisingContext(String merchandisingContext)
      The value that should be mapped to CartItem.getMerchandisingContext(). This holds the selector or merchandising product's id.
      Parameters:
      merchandisingContext - The context of the item signifying where it's added from
    • setAdditionalAttributes

      public void setAdditionalAttributes(Map<String,Object> additionalAttributes)
      Miscellaneous attributes that can be set to this request in order to inform business logic for adding a CartItem.
      Parameters:
      additionalAttributes - Miscellaneous attributes that can be set to this request in order to inform business logic for adding a CartItem.
    • setTermDurationType

      public void setTermDurationType(String termDurationType)
      The type of the term duration selected for the item, if any. Some items may have terms to allow certain pricing for the user. This indicates the type of duration, e.g., DAYS, WEEKS, MONTHS, YEARS, for the selected term. For example, choosing between paying the full price for a device (no terms) vs splitting payment over 36 months (termDurationLength of 36 and termDurationType of MONTHS).
      See Also:
      • termDurationLength
    • setTermDurationLength

      public void setTermDurationLength(Integer termDurationLength)
      The length of the term duration selected for the item, if any. Some items may have terms to allow certain pricing for the user. This indicates the length of duration for the selected term. For example, choosing between paying the full price for a device (no terms) vs splitting payment over 36 months (termDurationLength of 36 and termDurationType of MONTHS).
      See Also:
      • termDurationType
    • setRecurringPeriodFrequency

      public void setRecurringPeriodFrequency(Integer recurringPeriodFrequency)
      The frequency of the recurring period, e.g., if this is 1 and recurringPeriodType is MONTHLY, then the recurring price should be charged every 1 month.
      See Also:
      • recurringPeriodType
    • setRecurringPeriodType

      public void setRecurringPeriodType(String recurringPeriodType)
      The period type for the recurring price, e.g. MONTHLY, QUARTERLY, ANNUALLY.
      See Also:
      • recurringPeriodFrequency
    • setVersion

      public void setVersion(Integer version)
      The version of the cart being modified. Not needed for creation requests.
    • setNonCatalogItemDetails

      public void setNonCatalogItemDetails(NonCatalogItemDetails nonCatalogItemDetails)
      Details of the item not present in a catalog.

      This is used as the cartItem in the InitiateCancelSubscriptionHandler that is added to the cart which holds subscription cancellation related details.

      See Also:
    • setPaymentStrategy

      public void setPaymentStrategy(String paymentStrategy)
      Declares that payments made against a subscription are going towards the goods/services rendered in the previous vs current period.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object