001
002package com.commercetools.api.client;
003
004import java.net.URI;
005import java.time.Duration;
006import java.util.ArrayList;
007import java.util.Collection;
008import java.util.List;
009import java.util.concurrent.CompletableFuture;
010import java.util.function.Function;
011import java.util.function.Supplier;
012import java.util.stream.Collectors;
013
014import io.vrap.rmf.base.client.*;
015import io.vrap.rmf.base.client.utils.Generated;
016
017import org.apache.commons.lang3.builder.EqualsBuilder;
018import org.apache.commons.lang3.builder.HashCodeBuilder;
019
020/**
021 *  <p>If the Order exists in the Project but does not have the <code>store</code> field, or the <code>store</code> field references a different Store, this method returns a ResourceNotFound error.</p>
022 *
023 * <hr>
024 * <div class=code-example>
025 * <pre><code class='java'>{@code
026 *   CompletableFuture<ApiHttpResponse<com.commercetools.api.models.order.Order>> result = apiRoot
027 *            .withProjectKey("{projectKey}")
028 *            .inStoreKeyWithStoreKeyValue("{storeKey}")
029 *            .me()
030 *            .orders()
031 *            .withId("{ID}")
032 *            .get()
033 *            .execute()
034 * }</code></pre>
035 * </div>
036 */
037@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
038public class ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet
039        extends ApiMethod<ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet, com.commercetools.api.models.order.Order>
040        implements com.commercetools.api.client.ExpandableTrait<ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet>,
041        com.commercetools.api.client.ErrorableTrait<ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet>,
042        com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet> {
043
044    private String projectKey;
045    private String storeKey;
046    private String ID;
047
048    public ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet(final ApiHttpClient apiHttpClient, String projectKey,
049            String storeKey, String ID) {
050        super(apiHttpClient);
051        this.projectKey = projectKey;
052        this.storeKey = storeKey;
053        this.ID = ID;
054    }
055
056    public ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet(ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet t) {
057        super(t);
058        this.projectKey = t.projectKey;
059        this.storeKey = t.storeKey;
060        this.ID = t.ID;
061    }
062
063    @Override
064    protected ApiHttpRequest buildHttpRequest() {
065        List<String> params = new ArrayList<>(getQueryParamUriStrings());
066        String httpRequestPath = String.format("%s/in-store/key=%s/me/orders/%s", this.projectKey, this.storeKey,
067            this.ID);
068        if (!params.isEmpty()) {
069            httpRequestPath += "?" + String.join("&", params);
070        }
071        return new ApiHttpRequest(ApiHttpMethod.GET, URI.create(httpRequestPath), getHeaders(), null);
072    }
073
074    @Override
075    public ApiHttpResponse<com.commercetools.api.models.order.Order> executeBlocking(final ApiHttpClient client,
076            final Duration timeout) {
077        return executeBlocking(client, timeout, com.commercetools.api.models.order.Order.class);
078    }
079
080    @Override
081    public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.order.Order>> execute(
082            final ApiHttpClient client) {
083        return execute(client, com.commercetools.api.models.order.Order.class);
084    }
085
086    public String getProjectKey() {
087        return this.projectKey;
088    }
089
090    public String getStoreKey() {
091        return this.storeKey;
092    }
093
094    public String getID() {
095        return this.ID;
096    }
097
098    public List<String> getExpand() {
099        return this.getQueryParam("expand");
100    }
101
102    public void setProjectKey(final String projectKey) {
103        this.projectKey = projectKey;
104    }
105
106    public void setStoreKey(final String storeKey) {
107        this.storeKey = storeKey;
108    }
109
110    public void setID(final String ID) {
111        this.ID = ID;
112    }
113
114    /**
115     * set expand with the specified value
116     * @param expand value to be set
117     * @param <TValue> value type
118     * @return ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet
119     */
120    public <TValue> ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet withExpand(final TValue expand) {
121        return copy().withQueryParam("expand", expand);
122    }
123
124    /**
125     * add additional expand query parameter
126     * @param expand value to be added
127     * @param <TValue> value type
128     * @return ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet
129     */
130    public <TValue> ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet addExpand(final TValue expand) {
131        return copy().addQueryParam("expand", expand);
132    }
133
134    /**
135     * set expand with the specified value
136     * @param supplier supplier for the value to be set
137     * @return ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet
138     */
139    public ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet withExpand(final Supplier<String> supplier) {
140        return copy().withQueryParam("expand", supplier.get());
141    }
142
143    /**
144     * add additional expand query parameter
145     * @param supplier supplier for the value to be added
146     * @return ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet
147     */
148    public ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet addExpand(final Supplier<String> supplier) {
149        return copy().addQueryParam("expand", supplier.get());
150    }
151
152    /**
153     * set expand with the specified value
154     * @param op builder for the value to be set
155     * @return ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet
156     */
157    public ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet withExpand(final Function<StringBuilder, StringBuilder> op) {
158        return copy().withQueryParam("expand", op.apply(new StringBuilder()));
159    }
160
161    /**
162     * add additional expand query parameter
163     * @param op builder for the value to be added
164     * @return ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet
165     */
166    public ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet addExpand(final Function<StringBuilder, StringBuilder> op) {
167        return copy().addQueryParam("expand", op.apply(new StringBuilder()));
168    }
169
170    /**
171     * set expand with the specified values
172     * @param expand values to be set
173     * @param <TValue> value type
174     * @return ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet
175     */
176    public <TValue> ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet withExpand(final Collection<TValue> expand) {
177        return copy().withoutQueryParam("expand")
178                .addQueryParams(
179                    expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList()));
180    }
181
182    /**
183     * add additional expand query parameters
184     * @param expand values to be added
185     * @param <TValue> value type
186     * @return ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet
187     */
188    public <TValue> ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet addExpand(final Collection<TValue> expand) {
189        return copy().addQueryParams(
190            expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList()));
191    }
192
193    @Override
194    public boolean equals(Object o) {
195        if (this == o)
196            return true;
197
198        if (o == null || getClass() != o.getClass())
199            return false;
200
201        ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet that = (ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet) o;
202
203        return new EqualsBuilder().append(projectKey, that.projectKey)
204                .append(storeKey, that.storeKey)
205                .append(ID, that.ID)
206                .isEquals();
207    }
208
209    @Override
210    public int hashCode() {
211        return new HashCodeBuilder(17, 37).append(projectKey).append(storeKey).append(ID).toHashCode();
212    }
213
214    @Override
215    protected ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet copy() {
216        return new ByProjectKeyInStoreKeyByStoreKeyMeOrdersByIDGet(this);
217    }
218}