Interface DiscountCodeDraft

All Superinterfaces:
CustomizableDraft<DiscountCodeDraft>, Draft<DiscountCodeDraft>

public interface DiscountCodeDraft extends CustomizableDraft<DiscountCodeDraft>, Draft<DiscountCodeDraft>
DiscountCodeDraft
Example to create an instance using the builder pattern

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

    • getKey

      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

      @Valid @Valid LocalizedString getName()

      Name of the DiscountCode.

      Returns:
      name
    • getDescription

      @Valid @Valid LocalizedString getDescription()

      Description of the DiscountCode.

      Returns:
      description
    • getCode

      @NotNull @NotNull 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

      @NotNull @Valid @NotNull @Valid List<CartDiscountResourceIdentifier> getCartDiscounts()

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

      Returns:
      cartDiscounts
    • getCartPredicate

      String getCartPredicate()

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

      Returns:
      cartPredicate
    • getIsActive

      Boolean getIsActive()

      Only active DiscountCodes can be applied to the Cart.

      Returns:
      isActive
    • getMaxApplications

      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

      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

      @Valid @Valid CustomFieldsDraft getCustom()

      Custom Fields for the DiscountCode.

      Specified by:
      getCustom in interface CustomizableDraft<DiscountCodeDraft>
      Returns:
      custom
    • getGroups

      List<String> getGroups()

      Groups to which the DiscountCode will belong to.

      Returns:
      groups
    • getValidFrom

      ZonedDateTime getValidFrom()

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

      Returns:
      validFrom
    • getValidUntil

      ZonedDateTime getValidUntil()

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

      Returns:
      validUntil
    • setKey

      void setKey(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
    • setName

      void setName(LocalizedString name)

      Name of the DiscountCode.

      Parameters:
      name - value to be set
    • setDescription

      void setDescription(LocalizedString description)

      Description of the DiscountCode.

      Parameters:
      description - value to be set
    • setCode

      void setCode(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
    • setCartDiscounts

      void setCartDiscounts(CartDiscountResourceIdentifier... cartDiscounts)

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

      Parameters:
      cartDiscounts - values to be set
    • setCartDiscounts

      void setCartDiscounts(List<CartDiscountResourceIdentifier> cartDiscounts)

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

      Parameters:
      cartDiscounts - values to be set
    • setCartPredicate

      void setCartPredicate(String cartPredicate)

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

      Parameters:
      cartPredicate - value to be set
    • setIsActive

      void setIsActive(Boolean isActive)

      Only active DiscountCodes can be applied to the Cart.

      Parameters:
      isActive - value to be set
    • setMaxApplications

      void setMaxApplications(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
    • setMaxApplicationsPerCustomer

      void setMaxApplicationsPerCustomer(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
    • setCustom

      void setCustom(CustomFieldsDraft custom)

      Custom Fields for the DiscountCode.

      Specified by:
      setCustom in interface CustomizableDraft<DiscountCodeDraft>
      Parameters:
      custom - value to be set
    • setGroups

      void setGroups(String... groups)

      Groups to which the DiscountCode will belong to.

      Parameters:
      groups - values to be set
    • setGroups

      void setGroups(List<String> groups)

      Groups to which the DiscountCode will belong to.

      Parameters:
      groups - values to be set
    • setValidFrom

      void setValidFrom(ZonedDateTime validFrom)

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

      Parameters:
      validFrom - value to be set
    • setValidUntil

      void setValidUntil(ZonedDateTime validUntil)

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

      Parameters:
      validUntil - value to be set
    • of

      static DiscountCodeDraft of()
      factory method
      Returns:
      instance of DiscountCodeDraft
    • of

      static DiscountCodeDraft of(DiscountCodeDraft template)
      factory method to create a shallow copy DiscountCodeDraft
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • deepCopy

      factory method to create a deep copy of DiscountCodeDraft
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • builder

      static DiscountCodeDraftBuilder builder()
      builder factory method for DiscountCodeDraft
      Returns:
      builder
    • builder

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

      default <T> T withDiscountCodeDraft(Function<DiscountCodeDraft,T> helper)
      accessor map function
      Type Parameters:
      T - mapped type
      Parameters:
      helper - function to map the object
      Returns:
      mapped value
    • typeReference

      static com.fasterxml.jackson.core.type.TypeReference<DiscountCodeDraft> typeReference()
      gives a TypeReference for usage with Jackson DataBind
      Returns:
      TypeReference