Class CartDiscountDraftBuilder

java.lang.Object
com.commercetools.api.models.cart_discount.CartDiscountDraftBuilder
All Implemented Interfaces:
io.vrap.rmf.base.client.Builder<CartDiscountDraft>

public class CartDiscountDraftBuilder extends Object implements io.vrap.rmf.base.client.Builder<CartDiscountDraft>
CartDiscountDraftBuilder
Example to create an instance using the builder pattern

     CartDiscountDraft cartDiscountDraft = CartDiscountDraft.builder()
             .name(nameBuilder -> nameBuilder)
             .value(valueBuilder -> valueBuilder)
             .cartPredicate("{cartPredicate}")
             .sortOrder("{sortOrder}")
             .build()
 
  • Constructor Details

    • CartDiscountDraftBuilder

      public CartDiscountDraftBuilder()
  • Method Details

    • name

      Name of the CartDiscount.

      Parameters:
      builder - function to build the name value
      Returns:
      Builder
    • withName

      Name of the CartDiscount.

      Parameters:
      builder - function to build the name value
      Returns:
      Builder
    • name

      Name of the CartDiscount.

      Parameters:
      name - value to be set
      Returns:
      Builder
    • key

      User-defined unique identifier for the CartDiscount.

      Parameters:
      key - value to be set
      Returns:
      Builder
    • description

      Description of the CartDiscount.

      Parameters:
      builder - function to build the description value
      Returns:
      Builder
    • withDescription

      Description of the CartDiscount.

      Parameters:
      builder - function to build the description value
      Returns:
      Builder
    • description

      public CartDiscountDraftBuilder description(@Nullable LocalizedString description)

      Description of the CartDiscount.

      Parameters:
      description - value to be set
      Returns:
      Builder
    • value

      Effect of the CartDiscount on the target.

      Parameters:
      value - value to be set
      Returns:
      Builder
    • value

      public CartDiscountDraftBuilder value(Function<CartDiscountValueDraftBuilder,io.vrap.rmf.base.client.Builder<? extends CartDiscountValueDraft>> builder)

      Effect of the CartDiscount on the target.

      Parameters:
      builder - function to build the value value
      Returns:
      Builder
    • cartPredicate

      public CartDiscountDraftBuilder cartPredicate(String cartPredicate)

      Valid Cart Predicate.

      Parameters:
      cartPredicate - value to be set
      Returns:
      Builder
    • target

      Segment of the Cart that will be discounted.

      Must not be set if the value is giftLineItem.

      Parameters:
      target - value to be set
      Returns:
      Builder
    • target

      public CartDiscountDraftBuilder target(Function<CartDiscountTargetBuilder,io.vrap.rmf.base.client.Builder<? extends CartDiscountTarget>> builder)

      Segment of the Cart that will be discounted.

      Must not be set if the value is giftLineItem.

      Parameters:
      builder - function to build the target value
      Returns:
      Builder
    • sortOrder

      public CartDiscountDraftBuilder sortOrder(String sortOrder)

      Value between 0 and 1. A Discount with a higher sortOrder is prioritized. The sort order must be unambiguous among all CartDiscounts.

      Parameters:
      sortOrder - value to be set
      Returns:
      Builder
    • stores

      • If defined, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
      • If not defined, the Cart Discount applies on all Carts, irrespective of a Store.

      If the referenced Stores exceed the limit, a MaxStoreReferencesReached error is returned.

      If the referenced Stores exceed the limit for Cart Discounts that do not require a Discount Code, a StoreCartDiscountsLimitReached error is returned.

      Parameters:
      stores - value to be set
      Returns:
      Builder
    • stores

      • If defined, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
      • If not defined, the Cart Discount applies on all Carts, irrespective of a Store.

      If the referenced Stores exceed the limit, a MaxStoreReferencesReached error is returned.

      If the referenced Stores exceed the limit for Cart Discounts that do not require a Discount Code, a StoreCartDiscountsLimitReached error is returned.

      Parameters:
      stores - value to be set
      Returns:
      Builder
    • plusStores

      • If defined, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
      • If not defined, the Cart Discount applies on all Carts, irrespective of a Store.

      If the referenced Stores exceed the limit, a MaxStoreReferencesReached error is returned.

      If the referenced Stores exceed the limit for Cart Discounts that do not require a Discount Code, a StoreCartDiscountsLimitReached error is returned.

      Parameters:
      stores - value to be set
      Returns:
      Builder
    • plusStores

      • If defined, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
      • If not defined, the Cart Discount applies on all Carts, irrespective of a Store.

      If the referenced Stores exceed the limit, a MaxStoreReferencesReached error is returned.

      If the referenced Stores exceed the limit for Cart Discounts that do not require a Discount Code, a StoreCartDiscountsLimitReached error is returned.

      Parameters:
      builder - function to build the stores value
      Returns:
      Builder
    • withStores

      • If defined, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
      • If not defined, the Cart Discount applies on all Carts, irrespective of a Store.

      If the referenced Stores exceed the limit, a MaxStoreReferencesReached error is returned.

      If the referenced Stores exceed the limit for Cart Discounts that do not require a Discount Code, a StoreCartDiscountsLimitReached error is returned.

      Parameters:
      builder - function to build the stores value
      Returns:
      Builder
    • addStores

      • If defined, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
      • If not defined, the Cart Discount applies on all Carts, irrespective of a Store.

      If the referenced Stores exceed the limit, a MaxStoreReferencesReached error is returned.

      If the referenced Stores exceed the limit for Cart Discounts that do not require a Discount Code, a StoreCartDiscountsLimitReached error is returned.

      Parameters:
      builder - function to build the stores value
      Returns:
      Builder
    • setStores

      • If defined, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
      • If not defined, the Cart Discount applies on all Carts, irrespective of a Store.

      If the referenced Stores exceed the limit, a MaxStoreReferencesReached error is returned.

      If the referenced Stores exceed the limit for Cart Discounts that do not require a Discount Code, a StoreCartDiscountsLimitReached error is returned.

      Parameters:
      builder - function to build the stores value
      Returns:
      Builder
    • isActive

      public CartDiscountDraftBuilder isActive(@Nullable Boolean isActive)

      Only active Discounts can be applied to the Cart. If the limit for active Cart Discounts is reached, a MaxCartDiscountsReached error is returned.

      Parameters:
      isActive - value to be set
      Returns:
      Builder
    • validFrom

      public CartDiscountDraftBuilder validFrom(@Nullable ZonedDateTime validFrom)

      Date and time (UTC) from which the Discount is effective.

      Parameters:
      validFrom - value to be set
      Returns:
      Builder
    • validUntil

      public CartDiscountDraftBuilder validUntil(@Nullable ZonedDateTime validUntil)

      Date and time (UTC) until which the Discount is effective.

      Parameters:
      validUntil - value to be set
      Returns:
      Builder
    • requiresDiscountCode

      public CartDiscountDraftBuilder requiresDiscountCode(@Nullable Boolean requiresDiscountCode)

      States whether the Discount can only be used in a connection with a DiscountCode.

      Parameters:
      requiresDiscountCode - value to be set
      Returns:
      Builder
    • stackingMode

      public CartDiscountDraftBuilder stackingMode(@Nullable StackingMode stackingMode)

      Specifies whether the application of this discount causes the following discounts to be ignored.

      Parameters:
      stackingMode - value to be set
      Returns:
      Builder
    • custom

      Custom Fields of the CartDiscount.

      Parameters:
      builder - function to build the custom value
      Returns:
      Builder
    • withCustom

      Custom Fields of the CartDiscount.

      Parameters:
      builder - function to build the custom value
      Returns:
      Builder
    • custom

      Custom Fields of the CartDiscount.

      Parameters:
      custom - value to be set
      Returns:
      Builder
    • getName

      public LocalizedString getName()

      Name of the CartDiscount.

      Returns:
      name
    • getKey

      @Nullable public String getKey()

      User-defined unique identifier for the CartDiscount.

      Returns:
      key
    • getDescription

      @Nullable public LocalizedString getDescription()

      Description of the CartDiscount.

      Returns:
      description
    • getValue

      public CartDiscountValueDraft getValue()

      Effect of the CartDiscount on the target.

      Returns:
      value
    • getCartPredicate

      public String getCartPredicate()

      Valid Cart Predicate.

      Returns:
      cartPredicate
    • getTarget

      @Nullable public CartDiscountTarget getTarget()

      Segment of the Cart that will be discounted.

      Must not be set if the value is giftLineItem.

      Returns:
      target
    • getSortOrder

      public String getSortOrder()

      Value between 0 and 1. A Discount with a higher sortOrder is prioritized. The sort order must be unambiguous among all CartDiscounts.

      Returns:
      sortOrder
    • getStores

      @Nullable public List<StoreResourceIdentifier> getStores()
      • If defined, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
      • If not defined, the Cart Discount applies on all Carts, irrespective of a Store.

      If the referenced Stores exceed the limit, a MaxStoreReferencesReached error is returned.

      If the referenced Stores exceed the limit for Cart Discounts that do not require a Discount Code, a StoreCartDiscountsLimitReached error is returned.

      Returns:
      stores
    • getIsActive

      @Nullable public Boolean getIsActive()

      Only active Discounts can be applied to the Cart. If the limit for active Cart Discounts is reached, a MaxCartDiscountsReached error is returned.

      Returns:
      isActive
    • getValidFrom

      @Nullable public ZonedDateTime getValidFrom()

      Date and time (UTC) from which the Discount is effective.

      Returns:
      validFrom
    • getValidUntil

      @Nullable public ZonedDateTime getValidUntil()

      Date and time (UTC) until which the Discount is effective.

      Returns:
      validUntil
    • getRequiresDiscountCode

      @Nullable public Boolean getRequiresDiscountCode()

      States whether the Discount can only be used in a connection with a DiscountCode.

      Returns:
      requiresDiscountCode
    • getStackingMode

      @Nullable public StackingMode getStackingMode()

      Specifies whether the application of this discount causes the following discounts to be ignored.

      Returns:
      stackingMode
    • getCustom

      @Nullable public CustomFieldsDraft getCustom()

      Custom Fields of the CartDiscount.

      Returns:
      custom
    • build

      public CartDiscountDraft build()
      builds CartDiscountDraft with checking for non-null required values
      Specified by:
      build in interface io.vrap.rmf.base.client.Builder<CartDiscountDraft>
      Returns:
      CartDiscountDraft
    • buildUnchecked

      public CartDiscountDraft buildUnchecked()
      builds CartDiscountDraft without checking for non-null required values
      Returns:
      CartDiscountDraft
    • of

      public static CartDiscountDraftBuilder of()
      factory method for an instance of CartDiscountDraftBuilder
      Returns:
      builder
    • of

      public static CartDiscountDraftBuilder of(CartDiscountDraft template)
      create builder for CartDiscountDraft instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder