001 002package com.commercetools.api.models.cart; 003 004import java.time.*; 005import java.util.*; 006import java.util.function.Function; 007 008import javax.annotation.Nullable; 009import javax.validation.Valid; 010import javax.validation.constraints.NotNull; 011 012import com.commercetools.api.models.common.Money; 013import com.fasterxml.jackson.annotation.*; 014import com.fasterxml.jackson.databind.annotation.*; 015 016import io.vrap.rmf.base.client.utils.Generated; 017 018/** 019 * <p>When multiple shipping addresses are set for a Line Item, use the Remove LineItem and Add LineItem update action to change the shipping details. Since it is not possible for the API to infer how the overall change in the Line Item quantity should be distributed over the sub-quantities, the <code>shippingDetails</code> field is kept in its current state to avoid data loss.</p> 020 * <p>To change the Line Item quantity and shipping details together, use this update action in combination with the Set LineItemShippingDetails update action in a single Cart update command.</p> 021 * <p>The LineItem price is set as described in LineItem Price selection.</p> 022 * 023 * <hr> 024 * Example to create an instance using the builder pattern 025 * <div class=code-example> 026 * <pre><code class='java'> 027 * CartChangeLineItemQuantityAction cartChangeLineItemQuantityAction = CartChangeLineItemQuantityAction.builder() 028 * .quantity(0.3) 029 * .build() 030 * </code></pre> 031 * </div> 032 */ 033@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 034@JsonDeserialize(as = CartChangeLineItemQuantityActionImpl.class) 035public interface CartChangeLineItemQuantityAction extends CartUpdateAction { 036 037 /** 038 * discriminator value for CartChangeLineItemQuantityAction 039 */ 040 String CHANGE_LINE_ITEM_QUANTITY = "changeLineItemQuantity"; 041 042 /** 043 * <p><code>id</code> of the LineItem to update. Either <code>lineItemId</code> or <code>lineItemKey</code> is required.</p> 044 * @return lineItemId 045 */ 046 047 @JsonProperty("lineItemId") 048 public String getLineItemId(); 049 050 /** 051 * <p><code>key</code> of the LineItem to update. Either <code>lineItemId</code> or <code>lineItemKey</code> is required.</p> 052 * @return lineItemKey 053 */ 054 055 @JsonProperty("lineItemKey") 056 public String getLineItemKey(); 057 058 /** 059 * <p>New value to set.</p> 060 * <p>If <code>0</code>, the Line Item is removed from the Cart.</p> 061 * @return quantity 062 */ 063 @NotNull 064 @JsonProperty("quantity") 065 public Long getQuantity(); 066 067 /** 068 * <p>Sets the LineItem <code>price</code> to the given value when changing the quantity of a Line Item with the <code>ExternalPrice</code> LineItemPriceMode.</p> 069 * <p>The LineItem price is updated as described in LineItem Price selection.</p> 070 * @return externalPrice 071 */ 072 @Valid 073 @JsonProperty("externalPrice") 074 public Money getExternalPrice(); 075 076 /** 077 * <p>Sets the LineItem <code>price</code> and <code>totalPrice</code> to the given value when changing the quantity of a Line Item with the <code>ExternalTotal</code> LineItemPriceMode.</p> 078 * @return externalTotalPrice 079 */ 080 @Valid 081 @JsonProperty("externalTotalPrice") 082 public ExternalLineItemTotalPrice getExternalTotalPrice(); 083 084 /** 085 * <p><code>id</code> of the LineItem to update. Either <code>lineItemId</code> or <code>lineItemKey</code> is required.</p> 086 * @param lineItemId value to be set 087 */ 088 089 public void setLineItemId(final String lineItemId); 090 091 /** 092 * <p><code>key</code> of the LineItem to update. Either <code>lineItemId</code> or <code>lineItemKey</code> is required.</p> 093 * @param lineItemKey value to be set 094 */ 095 096 public void setLineItemKey(final String lineItemKey); 097 098 /** 099 * <p>New value to set.</p> 100 * <p>If <code>0</code>, the Line Item is removed from the Cart.</p> 101 * @param quantity value to be set 102 */ 103 104 public void setQuantity(final Long quantity); 105 106 /** 107 * <p>Sets the LineItem <code>price</code> to the given value when changing the quantity of a Line Item with the <code>ExternalPrice</code> LineItemPriceMode.</p> 108 * <p>The LineItem price is updated as described in LineItem Price selection.</p> 109 * @param externalPrice value to be set 110 */ 111 112 public void setExternalPrice(final Money externalPrice); 113 114 /** 115 * <p>Sets the LineItem <code>price</code> and <code>totalPrice</code> to the given value when changing the quantity of a Line Item with the <code>ExternalTotal</code> LineItemPriceMode.</p> 116 * @param externalTotalPrice value to be set 117 */ 118 119 public void setExternalTotalPrice(final ExternalLineItemTotalPrice externalTotalPrice); 120 121 /** 122 * factory method 123 * @return instance of CartChangeLineItemQuantityAction 124 */ 125 public static CartChangeLineItemQuantityAction of() { 126 return new CartChangeLineItemQuantityActionImpl(); 127 } 128 129 /** 130 * factory method to create a shallow copy CartChangeLineItemQuantityAction 131 * @param template instance to be copied 132 * @return copy instance 133 */ 134 public static CartChangeLineItemQuantityAction of(final CartChangeLineItemQuantityAction template) { 135 CartChangeLineItemQuantityActionImpl instance = new CartChangeLineItemQuantityActionImpl(); 136 instance.setLineItemId(template.getLineItemId()); 137 instance.setLineItemKey(template.getLineItemKey()); 138 instance.setQuantity(template.getQuantity()); 139 instance.setExternalPrice(template.getExternalPrice()); 140 instance.setExternalTotalPrice(template.getExternalTotalPrice()); 141 return instance; 142 } 143 144 /** 145 * factory method to create a deep copy of CartChangeLineItemQuantityAction 146 * @param template instance to be copied 147 * @return copy instance 148 */ 149 @Nullable 150 public static CartChangeLineItemQuantityAction deepCopy(@Nullable final CartChangeLineItemQuantityAction template) { 151 if (template == null) { 152 return null; 153 } 154 CartChangeLineItemQuantityActionImpl instance = new CartChangeLineItemQuantityActionImpl(); 155 instance.setLineItemId(template.getLineItemId()); 156 instance.setLineItemKey(template.getLineItemKey()); 157 instance.setQuantity(template.getQuantity()); 158 instance.setExternalPrice(com.commercetools.api.models.common.Money.deepCopy(template.getExternalPrice())); 159 instance.setExternalTotalPrice( 160 com.commercetools.api.models.cart.ExternalLineItemTotalPrice.deepCopy(template.getExternalTotalPrice())); 161 return instance; 162 } 163 164 /** 165 * builder factory method for CartChangeLineItemQuantityAction 166 * @return builder 167 */ 168 public static CartChangeLineItemQuantityActionBuilder builder() { 169 return CartChangeLineItemQuantityActionBuilder.of(); 170 } 171 172 /** 173 * create builder for CartChangeLineItemQuantityAction instance 174 * @param template instance with prefilled values for the builder 175 * @return builder 176 */ 177 public static CartChangeLineItemQuantityActionBuilder builder(final CartChangeLineItemQuantityAction template) { 178 return CartChangeLineItemQuantityActionBuilder.of(template); 179 } 180 181 /** 182 * accessor map function 183 * @param <T> mapped type 184 * @param helper function to map the object 185 * @return mapped value 186 */ 187 default <T> T withCartChangeLineItemQuantityAction(Function<CartChangeLineItemQuantityAction, T> helper) { 188 return helper.apply(this); 189 } 190 191 /** 192 * gives a TypeReference for usage with Jackson DataBind 193 * @return TypeReference 194 */ 195 public static com.fasterxml.jackson.core.type.TypeReference<CartChangeLineItemQuantityAction> typeReference() { 196 return new com.fasterxml.jackson.core.type.TypeReference<CartChangeLineItemQuantityAction>() { 197 @Override 198 public String toString() { 199 return "TypeReference<CartChangeLineItemQuantityAction>"; 200 } 201 }; 202 } 203}