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 *
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 *            .orders()
030 *            .withOrderNumber("{orderNumber}")
031 *            .delete()
032 *            .withVersion(version)
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 ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete extends
039        ApiMethod<ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete, com.commercetools.api.models.order.Order>
040        implements
041        com.commercetools.api.client.DataerasureTrait<ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete>,
042        com.commercetools.api.client.VersionedTrait<ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete>,
043        com.commercetools.api.client.ConflictingTrait<ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete>,
044        com.commercetools.api.client.ExpandableTrait<ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete>,
045        com.commercetools.api.client.ErrorableTrait<ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete>,
046        com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete> {
047
048    private String projectKey;
049    private String storeKey;
050    private String orderNumber;
051
052    public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete(final ApiHttpClient apiHttpClient,
053            String projectKey, String storeKey, String orderNumber) {
054        super(apiHttpClient);
055        this.projectKey = projectKey;
056        this.storeKey = storeKey;
057        this.orderNumber = orderNumber;
058    }
059
060    public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete(
061            ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete t) {
062        super(t);
063        this.projectKey = t.projectKey;
064        this.storeKey = t.storeKey;
065        this.orderNumber = t.orderNumber;
066    }
067
068    @Override
069    protected ApiHttpRequest buildHttpRequest() {
070        List<String> params = new ArrayList<>(getQueryParamUriStrings());
071        String httpRequestPath = String.format("%s/in-store/key=%s/orders/order-number=%s", this.projectKey,
072            this.storeKey, this.orderNumber);
073        if (!params.isEmpty()) {
074            httpRequestPath += "?" + String.join("&", params);
075        }
076        return new ApiHttpRequest(ApiHttpMethod.DELETE, URI.create(httpRequestPath), getHeaders(), null);
077    }
078
079    @Override
080    public ApiHttpResponse<com.commercetools.api.models.order.Order> executeBlocking(final ApiHttpClient client,
081            final Duration timeout) {
082        return executeBlocking(client, timeout, com.commercetools.api.models.order.Order.class);
083    }
084
085    @Override
086    public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.order.Order>> execute(
087            final ApiHttpClient client) {
088        return execute(client, com.commercetools.api.models.order.Order.class);
089    }
090
091    public String getProjectKey() {
092        return this.projectKey;
093    }
094
095    public String getStoreKey() {
096        return this.storeKey;
097    }
098
099    public String getOrderNumber() {
100        return this.orderNumber;
101    }
102
103    public List<String> getDataErasure() {
104        return this.getQueryParam("dataErasure");
105    }
106
107    public List<String> getVersion() {
108        return this.getQueryParam("version");
109    }
110
111    public List<String> getExpand() {
112        return this.getQueryParam("expand");
113    }
114
115    public void setProjectKey(final String projectKey) {
116        this.projectKey = projectKey;
117    }
118
119    public void setStoreKey(final String storeKey) {
120        this.storeKey = storeKey;
121    }
122
123    public void setOrderNumber(final String orderNumber) {
124        this.orderNumber = orderNumber;
125    }
126
127    /**
128     * set dataErasure with the specified value
129     * @param dataErasure value to be set
130     * @param <TValue> value type
131     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
132     */
133    public <TValue> ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete withDataErasure(
134            final TValue dataErasure) {
135        return copy().withQueryParam("dataErasure", dataErasure);
136    }
137
138    /**
139     * add additional dataErasure query parameter
140     * @param dataErasure value to be added
141     * @param <TValue> value type
142     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
143     */
144    public <TValue> ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete addDataErasure(
145            final TValue dataErasure) {
146        return copy().addQueryParam("dataErasure", dataErasure);
147    }
148
149    /**
150     * set dataErasure with the specified value
151     * @param supplier supplier for the value to be set
152     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
153     */
154    public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete withDataErasure(
155            final Supplier<Boolean> supplier) {
156        return copy().withQueryParam("dataErasure", supplier.get());
157    }
158
159    /**
160     * add additional dataErasure query parameter
161     * @param supplier supplier for the value to be added
162     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
163     */
164    public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete addDataErasure(
165            final Supplier<Boolean> supplier) {
166        return copy().addQueryParam("dataErasure", supplier.get());
167    }
168
169    /**
170     * set dataErasure with the specified value
171     * @param op builder for the value to be set
172     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
173     */
174    public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete withDataErasure(
175            final Function<StringBuilder, StringBuilder> op) {
176        return copy().withQueryParam("dataErasure", op.apply(new StringBuilder()));
177    }
178
179    /**
180     * add additional dataErasure query parameter
181     * @param op builder for the value to be added
182     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
183     */
184    public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete addDataErasure(
185            final Function<StringBuilder, StringBuilder> op) {
186        return copy().addQueryParam("dataErasure", op.apply(new StringBuilder()));
187    }
188
189    /**
190     * set dataErasure with the specified values
191     * @param dataErasure values to be set
192     * @param <TValue> value type
193     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
194     */
195    public <TValue> ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete withDataErasure(
196            final Collection<TValue> dataErasure) {
197        return copy().withoutQueryParam("dataErasure")
198                .addQueryParams(dataErasure.stream()
199                        .map(s -> new ParamEntry<>("dataErasure", s.toString()))
200                        .collect(Collectors.toList()));
201    }
202
203    /**
204     * add additional dataErasure query parameters
205     * @param dataErasure values to be added
206     * @param <TValue> value type
207     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
208     */
209    public <TValue> ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete addDataErasure(
210            final Collection<TValue> dataErasure) {
211        return copy().addQueryParams(
212            dataErasure.stream().map(s -> new ParamEntry<>("dataErasure", s.toString())).collect(Collectors.toList()));
213    }
214
215    /**
216     * set version with the specified value
217     * @param version value to be set
218     * @param <TValue> value type
219     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
220     */
221    public <TValue> ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete withVersion(
222            final TValue version) {
223        return copy().withQueryParam("version", version);
224    }
225
226    /**
227     * add additional version query parameter
228     * @param version value to be added
229     * @param <TValue> value type
230     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
231     */
232    public <TValue> ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete addVersion(
233            final TValue version) {
234        return copy().addQueryParam("version", version);
235    }
236
237    /**
238     * set version with the specified value
239     * @param supplier supplier for the value to be set
240     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
241     */
242    public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete withVersion(
243            final Supplier<Long> supplier) {
244        return copy().withQueryParam("version", supplier.get());
245    }
246
247    /**
248     * add additional version query parameter
249     * @param supplier supplier for the value to be added
250     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
251     */
252    public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete addVersion(
253            final Supplier<Long> supplier) {
254        return copy().addQueryParam("version", supplier.get());
255    }
256
257    /**
258     * set version with the specified value
259     * @param op builder for the value to be set
260     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
261     */
262    public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete withVersion(
263            final Function<StringBuilder, StringBuilder> op) {
264        return copy().withQueryParam("version", op.apply(new StringBuilder()));
265    }
266
267    /**
268     * add additional version query parameter
269     * @param op builder for the value to be added
270     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
271     */
272    public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete addVersion(
273            final Function<StringBuilder, StringBuilder> op) {
274        return copy().addQueryParam("version", op.apply(new StringBuilder()));
275    }
276
277    /**
278     * set version with the specified values
279     * @param version values to be set
280     * @param <TValue> value type
281     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
282     */
283    public <TValue> ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete withVersion(
284            final Collection<TValue> version) {
285        return copy().withoutQueryParam("version")
286                .addQueryParams(
287                    version.stream().map(s -> new ParamEntry<>("version", s.toString())).collect(Collectors.toList()));
288    }
289
290    /**
291     * add additional version query parameters
292     * @param version values to be added
293     * @param <TValue> value type
294     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
295     */
296    public <TValue> ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete addVersion(
297            final Collection<TValue> version) {
298        return copy().addQueryParams(
299            version.stream().map(s -> new ParamEntry<>("version", s.toString())).collect(Collectors.toList()));
300    }
301
302    /**
303     * set expand with the specified value
304     * @param expand value to be set
305     * @param <TValue> value type
306     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
307     */
308    public <TValue> ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete withExpand(
309            final TValue expand) {
310        return copy().withQueryParam("expand", expand);
311    }
312
313    /**
314     * add additional expand query parameter
315     * @param expand value to be added
316     * @param <TValue> value type
317     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
318     */
319    public <TValue> ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete addExpand(
320            final TValue expand) {
321        return copy().addQueryParam("expand", expand);
322    }
323
324    /**
325     * set expand with the specified value
326     * @param supplier supplier for the value to be set
327     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
328     */
329    public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete withExpand(
330            final Supplier<String> supplier) {
331        return copy().withQueryParam("expand", supplier.get());
332    }
333
334    /**
335     * add additional expand query parameter
336     * @param supplier supplier for the value to be added
337     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
338     */
339    public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete addExpand(
340            final Supplier<String> supplier) {
341        return copy().addQueryParam("expand", supplier.get());
342    }
343
344    /**
345     * set expand with the specified value
346     * @param op builder for the value to be set
347     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
348     */
349    public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete withExpand(
350            final Function<StringBuilder, StringBuilder> op) {
351        return copy().withQueryParam("expand", op.apply(new StringBuilder()));
352    }
353
354    /**
355     * add additional expand query parameter
356     * @param op builder for the value to be added
357     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
358     */
359    public ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete addExpand(
360            final Function<StringBuilder, StringBuilder> op) {
361        return copy().addQueryParam("expand", op.apply(new StringBuilder()));
362    }
363
364    /**
365     * set expand with the specified values
366     * @param expand values to be set
367     * @param <TValue> value type
368     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
369     */
370    public <TValue> ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete withExpand(
371            final Collection<TValue> expand) {
372        return copy().withoutQueryParam("expand")
373                .addQueryParams(
374                    expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList()));
375    }
376
377    /**
378     * add additional expand query parameters
379     * @param expand values to be added
380     * @param <TValue> value type
381     * @return ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete
382     */
383    public <TValue> ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete addExpand(
384            final Collection<TValue> expand) {
385        return copy().addQueryParams(
386            expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList()));
387    }
388
389    @Override
390    public boolean equals(Object o) {
391        if (this == o)
392            return true;
393
394        if (o == null || getClass() != o.getClass())
395            return false;
396
397        ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete that = (ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete) o;
398
399        return new EqualsBuilder().append(projectKey, that.projectKey)
400                .append(storeKey, that.storeKey)
401                .append(orderNumber, that.orderNumber)
402                .isEquals();
403    }
404
405    @Override
406    public int hashCode() {
407        return new HashCodeBuilder(17, 37).append(projectKey).append(storeKey).append(orderNumber).toHashCode();
408    }
409
410    @Override
411    protected ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete copy() {
412        return new ByProjectKeyInStoreKeyByStoreKeyOrdersOrderNumberByOrderNumberDelete(this);
413    }
414}