Class HelperMethods

java.lang.Object
com.commercetools.docs.meta.HelperMethods

public class HelperMethods extends Object

The helper methods simplify the use of our SDK.

The list below is sorted by endpoint.

Business Units

BusinessUnitSetCustomFieldAction.ofUnset(String)

final BusinessUnit updatedBusinessUnit = projectApiRoot.businessUnits()
        .withId(businessUnit.getId())
        .post(BusinessUnitUpdateBuilder.of()
                .version(businessUnit.getVersion())
                .actions(BusinessUnitSetCustomFieldAction.ofUnset("test-custom-field"))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

BusinessUnitSetAddressCustomFieldAction.ofUnset(String)

final BusinessUnit updatedBusinessUnit = projectApiRoot.businessUnits()
        .withId(businessUnit.getId())
        .post(BusinessUnitUpdateBuilder.of()
                .version(businessUnit.getVersion())
                .actions(BusinessUnitSetAddressCustomFieldAction.ofUnset("test-address-custom-field"))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Carts

To be added

{com.commercetools.api.models.cart.InventoryMode##defaultValue()}


See the test code.

CartMixin.toResourceIdentifier()

final CartResourceIdentifier cartResourceIdentifier = cart.toResourceIdentifier();

See the test code.

CartMixin.toReference()

final CartReference cartReference = cart.toReference();

See the test code.

CartSetLineItemCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String lineId = "test-lineId-" + UUID.randomUUID().toString();
final Cart updatedCart = projectApiRoot.carts()
        .withId(cart.getId())
        .post(CartUpdateBuilder.of()
                .version(cart.getVersion())
                .actions(CartSetLineItemCustomFieldAction.ofUnset(name, lineId))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

CartSetCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();
final Cart updatedCart = projectApiRoot.carts()
        .withId(cart.getId())
        .post(CartUpdateBuilder.of()
                .version(cart.getVersion())
                .actions(CartSetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

CartSetBillingAddressCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();
final Cart updatedCart = projectApiRoot.carts()
        .withId(cart.getId())
        .post(CartUpdateBuilder.of()
                .version(cart.getVersion())
                .actions(CartSetBillingAddressCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

CartSetCustomLineItemCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String customLineId = "test-customLineId-" + UUID.randomUUID().toString();
final Cart updatedCart = projectApiRoot.carts()
        .withId(cart.getId())
        .post(CartUpdateBuilder.of()
                .version(cart.getVersion())
                .actions(CartSetCustomLineItemCustomFieldAction.ofUnset(name, customLineId))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

CartSetDeleteDaysAfterLastModificationAction.ofUnset()

final Cart updatedCart = projectApiRoot.carts()
        .withId(cart.getId())
        .post(CartUpdateBuilder.of()
                .version(cart.getVersion())
                .actions(CartSetDeleteDaysAfterLastModificationAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

CartSetItemShippingAddressCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String addressKey = "test-addressKey-" + UUID.randomUUID().toString();
final Cart updatedCart = projectApiRoot.carts()
        .withId(cart.getId())
        .post(CartUpdateBuilder.of()
                .version(cart.getVersion())
                .actions(CartSetItemShippingAddressCustomFieldAction.ofUnset(name, addressKey))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

CartSetShippingAddressCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();
final Cart updatedCart = projectApiRoot.carts()
        .withId(cart.getId())
        .post(CartUpdateBuilder.of()
                .version(cart.getVersion())
                .actions(CartSetShippingAddressCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

CartSetShippingRateInputAction.ofUnset()

final Cart updatedCart = projectApiRoot.carts()
        .withId(cart.getId())
        .post(CartUpdateBuilder.of()
                .version(cart.getVersion())
                .actions(CartSetShippingRateInputAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

CartSetKeyAction.ofUnset()

final Cart updatedCart = projectApiRoot.carts()
        .withId(cart.getId())
        .post(CartUpdateBuilder.of().version(cart.getVersion()).actions(CartSetKeyAction.ofUnset()).build())
        .executeBlocking()
        .getBody();

See the test code.

Cart Discounts

CartDiscountMixin.toResourceIdentifier()

final CartDiscountResourceIdentifier cartDiscountResourceIdentifier = cartDiscount.toResourceIdentifier();

See the test code.

CartDiscountMixin.toReference()

final CartDiscountReference cartDiscountReference = cartDiscount.toReference();

See the test code.

CartDiscount.referenceTypeId()

ReferenceTypeId referenceTypeId = CartDiscount.referenceTypeId();

See the test code.

CartDiscountSetCustomFieldAction.ofUnset(String)

final CartDiscount updatedCartDiscount = projectApiRoot.cartDiscounts()
        .withId(cartDiscount.getId())
        .post(CartDiscountUpdateBuilder.of()
                .version(cartDiscount.getVersion())
                .actions(CartDiscountSetCustomFieldAction.ofUnset("test-custom-field"))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

CartDiscountSetKeyAction.ofUnset()

final CartDiscount updatedCartDiscount = projectApiRoot.cartDiscounts()
        .withId(cartDiscount.getId())
        .post(CartDiscountUpdateBuilder.of()
                .version(cartDiscount.getVersion())
                .actions(CartDiscountSetKeyAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Categories

CategoryMixin.toResourceIdentifier()

final CategoryResourceIdentifier categoryResourceIdentifier = category.toResourceIdentifier();

See the test code.

CategoryMixin.toReference()

final CategoryReference categoryReference = category.toReference();

See the test code.

Category.referenceTypeId()

ReferenceTypeId referenceTypeId = Category.referenceTypeId();

See the test code.

CategorySetKeyAction.ofUnset()

final Category updatedCategory = projectApiRoot.categories()
        .withId(category.getId())
        .post(CategoryUpdateBuilder.of()
                .version(category.getVersion())
                .actions(CategorySetKeyAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

CategorySetCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();
final Category updatedCategory = projectApiRoot.categories()
        .withId(category.getId())
        .post(CategoryUpdateBuilder.of()
                .version(category.getVersion())
                .actions(CategorySetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

CategoryTree.findById(String)

final String id = "test-id-" + UUID.randomUUID().toString();
final CategoryTree categoryTree = CategoryTree.of(createCategoryHierarchy());

final Category category = categoryTree.findById(id).get();

See the test code.

CategoryTree.findBySlug(Locale, String)

final CategoryTree categoryTree = CategoryTree.of(createCategoryHierarchy());

final Category category = categoryTree.findBySlug(Locale.ENGLISH, "category-slug").get();

See the test code.

CategoryTree.findByKey(String)

final String key = "test-key";
final CategoryTree categoryTree = CategoryTree.of(createCategoryHierarchy());

final Category category = categoryTree.findByKey(key).get();

See the test code.

CategoryTree.findByExternalId(String)

final String externalId = "test-external-id";
final CategoryTree categoryTree = CategoryTree.of(createCategoryHierarchy());

final Category category = categoryTree.findByExternalId(externalId).get();

See the test code.

CategoryTree.getRoots()

final CategoryTree categoryTree = CategoryTree.of(createCategoryHierarchy());

final List<Category> categories = categoryTree.getRoots();

See the test code.

CategoryTree.getAllAsFlatList()

final CategoryTree categoryTree = CategoryTree.of(createCategoryHierarchy());

final List<Category> categories = categoryTree.getAllAsFlatList();

See the test code.

CategoryTree.findChildren(Identifiable)

String id = "0";
final CategoryTree categoryTree = CategoryTree.of(createCategoryHierarchy());
final Category category = categoryTree.findById(id).get();

final List<Category> categories = categoryTree.findChildren(category);

See the test code.

CategoryTree.findSiblings(Collection)

String id = "0";
final CategoryTree categoryTree = CategoryTree.of(createCategoryHierarchy());
final Category category = categoryTree.findById(id).get();

final List<Category> categories = categoryTree.findSiblings(singletonList(category));

See the test code.

CategoryTree.getSubtreeRoots()

String id = "0";
final CategoryTree categoryTree = CategoryTree.of(createCategoryHierarchy());

final Category category = categoryTree.findById(id).get();
final CategoryTree subtree = categoryTree.getSubtree(singletonList(category));

final List<Category> subTreeRoots = subtree.getSubtreeRoots();

See the test code.

CategoryTree.getSubtree(Collection)

final CategoryTree categoryTree = CategoryTree.of(createCategoryHierarchy());

final Category category0 = categoryTree.findById("0").get();
final Category category1 = categoryTree.findById("1").get();

final CategoryTree subtree = categoryTree.getSubtree(asList(category0, category1));

See the test code.

CategoryTree.getRootAncestor(Identifiable)

final CategoryTree categoryTree = CategoryTree.of(createCategoryHierarchy());

final Category category = categoryTree.findById("0").get();

final Category rootAncestor = categoryTree.getRootAncestor(category);

See the test code.

Channels

ChannelMixin.toResourceIdentifier()

final ChannelResourceIdentifier channelResourceIdentifier = channel.toResourceIdentifier();

See the test code.

ChannelMixin.toReference()

final ChannelReference channelReference = channel.toReference();

See the test code.

Channel.referenceTypeId()

ReferenceTypeId referenceTypeId = Channel.referenceTypeId();

See the test code.

ChannelSetGeoLocationAction

final Channel updatedChannel = projectApiRoot.channels()
        .withId(channel.getId())
        .post(ChannelUpdateBuilder.of()
                .version(channel.getVersion())
                .actions(ChannelSetGeoLocationAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ChannelSetAddressCustomFieldAction

final String name = "test-name-" + UUID.randomUUID().toString();
final Channel updatedChannel = projectApiRoot.channels()
        .withId(channel.getId())
        .post(ChannelUpdateBuilder.of()
                .version(channel.getVersion())
                .actions(ChannelSetAddressCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ChannelSetCustomFieldAction

final String name = "test-name-" + UUID.randomUUID().toString();
final Channel updatedChannel = projectApiRoot.channels()
        .withId(channel.getId())
        .post(ChannelUpdateBuilder.of()
                .version(channel.getVersion())
                .actions(ChannelSetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Common

BaseAddress

{@link com.commercetools.api.models.common.BaseAddress#toDraft())}

final Address address = AddressBuilder.of()
        .key("address-key")
        .country("DE")
        .id("address-id")
        .email("test@example.com")
        .firstName("adddress-firstName")
        .build();

final AddressDraft addressDraft = address.toDraft();

See the test code.

BaseAddressMixin.toDraftBuilder()

final Address address = AddressBuilder.of()
        .key("address-key")
        .country("DE")
        .id("address-id")
        .email("test@example.com")
        .firstName("adddress-firstName")
        .build();

final AddressDraftBuilder addressDraftBuilder = address.toDraftBuilder();

See the test code.

BaseAddressMixin.equalsIgnoreId(BaseAddress) ())}

final Address address1 = Address.builder().id("123").country("DE").build();
final Address address2 = Address.builder().id("234").country("DE").build();

final boolean equalsAddressIgnoringId = address1.equalsIgnoreId(address2);

See the test code.

CentPrecisionMoney

{@link com.commercetools.api.models.common.CentPrecisionMoney#toDraft())}

final CentPrecisionMoney centPrecisionMoney = CentPrecisionMoneyBuilder.of()
        .fractionDigits(2)
        .centAmount(100L)
        .currencyCode("EUR")
        .build();

final CentPrecisionMoneyDraft centPrecisionMoneyDraft = centPrecisionMoney.toDraft();

See the test code.

HighPrecisionMoney

HighPrecisionMoney.toDraft()

final HighPrecisionMoney highPrecisionMoney = HighPrecisionMoneyBuilder.of()
        .fractionDigits(2)
        .centAmount(100L)
        .currencyCode("EUR")
        .build();

final HighPrecisionMoneyDraft highPrecisionMoneyDraft = highPrecisionMoney.toDraft();

See the test code.

HighPrecisionMoney.createMoneyOperator()

final HighPrecisionMoney highPrecisionMoney = HighPrecisionMoneyBuilder.of()
        .fractionDigits(2)
        .centAmount(100L)
        .currencyCode("EUR")
        .build();

final MonetaryOperator monetaryOperator = highPrecisionMoney.createMoneyOperator();

See the test code.

HighPrecisionMoneyDraft.createMoneyOperator()

final HighPrecisionMoneyDraft highPrecisionMoneyDraft = HighPrecisionMoneyDraftBuilder.of()
        .fractionDigits(2)
        .centAmount(100L)
        .currencyCode("EUR")
        .build();

final MonetaryOperator monetaryOperator = highPrecisionMoneyDraft.createMoneyOperator();

See the test code.

TypedMoney

TypedMoney.createMoneyOperator()

final TypedMoney typedMoney = TypedMoneyBuilder.of()
        .centPrecisionBuilder()
        .centAmount(100L)
        .currencyCode("EUR")
        .build();

final MonetaryOperator monetaryOperator = typedMoney.createMoneyOperator();

See the test code.

TypedMoneyDraft.createMoneyOperator()

final TypedMoneyDraft typedMoneyDraft = TypedMoneyDraftBuilder.of()
        .centPrecisionBuilder()
        .centAmount(100L)
        .currencyCode("EUR")
        .build();

final MonetaryOperator monetaryOperator = typedMoneyDraft.createMoneyOperator();

See the test code.

MoneyUtil

MoneyUtil.toMonetaryAmount(Money)

final Money money = MoneyBuilder.of().currencyCode("EUR").centAmount(100L).build();
final MonetaryAmount monetaryAmount = MoneyUtil.toMonetaryAmount(money);

See the test code.

MoneyUtil.toMonetaryAmount(TypedMoneyDraft)

final TypedMoneyDraft typedMoneyDraft = TypedMoneyDraftBuilder.of()
        .centPrecisionBuilder()
        .centAmount(100L)
        .currencyCode("EUR")
        .build();
final MonetaryAmount monetaryAmount = MoneyUtil.toMonetaryAmount(typedMoneyDraft);

See the test code.

MoneyUtil.toMonetaryAmount(CentPrecisionMoneyDraft)

final CentPrecisionMoneyDraft centPrecisionMoneyDraft = CentPrecisionMoneyDraftBuilder.of()
        .fractionDigits(2)
        .centAmount(100L)
        .currencyCode("EUR")
        .build();
final MonetaryAmount monetaryAmount = MoneyUtil.toMonetaryAmount(centPrecisionMoneyDraft);

See the test code.

MoneyUtil.toMonetaryAmount(HighPrecisionMoneyDraft)

final HighPrecisionMoneyDraft highPrecisionMoneyDraft = HighPrecisionMoneyDraftBuilder.of()
        .preciseAmount(100L)
        .fractionDigits(2)
        .currencyCode("EUR")
        .build();
final MonetaryAmount monetaryAmount = MoneyUtil.toMonetaryAmount(highPrecisionMoneyDraft);

See the test code.

MoneyUtil.toMonetaryAmount(TypedMoney)

final TypedMoney typedMoney = TypedMoneyBuilder.of()
        .highPrecisionBuilder()
        .fractionDigits(2)
        .preciseAmount(100L)
        .centAmount(100L)
        .currencyCode("EUR")
        .build();
final MonetaryAmount monetaryAmount = MoneyUtil.toMonetaryAmount(typedMoney);

See the test code.

MoneyUtil.toMonetaryAmount(CentPrecisionMoney)

final CentPrecisionMoney centPrecisionMoney = CentPrecisionMoneyBuilder.of()
        .fractionDigits(2)
        .centAmount(100L)
        .currencyCode("EUR")
        .build();
final MonetaryAmount monetaryAmount = MoneyUtil.toMonetaryAmount(centPrecisionMoney);

See the test code.

MoneyUtil.toMonetaryAmount(HighPrecisionMoney)

final HighPrecisionMoney highPrecisionMoney = HighPrecisionMoneyBuilder.of()
        .preciseAmount(100L)
        .fractionDigits(2)
        .centAmount(100L)
        .currencyCode("EUR")
        .build();
final MonetaryAmount monetaryAmount = MoneyUtil.toMonetaryAmount(highPrecisionMoney);

See the test code.

MoneyUtil.zeroAmount(String)

final MonetaryAmount zeroAmount = MoneyUtil.zeroAmount("EUR");

See the test code.

MoneyUtil.of(MonetaryAmount)

CentPrecisionMoney centMoney = MoneyUtil.of(FastMoney.of(1.000, "EUR"));

See the test code.

MoneyUtil.of(MonetaryAmount, int)

HighPrecisionMoney highMoney = MoneyUtil.of(FastMoney.of(1.0010, "EUR"), 3);

See the test code.

MoneyUtil.draftOf(MonetaryAmount)

CentPrecisionMoneyDraft centMoneyDraft = MoneyUtil.draftOf(FastMoney.of(1.000, "EUR"));

See the test code.

MoneyUtil.draftOf(MonetaryAmount, int)

HighPrecisionMoneyDraft highMoneyDraft = MoneyUtil.draftOf(FastMoney.of(1.0010, "EUR"), 3);

See the test code.

MoneyUtil.amountToCents(MonetaryAmount)

final MonetaryAmount monetaryAmount = org.javamoney.moneta.Money.of(10.00501, "EUR");
final Long cents = MoneyUtil.amountToCents(monetaryAmount);

See the test code.

MoneyUtil.amountToPreciseAmount(MonetaryAmount, int)

final MonetaryAmount highEur = org.javamoney.moneta.Money.of(10.00501, "EUR");
final Long preciseAmount = MoneyUtil.amountToPreciseAmount(highEur, 3);

See the test code.

MoneyUtil.calculateAppliedTaxes(TaxedItemPrice)

final CentPrecisionMoney totalNet = CentPrecisionMoneyBuilder.of()
        .centAmount(100L)
        .currencyCode("EUR")
        .fractionDigits(2)
        .build();
final CentPrecisionMoney totalGross = CentPrecisionMoneyBuilder.of()
        .centAmount(119L)
        .currencyCode("EUR")
        .fractionDigits(2)
        .build();
final TaxedItemPrice taxedItemPrice = TaxedItemPriceBuilder.of()
        .totalNet(totalNet)
        .totalGross(totalGross)
        .build();
final MonetaryAmount appliedTaxes = MoneyUtil.calculateAppliedTaxes(taxedItemPrice);

See the test code.

MoneyUtil.calculateGrossPrice(MonetaryAmount, TaxRate)

final TaxRate taxRate = TaxRateBuilder.of()
        .amount(0.19)
        .country("DE")
        .name("test-foo")
        .includedInPrice(true)
        .build();
final CentPrecisionMoney centPrecisionMoney = CentPrecisionMoneyBuilder.of()
        .centAmount(100L)
        .fractionDigits(2)
        .currencyCode("EUR")
        .build();
final MonetaryAmount amount = centPrecisionMoney.toMonetaryAmount();
final MonetaryAmount grossPrice = MoneyUtil.calculateGrossPrice(amount, taxRate);

See the test code.

MoneyUtil.calculateNetPrice(MonetaryAmount, TaxRate)

final TaxRate taxRate = TaxRateBuilder.of()
        .amount(0.19)
        .country("DE")
        .name("test-foo")
        .includedInPrice(true)
        .build();
final CentPrecisionMoney centPrecisionMoney = CentPrecisionMoneyBuilder.of()
        .centAmount(119L)
        .fractionDigits(2)
        .currencyCode("EUR")
        .build();
final MonetaryAmount amount = centPrecisionMoney.toMonetaryAmount();
final MonetaryAmount netPrice = MoneyUtil.calculateNetPrice(amount, taxRate);

See the test code.

MoneyUtil.convertNetToGrossPrice(MonetaryAmount, double)

final MonetaryAmount netAmount = CentPrecisionMoneyBuilder.of()
        .centAmount(100L)
        .fractionDigits(2)
        .currencyCode("EUR")
        .build();
final double taxRate = 0.19;
final MonetaryAmount grossPrice = MoneyUtil.convertNetToGrossPrice(netAmount, taxRate);

See the test code.

MoneyUtil.convertGrossToNetPrice(MonetaryAmount, double)

final MonetaryAmount grossAmount = CentPrecisionMoneyBuilder.of()
        .centAmount(119L)
        .fractionDigits(2)
        .currencyCode("EUR")
        .build();
final double taxRate = 0.19;
final MonetaryAmount netPrice = MoneyUtil.convertNetToGrossPrice(grossAmount, taxRate);

See the test code.

Custom Objects

CustomObjectMixin.toReference()

final CustomObjectReference customObjectReference = customObject.toReference();

See the test code.

CustomObject.referenceTypeId()

ReferenceTypeId referenceTypeId = CustomObject.referenceTypeId();

See the test code.

Customers

CustomerMixin.toResourceIdentifier()

final CustomerResourceIdentifier customerResourceIdentifier = customer.toResourceIdentifier();

See the test code.

CustomerMixin.toReference()

final CustomerReference customerReference = customer.toReference();

See the test code.

Customer.referenceTypeId()

ReferenceTypeId referenceTypeId = Customer.referenceTypeId();

See the test code.

CustomerDraft.builder()

final CustomerDraftBuilder customerDraftBuilder = CustomerDraft.builder(customer);

See the test code.

CustomerSetAddressCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();
final Customer updatedCustomer = projectApiRoot.customers()
        .withId(customer.getId())
        .post(CustomerUpdateBuilder.of()
                .version(customer.getVersion())
                .actions(CustomerSetAddressCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

CustomerSetCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();
final Customer updatedCustomer = projectApiRoot.customers()
        .withId(customer.getId())
        .post(CustomerUpdateBuilder.of()
                .version(customer.getVersion())
                .actions(CustomerSetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

CustomerSetKeyAction.ofUnset()

final Customer updatedCustomer = projectApiRoot.customers()
        .withId(customer.getId())
        .post(CustomerUpdateBuilder.of()
                .version(customer.getVersion())
                .actions(CustomerSetKeyAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Customer Groups

CustomerGroupMixin.toResourceIdentifier()

final CustomerGroupResourceIdentifier customerGroupResourceIdentifier = customerGroup.toResourceIdentifier();

See the test code.

CustomerGroupMixin.toReference()

final CustomerGroupReference customerGroupReference = customerGroup.toReference();

See the test code.

CustomerGroup.referenceTypeId()

ReferenceTypeId referenceTypeId = CustomerGroup.referenceTypeId();

See the test code.

CustomerGroupSetCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();
final CustomerGroup updatedCustomerGroup = projectApiRoot.customerGroups()
        .withId(customerGroup.getId())
        .post(CustomerGroupUpdateBuilder.of()
                .version(customerGroup.getVersion())
                .actions(CustomerGroupSetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

CustomerGroupSetKeyAction.ofUnset()

final CustomerGroup updatedCustomerGroup = projectApiRoot.customerGroups()
        .withId(customerGroup.getId())
        .post(CustomerGroupUpdateBuilder.of()
                .version(customerGroup.getVersion())
                .actions(CustomerGroupSetKeyAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Discount Codes

DiscountCodeMixin.toResourceIdentifier()

final DiscountCodeResourceIdentifier cdiscountCodeResourceIdentifier = discountCode.toResourceIdentifier();

See the test code.

DiscountCodeMixin.toReference()

final DiscountCodeReference discountCodeReference = discountCode.toReference();

See the test code.

DiscountCode.referenceTypeId()

ReferenceTypeId referenceTypeId = DiscountCode.referenceTypeId();

See the test code.

DiscountCodeSetCustomFieldAction

final String name = "test-name-" + UUID.randomUUID().toString();
final DiscountCode updatedDiscountCode = projectApiRoot.discountCodes()
        .withId(discountCode.getId())
        .post(DiscountCodeUpdateBuilder.of()
                .version(discountCode.getVersion())
                .actions(DiscountCodeSetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Extension

ExtensionSetKeyAction.ofUnset()

final Extension updatedExtension = projectApiRoot.extensions()
        .withId(extension.getId())
        .post(ExtensionUpdateBuilder.of()
                .version(extension.getVersion())
                .actions(ExtensionSetKeyAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Inventory

InventoryEntryMixin.toResourceIdentifier()

final InventoryEntryResourceIdentifier inventoryEntryResourceIdentifier = inventoryEntry.toResourceIdentifier();

See the test code.

InventoryEntryMixin.toReference()

final InventoryEntryReference inventoryEntryReference = inventoryEntry.toReference();

See the test code.

InventoryEntry.referenceTypeId()

ReferenceTypeId referenceTypeId = InventoryEntry.referenceTypeId();

See the test code.

InventoryEntrySetCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();
final InventoryEntry updatedInventoryEntry = projectApiRoot.inventory()
        .withId(inventoryEntry.getId())
        .post(InventoryEntryUpdateBuilder.of()
                .version(inventoryEntry.getVersion())
                .actions(InventoryEntrySetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

InventoryEntrySetKeyAction.ofUnset()

final InventoryEntry updatedInventoryEntry = projectApiRoot.inventory()
        .withId(inventoryEntry.getId())
        .post(InventoryEntryUpdateBuilder.of()
                .version(inventoryEntry.getVersion())
                .actions(InventoryEntrySetKeyAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Order Edits

OrderEditMixin.toResourceIdentifier()

final OrderEditResourceIdentifier orderEditResourceIdentifier = orderEdit.toResourceIdentifier();

See the test code.

OrderEditMixin.toReference()

final OrderEditReference orderEditReference = orderEdit.toReference();

See the test code.

OrderEdit.referenceTypeId()

ReferenceTypeId referenceTypeId = OrderEdit.referenceTypeId();

See the test code.

OrderEditSetKeyAction.ofUnset()

final OrderEdit updatedOrderEdit = projectApiRoot.orders()
        .edits()
        .withId(orderEdit.getId())
        .post(OrderEditUpdateBuilder.of()
                .version(orderEdit.getVersion())
                .actions(OrderEditSetKeyAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

OrderEditSetCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();
final OrderEdit updatedOrderEdit = projectApiRoot.orders()
        .edits()
        .withId(orderEdit.getId())
        .post(OrderEditUpdateBuilder.of()
                .version(orderEdit.getVersion())
                .actions(OrderEditSetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

StagedOrderSetShippingRateInputAction.ofUnset()

final OrderEdit updatedOrderEdit = projectApiRoot.orders()
        .edits()
        .withId(orderEdit.getId())
        .post(OrderEditUpdateBuilder.of()
                .version(orderEdit.getVersion())
                .actions(OrderEditUpdateAction.addStagedActionBuilder()
                        .stagedAction(StagedOrderSetShippingRateInputAction.ofUnset())
                        .build())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

StagedOrderSetDeliveryAddressAction.ofUnset()

final OrderEdit updatedOrderEdit = projectApiRoot.orders()
        .edits()
        .withId(orderEdit.getId())
        .post(OrderEditUpdateBuilder.of()
                .version(orderEdit.getVersion())
                .actions(OrderEditUpdateAction.addStagedActionBuilder()
                        .stagedAction(StagedOrderSetDeliveryAddressAction.ofUnset())
                        .build())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

StagedOrderSetLineItemCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String lineItemId = "test-lineItemId-" + UUID.randomUUID().toString();
final OrderEdit updatedOrderEdit = projectApiRoot.orders()
        .edits()
        .withId(orderEdit.getId())
        .post(OrderEditUpdateBuilder.of()
                .version(orderEdit.getVersion())
                .actions(OrderEditUpdateAction.addStagedActionBuilder()
                        .stagedAction(StagedOrderSetLineItemCustomFieldAction.ofUnset(name, lineItemId))
                        .build())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

StagedOrderSetCustomLineItemCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String customLineItemId = "test-customLineItemId-" + UUID.randomUUID().toString();
final OrderEdit updatedOrderEdit = projectApiRoot.orders()
        .edits()
        .withId(orderEdit.getId())
        .post(OrderEditUpdateBuilder.of()
                .version(orderEdit.getVersion())
                .actions(OrderEditUpdateAction.addStagedActionBuilder()
                        .stagedAction(
                            StagedOrderSetCustomLineItemCustomFieldAction.ofUnset(name, customLineItemId))
                        .build())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

StagedOrderSetDeliveryAddressCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String deliveryId = "test-deliveryId-" + UUID.randomUUID().toString();
final OrderEdit updatedOrderEdit = projectApiRoot.orders()
        .edits()
        .withId(orderEdit.getId())
        .post(OrderEditUpdateBuilder.of()
                .version(orderEdit.getVersion())
                .actions(OrderEditUpdateAction.addStagedActionBuilder()
                        .stagedAction(StagedOrderSetDeliveryAddressCustomFieldAction.ofUnset(name, deliveryId))
                        .build())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

StagedOrderSetItemShippingAddressCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String addressKey = "test-addressKey-" + UUID.randomUUID().toString();
final OrderEdit updatedOrderEdit = projectApiRoot.orders()
        .edits()
        .withId(orderEdit.getId())
        .post(OrderEditUpdateBuilder.of()
                .version(orderEdit.getVersion())
                .actions(OrderEditUpdateAction.addStagedActionBuilder()
                        .stagedAction(
                            StagedOrderSetItemShippingAddressCustomFieldAction.ofUnset(name, addressKey))
                        .build())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

StagedOrderSetShippingAddressCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();
final OrderEdit updatedOrderEdit = projectApiRoot.orders()
        .edits()
        .withId(orderEdit.getId())
        .post(OrderEditUpdateBuilder.of()
                .version(orderEdit.getVersion())
                .actions(OrderEditUpdateAction.addStagedActionBuilder()
                        .stagedAction(StagedOrderSetShippingAddressCustomFieldAction.ofUnset(name))
                        .build())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

StagedOrderSetDeliveryCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String deliveryId = "test-deliveryId-" + UUID.randomUUID().toString();
final OrderEdit updatedOrderEdit = projectApiRoot.orders()
        .edits()
        .withId(orderEdit.getId())
        .post(OrderEditUpdateBuilder.of()
                .version(orderEdit.getVersion())
                .actions(OrderEditUpdateAction.addStagedActionBuilder()
                        .stagedAction(StagedOrderSetDeliveryCustomFieldAction.ofUnset(name, deliveryId))
                        .build())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

StagedOrderSetParcelCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String parcelId = "test-parcelId-" + UUID.randomUUID().toString();
final OrderEdit updatedOrderEdit = projectApiRoot.orders()
        .edits()
        .withId(orderEdit.getId())
        .post(OrderEditUpdateBuilder.of()
                .version(orderEdit.getVersion())
                .actions(OrderEditUpdateAction.addStagedActionBuilder()
                        .stagedAction(StagedOrderSetParcelCustomFieldAction.ofUnset(name, parcelId))
                        .build())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

StagedOrderSetReturnItemCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String returnItemId = "test-returnItemId-" + UUID.randomUUID().toString();
final OrderEdit updatedOrderEdit = projectApiRoot.orders()
        .edits()
        .withId(orderEdit.getId())
        .post(OrderEditUpdateBuilder.of()
                .version(orderEdit.getVersion())
                .actions(OrderEditUpdateAction.addStagedActionBuilder()
                        .stagedAction(StagedOrderSetReturnItemCustomFieldAction.ofUnset(name, returnItemId))
                        .build())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

StagedOrderSetCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();
final OrderEdit updatedOrderEdit = projectApiRoot.orders()
        .edits()
        .withId(orderEdit.getId())
        .post(OrderEditUpdateBuilder.of()
                .version(orderEdit.getVersion())
                .actions(OrderEditUpdateAction.addStagedActionBuilder()
                        .stagedAction(StagedOrderSetCustomFieldAction.ofUnset(name))
                        .build())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Orders

OrderMixin.toReference()

final OrderReference orderReference = order.toReference();

See the test code.

Order.referenceTypeId()

ReferenceTypeId referenceTypeId = Order.referenceTypeId();

See the test code.

OrderLike.calculateSubTotalPrice()

Cart cart = CartBuilder.of()
        .totalPrice(CentPrecisionMoneyBuilder.of().centAmount(0L).fractionDigits(2).currencyCode("EUR").build())
        .lineItems(Collections.emptyList())
        .customLineItems(Collections.emptyList())
        .buildUnchecked();

final MonetaryAmount subTotal = cart.calculateSubTotalPrice();

See the test code.

ParcelMixin.toDraft()

final Parcel parcel = ParcelBuilder.of().id("parcel-id").build();

final ParcelDraft parcelDraft = parcel.toDraft();

See the test code.

ParcelMixin.toDraftBuilder()

final Parcel parcel = ParcelBuilder.of().id("parcel-id").build();

final ParcelDraftBuilder parcelDraftBuilder = parcel.toDraftBuilder();

See the test code.

DeliveryMixin.toDraft()

final Delivery delivery = DeliveryBuilder.of().id("delivery-id").build();

final DeliveryDraft deliveryDraft = delivery.toDraft();

See the test code.

DeliveryMixin.toDraftBuilder()

final Delivery delivery = DeliveryBuilder.of().id("delivery-id").build();

final DeliveryDraftBuilder deliveryDraftBuilder = delivery.toDraftBuilder();

See the test code.

OrderSetDeliveryAddressAction.ofUnset(String)

final String deliveryId = "test-deliveryId-" + UUID.randomUUID().toString();
final Order updatedOrder = projectApiRoot.orders()
        .withId(order.getId())
        .post(OrderUpdateBuilder.of()
                .version(order.getVersion())
                .actions(OrderSetDeliveryAddressAction.ofUnset(deliveryId))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

OrderSetLineItemCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String lineItemId = "test-lineItemId-" + UUID.randomUUID().toString();
final Order updatedOrder = projectApiRoot.orders()
        .withId(order.getId())
        .post(OrderUpdateBuilder.of()
                .version(order.getVersion())
                .actions(OrderSetLineItemCustomFieldAction.ofUnset(name, lineItemId))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

OrderSetCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();
final Order updatedOrder = projectApiRoot.orders()
        .withId(order.getId())
        .post(OrderUpdateBuilder.of()
                .version(order.getVersion())
                .actions(OrderSetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

OrderSetBillingAddressCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();
final Order updatedOrder = projectApiRoot.orders()
        .withId(order.getId())
        .post(OrderUpdateBuilder.of()
                .version(order.getVersion())
                .actions(OrderSetBillingAddressCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

OrderSetCustomLineItemCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String customLineItemId = "test-customLineItemId-" + UUID.randomUUID().toString();
final Order updatedOrder = projectApiRoot.orders()
        .withId(order.getId())
        .post(OrderUpdateBuilder.of()
                .version(order.getVersion())
                .actions(OrderSetCustomLineItemCustomFieldAction.ofUnset(name, customLineItemId))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

OrderSetDeliveryAddressCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String deliveryId = "test-deliveryId-" + UUID.randomUUID().toString();
final Order updatedOrder = projectApiRoot.orders()
        .withId(order.getId())
        .post(OrderUpdateBuilder.of()
                .version(order.getVersion())
                .actions(OrderSetDeliveryAddressCustomFieldAction.ofUnset(name, deliveryId))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

OrderSetItemShippingAddressCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String addressKey = "test-addressKey-" + UUID.randomUUID().toString();
final Order updatedOrder = projectApiRoot.orders()
        .withId(order.getId())
        .post(OrderUpdateBuilder.of()
                .version(order.getVersion())
                .actions(OrderSetItemShippingAddressCustomFieldAction.ofUnset(name, addressKey))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

OrderSetShippingAddressCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();
final Order updatedOrder = projectApiRoot.orders()
        .withId(order.getId())
        .post(OrderUpdateBuilder.of()
                .version(order.getVersion())
                .actions(OrderSetShippingAddressCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

OrderSetParcelCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String parcelId = "test-parcelId-" + UUID.randomUUID().toString();
final Order updatedOrder = projectApiRoot.orders()
        .withId(order.getId())
        .post(OrderUpdateBuilder.of()
                .version(order.getVersion())
                .actions(OrderSetParcelCustomFieldAction.ofUnset(name, parcelId))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

OrderSetReturnItemCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String returnItemId = "test-returnItemId-" + UUID.randomUUID().toString();
final Order updatedOrder = projectApiRoot.orders()
        .withId(order.getId())
        .post(OrderUpdateBuilder.of()
                .version(order.getVersion())
                .actions(OrderSetReturnItemCustomFieldAction.ofUnset(name, returnItemId))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ByProjectKeyOrdersGetMixin.byCustomerId(String)

final OrderPagedQueryResponse orderPagedQueryResponse = projectApiRoot.orders()
        .get()
        .byCustomerId(order.getCustomerId())
        .executeBlocking()
        .getBody();

See the test code.

ByProjectKeyOrdersGetMixin.byCustomerEmail(String)

final OrderPagedQueryResponse orderPagedQueryResponse = projectApiRoot.orders()
        .get()
        .byCustomerEmail(order.getCustomerEmail())
        .executeBlocking()
        .getBody();

See the test code.

Payments

PaymentMixin.toResourceIdentifier()

final PaymentResourceIdentifier paymentResourceIdentifier = payment.toResourceIdentifier();

See the test code.

PaymentMixin.toReference()

final PaymentReference paymentReference = payment.toReference();

See the test code.

Payment.referenceTypeId()

ReferenceTypeId referenceTypeId = Payment.referenceTypeId();

See the test code.

PaymentSetTransactionCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String transactionId = "test-transactionId-" + UUID.randomUUID().toString();
final Payment updatedPayment = projectApiRoot.payments()
        .withId(payment.getId())
        .post(PaymentUpdateBuilder.of()
                .version(payment.getVersion())
                .actions(PaymentSetTransactionCustomFieldAction.ofUnset(name, transactionId))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

PaymentSetCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();
final Payment updatedPayment = projectApiRoot.payments()
        .withId(payment.getId())
        .post(PaymentUpdateBuilder.of()
                .version(payment.getVersion())
                .actions(PaymentSetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Products

ProductMixin.toResourceIdentifier()

final ProductResourceIdentifier productResourceIdentifier = product.toResourceIdentifier();

See the test code.

ProductMixin.toReference()

final ProductReference productReference = product.toReference();

See the test code.

Product.referenceTypeId()

ReferenceTypeId referenceTypeId = Product.referenceTypeId();

See the test code.

ProductDataLike.findVariantBySku(String)

ProductProjection productProjection = ProductProjectionBuilder.of()
        .masterVariant(product.getMasterData().getStaged().getMasterVariant())
        .build();

Optional<ProductVariant> productVariant = productProjection.findVariantBySku("sku-test");

See the test code.

ProductDataLike.getVariantOrMaster(long)

ProductVariant productVariant = product.getMasterData().getCurrent().getVariantOrMaster(111111L);

See the test code.

ProductDataLike.getVariant(long)

ProductProjection productProjection = ProductProjectionBuilder.of()
        .masterVariant(product.getMasterData().getStaged().getMasterVariant())
        .build();

Optional<ProductVariant> productVariant = Optional.ofNullable(
    productProjection.getVariant(product.getMasterData().getCurrent().getVariants().get(0).getId()));

See the test code.

ByIdVariantIdentifier.of(Referencable, Long)

final LineItem lineItem = LineItemBuilder.of()
        .productId(product.getId())
        .name(LocalizedStringBuilder.of().build())
        .build();

final ByIdVariantIdentifier byIdVariantIdentifier = ByIdVariantIdentifier.of(product,
    lineItem.getVariant().getId());

See the test code.

ByIdVariantIdentifier.of(String, Long)

final LineItem lineItem = LineItemBuilder.of()
        .productId(product.getId())
        .name(LocalizedStringBuilder.of().build())
        .build();

final ByIdVariantIdentifier byIdVariantIdentifier = ByIdVariantIdentifier.of(lineItem.getProductId(),
    lineItem.getVariant().getId());

See the test code.

BySkuVariantIdentifier.of(String)

final LineItem lineItem = LineItemBuilder.of()
        .productId(product.getId())
        .variant(ProductVariantBuilder.of().sku("test-sku").build())
        .name(LocalizedStringBuilder.of().build())
        .build();

final BySkuVariantIdentifier bySkuVariantIdentifier = BySkuVariantIdentifier.of(lineItem.getVariant().getSku());

See the test code.

ProductProjectionMixin.findVariant(ByIdVariantIdentifier)

ProductProjectionPagedSearchResponse response = null;

ProductVariant productVariant = response.getResults()
        .stream()
        .map(productProjection -> productProjection.findVariant(ByIdVariantIdentifier.of("abc", 3L)))
        .filter(Optional::isPresent)
        .map(Optional::get)
        .findFirst()
        .get();

See the test code.

ProductProjectionMixin.findMatchingVariants()

Attribute attribute = AttributeBuilder.of().name("string").value("color").build();
Optional<ProductVariant> productVariant = productProjectionStaged.findMatchingVariants()
        .stream()
        .filter(variant -> variant.getAttributes().contains(attribute))
        .findAny();

See the test code.

ProductProjectionMixin.findFirstMatchingVariant()

To be added
Attribute attribute = AttributeBuilder.of().name("string").value("size").build();
Optional<ProductVariant> productVariant = productProjectionStaged.findFirstMatchingVariant()
        .filter(variant -> variant.getAttributes().contains(attribute));

See the test code.

ProductSetKeyAction.ofUnset()

final Product updatedProduct = projectApiRoot.products()
        .withId(product.getId())
        .post(ProductUpdateBuilder.of()
                .version(product.getVersion())
                .actions(ProductSetKeyAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ProductSetImageLabelAction.ofUnset(Long, String, Boolean)

long variantId = 12345L;
String imageUrl = "/url/myimage.png";
final Product updatedProduct = projectApiRoot.products()
        .withId(product.getId())
        .post(ProductUpdateBuilder.of()
                .version(product.getVersion())
                .actions(ProductSetImageLabelAction.ofUnset(variantId, imageUrl, true))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ProductSetImageLabelAction.ofUnsetStaged(Long, String)

long variantId = 12345L;
String imageUrl = "/url/myimage.png";
final Product updatedProduct = projectApiRoot.products()
        .withId(product.getId())
        .post(ProductUpdateBuilder.of()
                .version(product.getVersion())
                .actions(ProductSetImageLabelAction.ofUnsetStaged(variantId, imageUrl))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ProductSetProductPriceCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String priceId = "test-priceId-" + UUID.randomUUID().toString();
final Product updatedProduct = projectApiRoot.products()
        .withId(product.getId())
        .post(ProductUpdateBuilder.of()
                .version(product.getVersion())
                .actions(ProductSetProductPriceCustomFieldAction.ofUnset(name, priceId))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ProductSetProductPriceCustomFieldAction.ofUnsetStaged(String, String, Boolean)

final String name = "test-name-" + UUID.randomUUID().toString();
final String priceId = "test-priceId-" + UUID.randomUUID().toString();
final Product updatedProduct = projectApiRoot.products()
        .withId(product.getId())
        .post(ProductUpdateBuilder.of()
                .version(product.getVersion())
                .actions(ProductSetProductPriceCustomFieldAction.ofUnsetStaged(name, priceId, true))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ProductSetTaxCategoryAction.ofUnset()

final Product updatedProduct = projectApiRoot.products()
        .withId(product.getId())
        .post(ProductUpdateBuilder.of()
                .version(product.getVersion())
                .actions(ProductSetTaxCategoryAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ProductSetAttributeAction.ofVariantId(Long, String, JsonNode, Boolean)

final String name = "test-name-" + UUID.randomUUID().toString();
long variantId = 12345L;
final Attribute attribute = AttributeBuilder.of().name("attribute-name").build();

final Product updatedProduct = projectApiRoot.products()
        .withId(product.getId())
        .post(ProductUpdateBuilder.of()
                .version(product.getVersion())
                .actions(ProductSetAttributeAction.ofVariantId(variantId, name, JsonUtils.toJsonNode(attribute),
                    true))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ProductSetAttributeAction.ofSku(String, String, JsonNode, Boolean)

final String name = "test-name-" + UUID.randomUUID().toString();
final String sku = "test-sku-" + UUID.randomUUID().toString();

final Attribute attribute = AttributeBuilder.of().name("attribute-name").build();

final Product updatedProduct = projectApiRoot.products()
        .withId(product.getId())
        .post(ProductUpdateBuilder.of()
                .version(product.getVersion())
                .actions(ProductSetAttributeAction.ofSku(sku, name, JsonUtils.toJsonNode(attribute), true))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ProductSetAttributeAction.ofUnsetAttribute(Long, String)/p>

final String name = "test-name-" + UUID.randomUUID().toString();
long variantId = 12345L;
final Product updatedProduct = projectApiRoot.products()
        .withId(product.getId())
        .post(ProductUpdateBuilder.of()
                .version(product.getVersion())
                .actions(ProductSetAttributeAction.ofUnsetAttribute(variantId, name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ProductSetAttributeAction.ofUnsetAttribute(Long, String, Boolean)

final String name = "test-name-" + UUID.randomUUID().toString();
long variantId = 12345L;
final Product updatedProduct = projectApiRoot.products()
        .withId(product.getId())
        .post(ProductUpdateBuilder.of()
                .version(product.getVersion())
                .actions(ProductSetAttributeAction.ofUnsetAttribute(variantId, name, true))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ProductSetAttributeAction.ofUnsetAttributeForVariantId(Long, String)

final String name = "test-name-" + UUID.randomUUID().toString();
long variantId = 12345L;
final Product updatedProduct = projectApiRoot.products()
        .withId(product.getId())
        .post(ProductUpdateBuilder.of()
                .version(product.getVersion())
                .actions(ProductSetAttributeAction.ofUnsetAttributeForVariantId(variantId, name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ProductSetAttributeAction.ofUnsetAttributeForSku(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String sku = "test-sku-" + UUID.randomUUID().toString();
final Product updatedProduct = projectApiRoot.products()
        .withId(product.getId())
        .post(ProductUpdateBuilder.of()
                .version(product.getVersion())
                .actions(ProductSetAttributeAction.ofUnsetAttributeForSku(sku, name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ProductSetAttributeAction.ofUnsetAttributeForSku(String, String, Boolean)

final String name = "test-name-" + UUID.randomUUID().toString();
final String sku = "test-sku-" + UUID.randomUUID().toString();
final Product updatedProduct = projectApiRoot.products()
        .withId(product.getId())
        .post(ProductUpdateBuilder.of()
                .version(product.getVersion())
                .actions(ProductSetAttributeAction.ofUnsetAttributeForSku(sku, name, true))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ProductSetAttributeInAllVariantsAction.ofUnsetAttribute(String)

final String name = "test-name-" + UUID.randomUUID().toString();

final Product updatedProduct = projectApiRoot.products()
        .withId(product.getId())
        .post(ProductUpdateBuilder.of()
                .version(product.getVersion())
                .actions(ProductSetAttributeInAllVariantsAction.ofUnsetAttribute(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ProductSetAttributeInAllVariantsAction.ofUnsetAttribute(String, Boolean)

final String name = "test-name-" + UUID.randomUUID().toString();

final Product updatedProduct = projectApiRoot.products()
        .withId(product.getId())
        .post(ProductUpdateBuilder.of()
                .version(product.getVersion())
                .actions(ProductSetAttributeInAllVariantsAction.ofUnsetAttribute(name, true))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Product Discounts

ProductDiscountMixin.toResourceIdentifier()

final ProductDiscountResourceIdentifier productDiscountResourceIdentifier = productDiscount
        .toResourceIdentifier();

See the test code.

ProductDiscountMixin.toReference()

final ProductDiscountReference productDiscountReference = productDiscount.toReference();

See the test code.

ProductDiscount.referenceTypeId()

ReferenceTypeId referenceTypeId = ProductDiscount.referenceTypeId();

See the test code.

ProductDiscountSetKeyAction.ofUnset()

final ProductDiscount updatedProductDiscount = projectApiRoot.productDiscounts()
        .withId(productDiscount.getId())
        .post(ProductDiscountUpdateBuilder.of()
                .version(productDiscount.getVersion())
                .actions(ProductDiscountSetKeyAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Product Types

ProductTypeMixin.toResourceIdentifier()

final ProductTypeResourceIdentifier productTypeResourceIdentifier = productType.toResourceIdentifier();

See the test code.

ProductTypeMixin.toReference()

final ProductTypeReference productTypeReference = productType.toReference();

See the test code.

ProductType.referenceTypeId()

ReferenceTypeId referenceTypeId = ProductType.referenceTypeId();

See the test code.

AttributeDefinitionContainer.getAttribute(String)

final Attribute attribute = (Attribute) productType.getAttribute("attribute-name");

See the test code.

AttributeDefinitionContainer.findAttribute(String)

final Optional<AttributeDefinition> attribute = productType.findAttribute("attribute-name");

See the test code.

ProductTypeSetKeyAction.ofUnset()

final ProductType updatedProductType = projectApiRoot.productTypes()
        .withId(productType.getId())
        .post(ProductTypeUpdateBuilder.of()
                .version(productType.getVersion())
                .actions(ProductTypeSetKeyAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Product Selections

ProductSelectionMixin.toResourceIdentifier()

final ProductSelectionResourceIdentifier productSelectionResourceIdentifier = productSelection
        .toResourceIdentifier();

See the test code.

ProductSelectionMixin.toReference()

final ProductSelectionReference productSelectionReference = productSelection.toReference();

See the test code.

ProductSelection.referenceTypeId()

ReferenceTypeId referenceTypeId = ProductSelection.referenceTypeId();

See the test code.

Projects

ProjectSetShippingRateInputTypeAction.ofUnset()

final Project updatedProject = projectApiRoot.withProjectKey(project.getKey())
        .post(ProjectUpdateBuilder.of()
                .version(project.getVersion())
                .actions(ProjectSetShippingRateInputTypeAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Quotes

QuoteMixin.toResourceIdentifier()

final QuoteResourceIdentifier quoteResourceIdentifier = quote.toResourceIdentifier();

See the test code.

QuoteMixin.toReference()

final QuoteReference quoteReference = quote.toReference();

See the test code.

Quote.referenceTypeId()

ReferenceTypeId referenceTypeId = Quote.referenceTypeId();

See the test code.

QuoteSetCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();

final Quote updatedQuote = projectApiRoot.quotes()
        .withId(quote.getId())
        .post(QuoteUpdateBuilder.of()
                .version(quote.getVersion())
                .actions(QuoteSetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Quotes Requests

QuoteRequestSetCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();

final QuoteRequest updatedQuoteRequest = projectApiRoot.quoteRequests()
        .withId(quoteRequest.getId())
        .post(QuoteRequestUpdateBuilder.of()
                .version(quoteRequest.getVersion())
                .actions(QuoteRequestSetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Reviews

ReviewMixin.toResourceIdentifier()

final ReviewResourceIdentifier reviewResourceIdentifier = review.toResourceIdentifier();

See the test code.

ReviewMixin.toReference()

final ReviewReference reviewReference = review.toReference();

See the test code.

Review.referenceTypeId()

ReferenceTypeId referenceTypeId = Review.referenceTypeId();

See the test code.

ReviewSetCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();

final Review updatedReview = projectApiRoot.reviews()
        .withId(review.getId())
        .post(ReviewUpdateBuilder.of()
                .version(review.getVersion())
                .actions(ReviewSetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ReviewSetCustomerAction.ofUnset()

final Review updatedReview = projectApiRoot.reviews()
        .withId(review.getId())
        .post(ReviewUpdateBuilder.of()
                .version(review.getVersion())
                .actions(ReviewSetCustomerAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ReviewSetKeyAction.ofUnset()

final Review updatedReview = projectApiRoot.reviews()
        .withId(review.getId())
        .post(
            ReviewUpdateBuilder.of().version(review.getVersion()).actions(ReviewSetKeyAction.ofUnset()).build())
        .executeBlocking()
        .getBody();

See the test code.

Shipping Methods

ShippingMethodMixin.toResourceIdentifier()

final ShippingMethodResourceIdentifier shippingMethodResourceIdentifier = shippingMethod.toResourceIdentifier();

See the test code.

ShippingMethodMixin.toReference()

final ShippingMethodReference shippingMethodReference = shippingMethod.toReference();

See the test code.

ShippingMethod.referenceTypeId()

ReferenceTypeId referenceTypeId = ShippingMethod.referenceTypeId();

See the test code.

ShippingMethodSetCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();

final ShippingMethod updatedShippingMethod = projectApiRoot.shippingMethods()
        .withId(shippingMethod.getId())
        .post(ShippingMethodUpdateBuilder.of()
                .version(shippingMethod.getVersion())
                .actions(ShippingMethodSetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ShippingMethodSetKeyAction.ofUnset()

final ShippingMethod updatedShippingMethod = projectApiRoot.shippingMethods()
        .withId(shippingMethod.getId())
        .post(ShippingMethodUpdateBuilder.of()
                .version(shippingMethod.getVersion())
                .actions(ShippingMethodSetKeyAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Shopping Lists

ShoppingListMixin.toResourceIdentifier()

final ShoppingListResourceIdentifier shoppingListResourceIdentifier = shoppingList.toResourceIdentifier();

See the test code.

ShoppingListMixin.toReference()

final ShoppingListReference shoppingListReference = shoppingList.toReference();

See the test code.

ShoppingList.referenceTypeId()

ReferenceTypeId referenceTypeId = ShoppingList.referenceTypeId();

See the test code.

ShoppingListSetCustomerAction.ofUnset()

final ShoppingList updatedShoppingList = projectApiRoot.shoppingLists()
        .withId(shoppingList.getId())
        .post(ShoppingListUpdateBuilder.of()
                .version(shoppingList.getVersion())
                .actions(ShoppingListSetCustomerAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ShoppingListSetCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();

final ShoppingList updatedShoppingList = projectApiRoot.shoppingLists()
        .withId(shoppingList.getId())
        .post(ShoppingListUpdateBuilder.of()
                .version(shoppingList.getVersion())
                .actions(ShoppingListSetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ShoppingListSetDeleteDaysAfterLastModificationAction.ofUnset()

final ShoppingList updatedShoppingList = projectApiRoot.shoppingLists()
        .withId(shoppingList.getId())
        .post(ShoppingListUpdateBuilder.of()
                .version(shoppingList.getVersion())
                .actions(ShoppingListSetDeleteDaysAfterLastModificationAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ShoppingListSetLineItemCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String lineItemId = "test-lineItemId-" + UUID.randomUUID().toString();

final ShoppingList updatedShoppingList = projectApiRoot.shoppingLists()
        .withId(shoppingList.getId())
        .post(ShoppingListUpdateBuilder.of()
                .version(shoppingList.getVersion())
                .actions(ShoppingListSetLineItemCustomFieldAction.ofUnset(name, lineItemId))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ShoppingListSetKeyAction.ofUnset()

final ShoppingList updatedShoppingList = projectApiRoot.shoppingLists()
        .withId(shoppingList.getId())
        .post(ShoppingListUpdateBuilder.of()
                .version(shoppingList.getVersion())
                .actions(ShoppingListSetKeyAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ShoppingListSetTextLineItemCustomFieldAction.ofUnset(String, String)

final String name = "test-name-" + UUID.randomUUID().toString();
final String textLineItemId = "test-textLineItemId-" + UUID.randomUUID().toString();

final ShoppingList updatedShoppingList = projectApiRoot.shoppingLists()
        .withId(shoppingList.getId())
        .post(ShoppingListUpdateBuilder.of()
                .version(shoppingList.getVersion())
                .actions(ShoppingListSetTextLineItemCustomFieldAction.ofUnset(name, textLineItemId))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

ShoppingListSetSlugAction.ofUnset()

final ShoppingList updatedShoppingList = projectApiRoot.shoppingLists()
        .withId(shoppingList.getId())
        .post(ShoppingListUpdateBuilder.of()
                .version(shoppingList.getVersion())
                .actions(ShoppingListSetSlugAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Staged Quotes

StagedQuoteSetCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();

final StagedQuote updatedStagedQuote = projectApiRoot.stagedQuotes()
        .withId(stagedQuote.getId())
        .post(StagedQuoteUpdateBuilder.of()
                .version(stagedQuote.getVersion())
                .actions(StagedQuoteSetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Standalone Prices

StandalonePriceMixin.toResourceIdentifier()

final StandalonePriceResourceIdentifier standalonePriceResourceIdentifier = standalonePrice
        .toResourceIdentifier();

See the test code.

StandalonePriceMixin.toReference()

final StandalonePriceReference standalonePriceReference = standalonePrice.toReference();

See the test code.

StandalonePrice.referenceTypeId()

ReferenceTypeId referenceTypeId = StandalonePrice.referenceTypeId();

See the test code.

StandalonePriceSetCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();

final StandalonePrice updatedStandalonePrice = projectApiRoot.standalonePrices()
        .withId(standalonePrice.getId())
        .post(StandalonePriceUpdateBuilder.of()
                .version(standalonePrice.getVersion())
                .actions(StandalonePriceSetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

States

StateMixin.toResourceIdentifier()

final StateResourceIdentifier stateResourceIdentifier = state.toResourceIdentifier();

See the test code.

StateMixin.toReference()

final StateReference stateReference = state.toReference();

See the test code.

State.referenceTypeId()

ReferenceTypeId referenceTypeId = State.referenceTypeId();

See the test code.

Stores

StoreMixin.toResourceIdentifier()

final StoreResourceIdentifier storeResourceIdentifier = store.toResourceIdentifier();

See the test code.

StoreMixin.toReference()

final StoreReference storeReference = store.toReference();

See the test code.

Store.referenceTypeId()

ReferenceTypeId referenceTypeId = Store.referenceTypeId();

See the test code.

StoreSetCustomFieldAction.ofUnset(String)

final String name = "test-name-" + UUID.randomUUID().toString();

final Store updatedStore = projectApiRoot.stores()
        .withId(store.getId())
        .post(StoreUpdateBuilder.of()
                .version(store.getVersion())
                .actions(StoreSetCustomFieldAction.ofUnset(name))
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Subscriptions

SubscriptionSetMessagesAction.ofUnset()

final Subscription updatedSubscription = projectApiRoot.subscriptions()
        .withId(subscription.getId())
        .post(SubscriptionUpdateBuilder.of()
                .version(subscription.getVersion())
                .actions(SubscriptionSetMessagesAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

SubscriptionSetChangesAction.ofUnset()

final Subscription updatedSubscription = projectApiRoot.subscriptions()
        .withId(subscription.getId())
        .post(SubscriptionUpdateBuilder.of()
                .version(subscription.getVersion())
                .actions(SubscriptionSetChangesAction.ofUnset())
                .build())
        .executeBlocking()
        .getBody();

See the test code.

Tax Categories

TaxCategoryMixin.toResourceIdentifier()

final TaxCategoryResourceIdentifier taxCategoryResourceIdentifier = taxCategory.toResourceIdentifier();

See the test code.

TaxCategoryMixin.toReference()

final TaxCategoryReference taxCategoryReference = taxCategory.toReference();

See the test code.

TaxCategory.referenceTypeId()

ReferenceTypeId referenceTypeId = TaxCategory.referenceTypeId();

See the test code.

Types

TypeMixin.toResourceIdentifier()

final TypeResourceIdentifier typeResourceIdentifier = type.toResourceIdentifier();

See the test code.

TypeMixin.toReference()

final TypeReference typeReference = type.toReference();

See the test code.

Type.referenceTypeId()

ReferenceTypeId referenceTypeId = Type.referenceTypeId();

See the test code.

TypeMixin.getFieldDefinitionByName(String)

String name = type.getFieldDefinitionByName("type-test-name").getType().getName();
LocalizedString label = type.getFieldDefinitionByName("type-test-name").getLabel();
TypeTextInputHint inputHint = type.getFieldDefinitionByName("type-test-name").getInputHint();
Boolean isRequired = type.getFieldDefinitionByName("type-test-name").getRequired();

See the test code.

CustomFieldsMixin.toDraft()

final CustomFields customField = CustomFieldsBuilder.of().fields(FieldContainerBuilder.of().build()).build();

final CustomFieldsDraft customFieldsDraft = customField.toDraft();

See the test code.

CustomFieldsMixin.toDraftBuilder()

final CustomFields customField = CustomFieldsBuilder.of().fields(FieldContainerBuilder.of().build()).build();

final CustomFieldsDraftBuilder customFieldsDraftBuilder = customField.toDraftBuilder();

See the test code.

Zones

ZoneMixin.toResourceIdentifier()

final ZoneResourceIdentifier zoneResourceIdentifier = zone.toResourceIdentifier();

See the test code.

ZoneMixin.toReference()

final ZoneReference zoneReference = zone.toReference();

See the test code.

Zone.referenceTypeId()

ReferenceTypeId referenceTypeId = Zone.referenceTypeId();

See the test code.

ZoneMixin.contains(String)

boolean hasZoneCountryCode = zone.contains("DE");

See the test code.

ResourcePagedQueryResponse

ResourcePagedQueryResponse.head()

CategoryPagedQueryResponse queryResponse = projectApiRoot.withProjectKey("project-key")
        .categories()
        .get()
        .withWhere("id = :catId")
        .withPredicateVar("catId", category.getId())
        .executeBlocking()
        .getBody();

Category categoryHead = queryResponse.head().get();

See the test code.

ResourcePagedQueryResponse.getPageIndex()

CategoryPagedQueryResponse queryResponse = CategoryPagedQueryResponseBuilder.of()
        .offset(100L)
        .limit(25L)
        .total(125L)
        .results(category)
        .build();
long pageIndex = queryResponse.getPageIndex();

See the test code.

ResourcePagedQueryResponse.getTotalPages()

CategoryPagedQueryResponse queryResponse = CategoryPagedQueryResponseBuilder.of()
        .offset(100L)
        .limit(25L)
        .total(125L)
        .results(category)
        .build();
long totalPages = queryResponse.getTotalPages();

See the test code.

ResourcePagedQueryResponse.isFirst()

CategoryPagedQueryResponse queryResponse = CategoryPagedQueryResponseBuilder.of()
        .offset(100L)
        .limit(25L)
        .total(125L)
        .results(category)
        .build();
boolean isFirst = queryResponse.isFirst();

See the test code.

ResourcePagedQueryResponse.isLast()

CategoryPagedQueryResponse queryResponse = CategoryPagedQueryResponseBuilder.of()
        .offset(100L)
        .limit(25L)
        .total(125L)
        .results(category)
        .build();
boolean isLast = queryResponse.isLast();

See the test code.

  • Constructor Details

    • HelperMethods

      public HelperMethods()