public interface CartDiscountCreateCommand extends DraftBasedCreateCommandDsl<CartDiscount,CartDiscountDraft,CartDiscountCreateCommand>, MetaModelReferenceExpansionDsl<CartDiscount,CartDiscountCreateCommand,CartDiscountExpansionModel<CartDiscount>>
CartDiscount
.
final ZonedDateTime validFrom = SphereTestUtils.now(); final ZonedDateTime validUntil = validFrom.plusSeconds(8000); final LocalizedString name = en("discount name"); final LocalizedString description = en("discount descriptions"); final String predicate = "totalPrice > \"800.00 EUR\""; final AbsoluteCartDiscountValue value = CartDiscountValue.ofAbsolute(MoneyImpl.of(10, EUR)); final LineItemsTarget target = LineItemsTarget.of("1 = 1"); final String sortOrder = "0.54"; final boolean requiresDiscountCode = false; final CartDiscountDraft discountDraft = CartDiscountDraftBuilder.of(name, CartPredicate.of(predicate), value, target, sortOrder, requiresDiscountCode) .validFrom(validFrom) .validUntil(validUntil) .description(description) .isActive(false) .stackingMode(StackingMode.STOP_AFTER_THIS_DISCOUNT) .build(); cartDiscount = client().executeBlocking(CartDiscountCreateCommand.of(discountDraft)); assertThat(cartDiscount.getName()).isEqualTo(name); assertThat(cartDiscount.getCartPredicate()).isEqualTo(predicate); assertThat(cartDiscount.getValue()).isEqualTo(value); assertThat(cartDiscount.getTarget()).isEqualTo(target); assertThat(cartDiscount.getSortOrder()).isEqualTo(sortOrder); assertThat(cartDiscount.isRequiringDiscountCode()).isEqualTo(requiresDiscountCode); assertThat(cartDiscount.getValidFrom()).isEqualTo(validFrom); assertThat(cartDiscount.getValidUntil()).isEqualTo(validUntil); assertThat(cartDiscount.getDescription()).isEqualTo(description); assertThat(cartDiscount.getReferences()).isEqualTo(Collections.emptyList()); assertThat(cartDiscount.getStackingMode()).isEqualTo(StackingMode.STOP_AFTER_THIS_DISCOUNT);
See the test code.
CartDiscountDraft
,
CartDiscount
Modifier and Type | Method and Description |
---|---|
static CartDiscountCreateCommand |
of(CartDiscountDraft draft)
Creates a command object to create a
CartDiscount . |
getDraft, withDraft
canDeserialize, deserialize, httpRequestIntent
plusExpansionPaths, withExpansionPaths
plusExpansionPaths, plusExpansionPaths, plusExpansionPaths, plusExpansionPaths, withExpansionPaths, withExpansionPaths, withExpansionPaths, withExpansionPaths
expansionPaths
static CartDiscountCreateCommand of(CartDiscountDraft draft)
CartDiscount
.draft
- template to create the new object