Class DiscountCodeDraftBuilder

java.lang.Object
com.commercetools.api.models.discount_code.DiscountCodeDraftBuilder
All Implemented Interfaces:
Builder<DiscountCodeDraft>

public class DiscountCodeDraftBuilder extends Object implements Builder<DiscountCodeDraft>
DiscountCodeDraftBuilder
Example to create an instance using the builder pattern

     DiscountCodeDraft discountCodeDraft = DiscountCodeDraft.builder()
             .code("{code}")
             .plusCartDiscounts(cartDiscountsBuilder -> cartDiscountsBuilder)
             .build()
 
  • Constructor Details

    • DiscountCodeDraftBuilder

      public DiscountCodeDraftBuilder()
  • Method Details

    • key

      public DiscountCodeDraftBuilder key(@Nullable String key)

      User-defined unique identifier for the DiscountCode.

      This field is optional for backwards compatibility reasons, but we strongly recommend setting it. Keys are mandatory for importing Discount Codes with the Import API and the Merchant Center.

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

      Name of the DiscountCode.

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

      Name of the DiscountCode.

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

      public DiscountCodeDraftBuilder name(@Nullable LocalizedString name)

      Name of the DiscountCode.

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

      Description of the DiscountCode.

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

      Description of the DiscountCode.

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

      public DiscountCodeDraftBuilder description(@Nullable LocalizedString description)

      Description of the DiscountCode.

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

      public DiscountCodeDraftBuilder code(String code)

      User-defined unique identifier for the DiscountCode that can be added to the Cart to apply the related CartDiscounts. It cannot be modified after the DiscountCode is created.

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

      public DiscountCodeDraftBuilder cartDiscounts(CartDiscountResourceIdentifier... cartDiscounts)

      Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.

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

      public DiscountCodeDraftBuilder cartDiscounts(List<CartDiscountResourceIdentifier> cartDiscounts)

      Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.

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

      public DiscountCodeDraftBuilder plusCartDiscounts(CartDiscountResourceIdentifier... cartDiscounts)

      Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.

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

      Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.

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

      Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.

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

      Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.

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

      Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.

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

      public DiscountCodeDraftBuilder cartPredicate(@Nullable String cartPredicate)

      DiscountCode can only be applied to Carts that match this predicate.

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

      public DiscountCodeDraftBuilder isActive(@Nullable Boolean isActive)

      Only active DiscountCodes can be applied to the Cart.

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

      public DiscountCodeDraftBuilder maxApplications(@Nullable Long maxApplications)

      Number of times the DiscountCode can be applied.

      If not set, the DiscountCode can be applied any number of times.

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

      public DiscountCodeDraftBuilder maxApplicationsPerCustomer(@Nullable Long maxApplicationsPerCustomer)

      Number of times the DiscountCode can be applied per Customer.

      If not set, the DiscountCode can be applied any number of times.

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

      Custom Fields for the DiscountCode.

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

      Custom Fields for the DiscountCode.

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

      public DiscountCodeDraftBuilder custom(@Nullable CustomFieldsDraft custom)

      Custom Fields for the DiscountCode.

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

      public DiscountCodeDraftBuilder groups(@Nullable String... groups)

      Groups to which the DiscountCode will belong to.

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

      public DiscountCodeDraftBuilder groups(@Nullable List<String> groups)

      Groups to which the DiscountCode will belong to.

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

      public DiscountCodeDraftBuilder plusGroups(@Nullable String... groups)

      Groups to which the DiscountCode will belong to.

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

      public DiscountCodeDraftBuilder validFrom(@Nullable ZonedDateTime validFrom)

      Date and time (UTC) from which the DiscountCode is effective. Must be earlier than validUntil.

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

      public DiscountCodeDraftBuilder validUntil(@Nullable ZonedDateTime validUntil)

      Date and time (UTC) until which the DiscountCode is effective. Must be later than validFrom.

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

      @Nullable public String getKey()

      User-defined unique identifier for the DiscountCode.

      This field is optional for backwards compatibility reasons, but we strongly recommend setting it. Keys are mandatory for importing Discount Codes with the Import API and the Merchant Center.

      Returns:
      key
    • getName

      @Nullable public LocalizedString getName()

      Name of the DiscountCode.

      Returns:
      name
    • getDescription

      @Nullable public LocalizedString getDescription()

      Description of the DiscountCode.

      Returns:
      description
    • getCode

      public String getCode()

      User-defined unique identifier for the DiscountCode that can be added to the Cart to apply the related CartDiscounts. It cannot be modified after the DiscountCode is created.

      Returns:
      code
    • getCartDiscounts

      public List<CartDiscountResourceIdentifier> getCartDiscounts()

      Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.

      Returns:
      cartDiscounts
    • getCartPredicate

      @Nullable public String getCartPredicate()

      DiscountCode can only be applied to Carts that match this predicate.

      Returns:
      cartPredicate
    • getIsActive

      @Nullable public Boolean getIsActive()

      Only active DiscountCodes can be applied to the Cart.

      Returns:
      isActive
    • getMaxApplications

      @Nullable public Long getMaxApplications()

      Number of times the DiscountCode can be applied.

      If not set, the DiscountCode can be applied any number of times.

      Returns:
      maxApplications
    • getMaxApplicationsPerCustomer

      @Nullable public Long getMaxApplicationsPerCustomer()

      Number of times the DiscountCode can be applied per Customer.

      If not set, the DiscountCode can be applied any number of times.

      Returns:
      maxApplicationsPerCustomer
    • getCustom

      @Nullable public CustomFieldsDraft getCustom()

      Custom Fields for the DiscountCode.

      Returns:
      custom
    • getGroups

      @Nullable public List<String> getGroups()

      Groups to which the DiscountCode will belong to.

      Returns:
      groups
    • getValidFrom

      @Nullable public ZonedDateTime getValidFrom()

      Date and time (UTC) from which the DiscountCode is effective. Must be earlier than validUntil.

      Returns:
      validFrom
    • getValidUntil

      @Nullable public ZonedDateTime getValidUntil()

      Date and time (UTC) until which the DiscountCode is effective. Must be later than validFrom.

      Returns:
      validUntil
    • build

      public DiscountCodeDraft build()
      builds DiscountCodeDraft with checking for non-null required values
      Specified by:
      build in interface Builder<DiscountCodeDraft>
      Returns:
      DiscountCodeDraft
    • buildUnchecked

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

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

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