001
002package com.commercetools.api.models.cart;
003
004import java.time.*;
005import java.util.*;
006import java.util.function.Function;
007import java.util.stream.Collectors;
008
009import javax.annotation.Nullable;
010import javax.validation.Valid;
011import javax.validation.constraints.NotNull;
012
013import com.commercetools.api.models.common.BaseAddress;
014import com.commercetools.api.models.order.DeliveryDraft;
015import com.commercetools.api.models.shipping_method.ShippingMethodReference;
016import com.commercetools.api.models.type.CustomFieldsDraft;
017import com.fasterxml.jackson.annotation.*;
018import com.fasterxml.jackson.databind.annotation.*;
019
020import io.vrap.rmf.base.client.utils.Generated;
021
022/**
023 *  <p>Wraps all shipping-related information (such as address, rate, deliveries) per Shipping Method for Carts with multiple Shipping Methods.</p>
024 *
025 * <hr>
026 * Example to create an instance using the builder pattern
027 * <div class=code-example>
028 * <pre><code class='java'>
029 *     ShippingDraft shippingDraft = ShippingDraft.builder()
030 *             .key("{key}")
031 *             .shippingAddress(shippingAddressBuilder -> shippingAddressBuilder)
032 *             .build()
033 * </code></pre>
034 * </div>
035 */
036@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
037@JsonDeserialize(as = ShippingDraftImpl.class)
038public interface ShippingDraft
039        extends com.commercetools.api.models.WithKey, io.vrap.rmf.base.client.Draft<ShippingDraft> {
040
041    /**
042     *  <p>User-defined unique identifier for the Shipping in a Cart with <code>Multiple</code> ShippingMode.</p>
043     * @return key
044     */
045    @NotNull
046    @JsonProperty("key")
047    public String getKey();
048
049    /**
050     *  <p>Shipping Methods added to the Cart with <code>Multiple</code> ShippingMode.</p>
051     * @return shippingMethod
052     */
053    @Valid
054    @JsonProperty("shippingMethod")
055    public ShippingMethodReference getShippingMethod();
056
057    /**
058     *  <p>Determines the shipping rate and Tax Rate of the associated Line Items.</p>
059     * @return shippingAddress
060     */
061    @NotNull
062    @Valid
063    @JsonProperty("shippingAddress")
064    public BaseAddress getShippingAddress();
065
066    /**
067     *  <p>Input used to select a ShippingRatePriceTier. The data type of this field depends on the <code>shippingRateInputType.type</code> configured in the Project:</p>
068     *  <ul>
069     *   <li>If <code>CartClassification</code>, it must be ClassificationShippingRateInputDraft.</li>
070     *   <li>If <code>CartScore</code>, it must be ScoreShippingRateInputDraft.</li>
071     *   <li>If <code>CartValue</code>, it cannot be set.</li>
072     *  </ul>
073     * @return shippingRateInput
074     */
075    @Valid
076    @JsonProperty("shippingRateInput")
077    public ShippingRateInputDraft getShippingRateInput();
078
079    /**
080     *  <p>Tax Rate used for taxing a shipping expense if the Cart has the <code>External</code> TaxMode.</p>
081     * @return externalTaxRate
082     */
083    @Valid
084    @JsonProperty("externalTaxRate")
085    public ExternalTaxRateDraft getExternalTaxRate();
086
087    /**
088     *  <p>Deliveries to be shipped with the Shipping Method.</p>
089     * @return deliveries
090     */
091    @Valid
092    @JsonProperty("deliveries")
093    public List<DeliveryDraft> getDeliveries();
094
095    /**
096     *  <p>Custom Fields for Shipping.</p>
097     * @return custom
098     */
099    @Valid
100    @JsonProperty("custom")
101    public CustomFieldsDraft getCustom();
102
103    /**
104     *  <p>User-defined unique identifier for the Shipping in a Cart with <code>Multiple</code> ShippingMode.</p>
105     * @param key value to be set
106     */
107
108    public void setKey(final String key);
109
110    /**
111     *  <p>Shipping Methods added to the Cart with <code>Multiple</code> ShippingMode.</p>
112     * @param shippingMethod value to be set
113     */
114
115    public void setShippingMethod(final ShippingMethodReference shippingMethod);
116
117    /**
118     *  <p>Determines the shipping rate and Tax Rate of the associated Line Items.</p>
119     * @param shippingAddress value to be set
120     */
121
122    public void setShippingAddress(final BaseAddress shippingAddress);
123
124    /**
125     *  <p>Input used to select a ShippingRatePriceTier. The data type of this field depends on the <code>shippingRateInputType.type</code> configured in the Project:</p>
126     *  <ul>
127     *   <li>If <code>CartClassification</code>, it must be ClassificationShippingRateInputDraft.</li>
128     *   <li>If <code>CartScore</code>, it must be ScoreShippingRateInputDraft.</li>
129     *   <li>If <code>CartValue</code>, it cannot be set.</li>
130     *  </ul>
131     * @param shippingRateInput value to be set
132     */
133
134    public void setShippingRateInput(final ShippingRateInputDraft shippingRateInput);
135
136    /**
137     *  <p>Tax Rate used for taxing a shipping expense if the Cart has the <code>External</code> TaxMode.</p>
138     * @param externalTaxRate value to be set
139     */
140
141    public void setExternalTaxRate(final ExternalTaxRateDraft externalTaxRate);
142
143    /**
144     *  <p>Deliveries to be shipped with the Shipping Method.</p>
145     * @param deliveries values to be set
146     */
147
148    @JsonIgnore
149    public void setDeliveries(final DeliveryDraft... deliveries);
150
151    /**
152     *  <p>Deliveries to be shipped with the Shipping Method.</p>
153     * @param deliveries values to be set
154     */
155
156    public void setDeliveries(final List<DeliveryDraft> deliveries);
157
158    /**
159     *  <p>Custom Fields for Shipping.</p>
160     * @param custom value to be set
161     */
162
163    public void setCustom(final CustomFieldsDraft custom);
164
165    /**
166     * factory method
167     * @return instance of ShippingDraft
168     */
169    public static ShippingDraft of() {
170        return new ShippingDraftImpl();
171    }
172
173    /**
174     * factory method to create a shallow copy ShippingDraft
175     * @param template instance to be copied
176     * @return copy instance
177     */
178    public static ShippingDraft of(final ShippingDraft template) {
179        ShippingDraftImpl instance = new ShippingDraftImpl();
180        instance.setKey(template.getKey());
181        instance.setShippingMethod(template.getShippingMethod());
182        instance.setShippingAddress(template.getShippingAddress());
183        instance.setShippingRateInput(template.getShippingRateInput());
184        instance.setExternalTaxRate(template.getExternalTaxRate());
185        instance.setDeliveries(template.getDeliveries());
186        instance.setCustom(template.getCustom());
187        return instance;
188    }
189
190    /**
191     * factory method to create a deep copy of ShippingDraft
192     * @param template instance to be copied
193     * @return copy instance
194     */
195    @Nullable
196    public static ShippingDraft deepCopy(@Nullable final ShippingDraft template) {
197        if (template == null) {
198            return null;
199        }
200        ShippingDraftImpl instance = new ShippingDraftImpl();
201        instance.setKey(template.getKey());
202        instance.setShippingMethod(com.commercetools.api.models.shipping_method.ShippingMethodReference
203                .deepCopy(template.getShippingMethod()));
204        instance.setShippingAddress(
205            com.commercetools.api.models.common.BaseAddress.deepCopy(template.getShippingAddress()));
206        instance.setShippingRateInput(
207            com.commercetools.api.models.cart.ShippingRateInputDraft.deepCopy(template.getShippingRateInput()));
208        instance.setExternalTaxRate(
209            com.commercetools.api.models.cart.ExternalTaxRateDraft.deepCopy(template.getExternalTaxRate()));
210        instance.setDeliveries(Optional.ofNullable(template.getDeliveries())
211                .map(t -> t.stream()
212                        .map(com.commercetools.api.models.order.DeliveryDraft::deepCopy)
213                        .collect(Collectors.toList()))
214                .orElse(null));
215        instance.setCustom(com.commercetools.api.models.type.CustomFieldsDraft.deepCopy(template.getCustom()));
216        return instance;
217    }
218
219    /**
220     * builder factory method for ShippingDraft
221     * @return builder
222     */
223    public static ShippingDraftBuilder builder() {
224        return ShippingDraftBuilder.of();
225    }
226
227    /**
228     * create builder for ShippingDraft instance
229     * @param template instance with prefilled values for the builder
230     * @return builder
231     */
232    public static ShippingDraftBuilder builder(final ShippingDraft template) {
233        return ShippingDraftBuilder.of(template);
234    }
235
236    /**
237     * accessor map function
238     * @param <T> mapped type
239     * @param helper function to map the object
240     * @return mapped value
241     */
242    default <T> T withShippingDraft(Function<ShippingDraft, T> helper) {
243        return helper.apply(this);
244    }
245
246    /**
247     * gives a TypeReference for usage with Jackson DataBind
248     * @return TypeReference
249     */
250    public static com.fasterxml.jackson.core.type.TypeReference<ShippingDraft> typeReference() {
251        return new com.fasterxml.jackson.core.type.TypeReference<ShippingDraft>() {
252            @Override
253            public String toString() {
254                return "TypeReference<ShippingDraft>";
255            }
256        };
257    }
258}