public final class AddLineItem extends UpdateActionImpl<ShoppingList> implements CustomDraft
See also ShoppingListInStoreUpdateCommand.
withTaxedProduct(client(), product -> { withUpdateableShoppingList(client(), shoppingList -> { final ShoppingList updatedShoppingList = client().executeBlocking( ShoppingListUpdateCommand.of(shoppingList, AddLineItem.of(product).withVariantId(1).withQuantity(2L))); assertThat(updatedShoppingList.getLineItems()).hasSize(1); final LineItem lineItem = updatedShoppingList.getLineItems().get(0); assertThat(lineItem.getProductId()).isEqualTo(product.getId()); assertThat(lineItem.getVariantId()).isEqualTo(1); assertThat(lineItem.getQuantity()).isEqualTo(2); assertThat(lineItem.getAddedAt()).isNotNull(); return updatedShoppingList; }); });
See the test code.
ShoppingList.getLineItems()
Modifier and Type | Method and Description |
---|---|
ZonedDateTime |
getAddedAt() |
CustomFieldsDraft |
getCustom() |
String |
getProductId() |
Long |
getQuantity() |
String |
getSku() |
Integer |
getVariantId() |
static AddLineItem |
of(LineItemDraft draft) |
static AddLineItem |
of(ProductIdentifiable product) |
static AddLineItem |
of(String productId) |
static AddLineItem |
ofSku(String sku) |
AddLineItem |
withAddedAt(ZonedDateTime addedAt) |
AddLineItem |
withCustom(CustomFieldsDraft custom) |
AddLineItem |
withQuantity(Long quantity) |
AddLineItem |
withSku(String sku) |
AddLineItem |
withVariantId(Integer variantId) |
getAction
public static AddLineItem of(ProductIdentifiable product)
public static AddLineItem of(LineItemDraft draft)
public static AddLineItem of(String productId)
public static AddLineItem ofSku(String sku)
@Nullable public ZonedDateTime getAddedAt()
@Nullable public CustomFieldsDraft getCustom()
getCustom
in interface CustomDraft
public AddLineItem withVariantId(@Nullable Integer variantId)
public AddLineItem withQuantity(@Nullable Long quantity)
public AddLineItem withCustom(@Nullable CustomFieldsDraft custom)
public AddLineItem withAddedAt(@Nullable ZonedDateTime addedAt)
public AddLineItem withSku(@Nullable String sku)