Class DiscountCodeDraftBuilder
- All Implemented Interfaces:
Builder<DiscountCodeDraft>
Example to create an instance using the builder pattern
DiscountCodeDraft discountCodeDraft = DiscountCodeDraft.builder()
.code("{code}")
.plusCartDiscounts(cartDiscountsBuilder -> cartDiscountsBuilder)
.build()
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddCartDiscounts
(Function<CartDiscountResourceIdentifierBuilder, CartDiscountResourceIdentifier> builder) Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.build()
builds DiscountCodeDraft with checking for non-null required valuesbuilds DiscountCodeDraft without checking for non-null required valuescartDiscounts
(CartDiscountResourceIdentifier... cartDiscounts) Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.cartDiscounts
(List<CartDiscountResourceIdentifier> cartDiscounts) Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.cartPredicate
(String cartPredicate) DiscountCode can only be applied to Carts that match this predicate.User-defined unique identifier for the DiscountCode that can be added to the Cart to apply the related CartDiscounts.custom
(CustomFieldsDraft custom) Custom Fields for the DiscountCode.Custom Fields for the DiscountCode.description
(LocalizedString description) Description of the DiscountCode.Description of the DiscountCode.Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.DiscountCode can only be applied to Carts that match this predicate.getCode()
User-defined unique identifier for the DiscountCode that can be added to the Cart to apply the related CartDiscounts.Custom Fields for the DiscountCode.Description of the DiscountCode.Groups to which the DiscountCode will belong to.Only active DiscountCodes can be applied to the Cart.getKey()
User-defined unique identifier for the DiscountCode.Number of times the DiscountCode can be applied.Number of times the DiscountCode can be applied per Customer.getName()
Name of the DiscountCode.Date and time (UTC) from which the DiscountCode is effective.Date and time (UTC) until which the DiscountCode is effective.Groups to which the DiscountCode will belong to.Groups to which the DiscountCode will belong to.Only active DiscountCodes can be applied to the Cart.User-defined unique identifier for the DiscountCode.maxApplications
(Long maxApplications) Number of times the DiscountCode can be applied.maxApplicationsPerCustomer
(Long maxApplicationsPerCustomer) Number of times the DiscountCode can be applied per Customer.name
(LocalizedString name) Name of the DiscountCode.Name of the DiscountCode.static DiscountCodeDraftBuilder
of()
factory method for an instance of DiscountCodeDraftBuilderstatic DiscountCodeDraftBuilder
of
(DiscountCodeDraft template) create builder for DiscountCodeDraft instanceplusCartDiscounts
(CartDiscountResourceIdentifier... cartDiscounts) Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.plusCartDiscounts
(Function<CartDiscountResourceIdentifierBuilder, CartDiscountResourceIdentifierBuilder> builder) Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.plusGroups
(String... groups) Groups to which the DiscountCode will belong to.setCartDiscounts
(Function<CartDiscountResourceIdentifierBuilder, CartDiscountResourceIdentifier> builder) Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.validFrom
(ZonedDateTime validFrom) Date and time (UTC) from which the DiscountCode is effective.validUntil
(ZonedDateTime validUntil) Date and time (UTC) until which the DiscountCode is effective.withCartDiscounts
(Function<CartDiscountResourceIdentifierBuilder, CartDiscountResourceIdentifierBuilder> builder) Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.Custom Fields for the DiscountCode.Description of the DiscountCode.Name of the DiscountCode.
-
Constructor Details
-
DiscountCodeDraftBuilder
public DiscountCodeDraftBuilder()
-
-
Method Details
-
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
public DiscountCodeDraftBuilder name(Function<LocalizedStringBuilder, LocalizedStringBuilder> builder) 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
Name of the DiscountCode.
- Parameters:
name
- value to be set- Returns:
- Builder
-
description
public DiscountCodeDraftBuilder description(Function<LocalizedStringBuilder, LocalizedStringBuilder> builder) Description of the DiscountCode.
- Parameters:
builder
- function to build the description value- Returns:
- Builder
-
withDescription
public DiscountCodeDraftBuilder withDescription(Function<LocalizedStringBuilder, LocalizedString> builder) Description of the DiscountCode.
- Parameters:
builder
- function to build the description value- Returns:
- Builder
-
description
Description of the DiscountCode.
- Parameters:
description
- value to be set- Returns:
- Builder
-
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
Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.
- Parameters:
cartDiscounts
- value to be set- Returns:
- Builder
-
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:
cartDiscounts
- value to be set- Returns:
- Builder
-
plusCartDiscounts
public DiscountCodeDraftBuilder plusCartDiscounts(Function<CartDiscountResourceIdentifierBuilder, CartDiscountResourceIdentifierBuilder> builder) 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
public DiscountCodeDraftBuilder withCartDiscounts(Function<CartDiscountResourceIdentifierBuilder, CartDiscountResourceIdentifierBuilder> builder) 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
public DiscountCodeDraftBuilder addCartDiscounts(Function<CartDiscountResourceIdentifierBuilder, CartDiscountResourceIdentifier> builder) 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
public DiscountCodeDraftBuilder setCartDiscounts(Function<CartDiscountResourceIdentifierBuilder, CartDiscountResourceIdentifier> builder) 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
DiscountCode can only be applied to Carts that match this predicate.
- Parameters:
cartPredicate
- value to be set- Returns:
- Builder
-
isActive
Only active DiscountCodes can be applied to the Cart.
- Parameters:
isActive
- value to be set- Returns:
- Builder
-
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
public DiscountCodeDraftBuilder custom(Function<CustomFieldsDraftBuilder, CustomFieldsDraftBuilder> builder) Custom Fields for the DiscountCode.
- Parameters:
builder
- function to build the custom value- Returns:
- Builder
-
withCustom
public DiscountCodeDraftBuilder withCustom(Function<CustomFieldsDraftBuilder, CustomFieldsDraft> builder) Custom Fields for the DiscountCode.
- Parameters:
builder
- function to build the custom value- Returns:
- Builder
-
custom
Custom Fields for the DiscountCode.
- Parameters:
custom
- value to be set- Returns:
- Builder
-
groups
Groups to which the DiscountCode will belong to.
- Parameters:
groups
- value to be set- Returns:
- Builder
-
groups
Groups to which the DiscountCode will belong to.
- Parameters:
groups
- value to be set- Returns:
- Builder
-
plusGroups
Groups to which the DiscountCode will belong to.
- Parameters:
groups
- value to be set- Returns:
- Builder
-
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
Date and time (UTC) until which the DiscountCode is effective. Must be later than
validFrom
.- Parameters:
validUntil
- value to be set- Returns:
- Builder
-
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
Name of the DiscountCode.
- Returns:
- name
-
getDescription
Description of the DiscountCode.
- Returns:
- description
-
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
Specify what CartDiscounts the API applies when you add the DiscountCode to the Cart.
- Returns:
- cartDiscounts
-
getCartPredicate
DiscountCode can only be applied to Carts that match this predicate.
- Returns:
- cartPredicate
-
getIsActive
Only active DiscountCodes can be applied to the Cart.
- Returns:
- isActive
-
getMaxApplications
Number of times the DiscountCode can be applied.
If not set, the DiscountCode can be applied any number of times.
- Returns:
- maxApplications
-
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
Custom Fields for the DiscountCode.
- Returns:
- custom
-
getGroups
Groups to which the DiscountCode will belong to.
- Returns:
- groups
-
getValidFrom
Date and time (UTC) from which the DiscountCode is effective. Must be earlier than
validUntil
.- Returns:
- validFrom
-
getValidUntil
Date and time (UTC) until which the DiscountCode is effective. Must be later than
validFrom
.- Returns:
- validUntil
-
build
builds DiscountCodeDraft with checking for non-null required values- Specified by:
build
in interfaceBuilder<DiscountCodeDraft>
- Returns:
- DiscountCodeDraft
-
buildUnchecked
builds DiscountCodeDraft without checking for non-null required values- Returns:
- DiscountCodeDraft
-
of
factory method for an instance of DiscountCodeDraftBuilder- Returns:
- builder
-
of
create builder for DiscountCodeDraft instance- Parameters:
template
- instance with prefilled values for the builder- Returns:
- builder
-