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.shipping_method.ShippingRateDraft;
013import com.commercetools.api.models.tax_category.TaxCategoryResourceIdentifier;
014import com.fasterxml.jackson.annotation.*;
015import com.fasterxml.jackson.databind.annotation.*;
016
017import io.vrap.rmf.base.client.utils.Generated;
018
019/**
020 *  <p>To set the Cart's custom Shipping Method (independent of the ShippingMethods managed through the Shipping Methods API) the Cart must have the <code>Single</code> ShippingMode and a <code>shippingAddress</code>.</p>
021 *  <p>To unset a custom Shipping Method on a Cart, use the Set ShippingMethod update action without the <code>shippingMethod</code> field instead.</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 *     CartSetCustomShippingMethodAction cartSetCustomShippingMethodAction = CartSetCustomShippingMethodAction.builder()
028 *             .shippingMethodName("{shippingMethodName}")
029 *             .shippingRate(shippingRateBuilder -> shippingRateBuilder)
030 *             .build()
031 * </code></pre>
032 * </div>
033 */
034@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
035@JsonDeserialize(as = CartSetCustomShippingMethodActionImpl.class)
036public interface CartSetCustomShippingMethodAction extends CartUpdateAction {
037
038    /**
039     * discriminator value for CartSetCustomShippingMethodAction
040     */
041    String SET_CUSTOM_SHIPPING_METHOD = "setCustomShippingMethod";
042
043    /**
044     *  <p>Name of the custom Shipping Method.</p>
045     * @return shippingMethodName
046     */
047    @NotNull
048    @JsonProperty("shippingMethodName")
049    public String getShippingMethodName();
050
051    /**
052     *  <p>Determines the shipping price.</p>
053     * @return shippingRate
054     */
055    @NotNull
056    @Valid
057    @JsonProperty("shippingRate")
058    public ShippingRateDraft getShippingRate();
059
060    /**
061     *  <p>Tax Category used to determine the Tax Rate when the Cart has the <code>Platform</code> TaxMode.</p>
062     * @return taxCategory
063     */
064    @Valid
065    @JsonProperty("taxCategory")
066    public TaxCategoryResourceIdentifier getTaxCategory();
067
068    /**
069     *  <p>External Tax Rate for the <code>shippingRate</code> to be set if the Cart has the <code>External</code> TaxMode.</p>
070     * @return externalTaxRate
071     */
072    @Valid
073    @JsonProperty("externalTaxRate")
074    public ExternalTaxRateDraft getExternalTaxRate();
075
076    /**
077     *  <p>Name of the custom Shipping Method.</p>
078     * @param shippingMethodName value to be set
079     */
080
081    public void setShippingMethodName(final String shippingMethodName);
082
083    /**
084     *  <p>Determines the shipping price.</p>
085     * @param shippingRate value to be set
086     */
087
088    public void setShippingRate(final ShippingRateDraft shippingRate);
089
090    /**
091     *  <p>Tax Category used to determine the Tax Rate when the Cart has the <code>Platform</code> TaxMode.</p>
092     * @param taxCategory value to be set
093     */
094
095    public void setTaxCategory(final TaxCategoryResourceIdentifier taxCategory);
096
097    /**
098     *  <p>External Tax Rate for the <code>shippingRate</code> to be set if the Cart has the <code>External</code> TaxMode.</p>
099     * @param externalTaxRate value to be set
100     */
101
102    public void setExternalTaxRate(final ExternalTaxRateDraft externalTaxRate);
103
104    /**
105     * factory method
106     * @return instance of CartSetCustomShippingMethodAction
107     */
108    public static CartSetCustomShippingMethodAction of() {
109        return new CartSetCustomShippingMethodActionImpl();
110    }
111
112    /**
113     * factory method to create a shallow copy CartSetCustomShippingMethodAction
114     * @param template instance to be copied
115     * @return copy instance
116     */
117    public static CartSetCustomShippingMethodAction of(final CartSetCustomShippingMethodAction template) {
118        CartSetCustomShippingMethodActionImpl instance = new CartSetCustomShippingMethodActionImpl();
119        instance.setShippingMethodName(template.getShippingMethodName());
120        instance.setShippingRate(template.getShippingRate());
121        instance.setTaxCategory(template.getTaxCategory());
122        instance.setExternalTaxRate(template.getExternalTaxRate());
123        return instance;
124    }
125
126    /**
127     * factory method to create a deep copy of CartSetCustomShippingMethodAction
128     * @param template instance to be copied
129     * @return copy instance
130     */
131    @Nullable
132    public static CartSetCustomShippingMethodAction deepCopy(
133            @Nullable final CartSetCustomShippingMethodAction template) {
134        if (template == null) {
135            return null;
136        }
137        CartSetCustomShippingMethodActionImpl instance = new CartSetCustomShippingMethodActionImpl();
138        instance.setShippingMethodName(template.getShippingMethodName());
139        instance.setShippingRate(
140            com.commercetools.api.models.shipping_method.ShippingRateDraft.deepCopy(template.getShippingRate()));
141        instance.setTaxCategory(com.commercetools.api.models.tax_category.TaxCategoryResourceIdentifier
142                .deepCopy(template.getTaxCategory()));
143        instance.setExternalTaxRate(
144            com.commercetools.api.models.cart.ExternalTaxRateDraft.deepCopy(template.getExternalTaxRate()));
145        return instance;
146    }
147
148    /**
149     * builder factory method for CartSetCustomShippingMethodAction
150     * @return builder
151     */
152    public static CartSetCustomShippingMethodActionBuilder builder() {
153        return CartSetCustomShippingMethodActionBuilder.of();
154    }
155
156    /**
157     * create builder for CartSetCustomShippingMethodAction instance
158     * @param template instance with prefilled values for the builder
159     * @return builder
160     */
161    public static CartSetCustomShippingMethodActionBuilder builder(final CartSetCustomShippingMethodAction template) {
162        return CartSetCustomShippingMethodActionBuilder.of(template);
163    }
164
165    /**
166     * accessor map function
167     * @param <T> mapped type
168     * @param helper function to map the object
169     * @return mapped value
170     */
171    default <T> T withCartSetCustomShippingMethodAction(Function<CartSetCustomShippingMethodAction, T> helper) {
172        return helper.apply(this);
173    }
174
175    /**
176     * gives a TypeReference for usage with Jackson DataBind
177     * @return TypeReference
178     */
179    public static com.fasterxml.jackson.core.type.TypeReference<CartSetCustomShippingMethodAction> typeReference() {
180        return new com.fasterxml.jackson.core.type.TypeReference<CartSetCustomShippingMethodAction>() {
181            @Override
182            public String toString() {
183                return "TypeReference<CartSetCustomShippingMethodAction>";
184            }
185        };
186    }
187}