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>Either the scope <code>manage_products:{projectKey}</code> or <code>manage_categories:{projectKey}</code> is required.</p>
022 *
023 * <hr>
024 * <div class=code-example>
025 * <pre><code class='java'>{@code
026 *   CompletableFuture<ApiHttpResponse<com.commercetools.api.models.category.Category>> result = apiRoot
027 *            .withProjectKey("{projectKey}")
028 *            .categories()
029 *            .withId("{ID}")
030 *            .delete()
031 *            .withVersion(version)
032 *            .execute()
033 * }</code></pre>
034 * </div>
035 */
036@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
037public class ByProjectKeyCategoriesByIDDelete
038        extends ApiMethod<ByProjectKeyCategoriesByIDDelete, com.commercetools.api.models.category.Category> implements
039        com.commercetools.api.client.ApiDeleteMethod<ByProjectKeyCategoriesByIDDelete, com.commercetools.api.models.category.Category>,
040        com.commercetools.api.client.VersionedTrait<ByProjectKeyCategoriesByIDDelete>,
041        com.commercetools.api.client.ConflictingTrait<ByProjectKeyCategoriesByIDDelete>,
042        com.commercetools.api.client.ExpandableTrait<ByProjectKeyCategoriesByIDDelete>,
043        com.commercetools.api.client.ErrorableTrait<ByProjectKeyCategoriesByIDDelete>,
044        com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyCategoriesByIDDelete> {
045
046    private String projectKey;
047    private String ID;
048
049    public ByProjectKeyCategoriesByIDDelete(final ApiHttpClient apiHttpClient, String projectKey, String ID) {
050        super(apiHttpClient);
051        this.projectKey = projectKey;
052        this.ID = ID;
053    }
054
055    public ByProjectKeyCategoriesByIDDelete(ByProjectKeyCategoriesByIDDelete t) {
056        super(t);
057        this.projectKey = t.projectKey;
058        this.ID = t.ID;
059    }
060
061    @Override
062    protected ApiHttpRequest buildHttpRequest() {
063        List<String> params = new ArrayList<>(getQueryParamUriStrings());
064        String httpRequestPath = String.format("%s/categories/%s", this.projectKey, this.ID);
065        if (!params.isEmpty()) {
066            httpRequestPath += "?" + String.join("&", params);
067        }
068        return new ApiHttpRequest(ApiHttpMethod.DELETE, URI.create(httpRequestPath), getHeaders(), null);
069    }
070
071    @Override
072    public ApiHttpResponse<com.commercetools.api.models.category.Category> executeBlocking(final ApiHttpClient client,
073            final Duration timeout) {
074        return executeBlocking(client, timeout, com.commercetools.api.models.category.Category.class);
075    }
076
077    @Override
078    public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.category.Category>> execute(
079            final ApiHttpClient client) {
080        return execute(client, com.commercetools.api.models.category.Category.class);
081    }
082
083    public String getProjectKey() {
084        return this.projectKey;
085    }
086
087    public String getID() {
088        return this.ID;
089    }
090
091    public List<String> getVersion() {
092        return this.getQueryParam("version");
093    }
094
095    public List<String> getExpand() {
096        return this.getQueryParam("expand");
097    }
098
099    public void setProjectKey(final String projectKey) {
100        this.projectKey = projectKey;
101    }
102
103    public void setID(final String ID) {
104        this.ID = ID;
105    }
106
107    /**
108     * set version with the specified value
109     * @param version value to be set
110     * @param <TValue> value type
111     * @return ByProjectKeyCategoriesByIDDelete
112     */
113    public <TValue> ByProjectKeyCategoriesByIDDelete withVersion(final TValue version) {
114        return copy().withQueryParam("version", version);
115    }
116
117    /**
118     * add additional version query parameter
119     * @param version value to be added
120     * @param <TValue> value type
121     * @return ByProjectKeyCategoriesByIDDelete
122     */
123    public <TValue> ByProjectKeyCategoriesByIDDelete addVersion(final TValue version) {
124        return copy().addQueryParam("version", version);
125    }
126
127    /**
128     * set version with the specified value
129     * @param supplier supplier for the value to be set
130     * @return ByProjectKeyCategoriesByIDDelete
131     */
132    public ByProjectKeyCategoriesByIDDelete withVersion(final Supplier<Long> supplier) {
133        return copy().withQueryParam("version", supplier.get());
134    }
135
136    /**
137     * add additional version query parameter
138     * @param supplier supplier for the value to be added
139     * @return ByProjectKeyCategoriesByIDDelete
140     */
141    public ByProjectKeyCategoriesByIDDelete addVersion(final Supplier<Long> supplier) {
142        return copy().addQueryParam("version", supplier.get());
143    }
144
145    /**
146     * set version with the specified value
147     * @param op builder for the value to be set
148     * @return ByProjectKeyCategoriesByIDDelete
149     */
150    public ByProjectKeyCategoriesByIDDelete withVersion(final Function<StringBuilder, StringBuilder> op) {
151        return copy().withQueryParam("version", op.apply(new StringBuilder()));
152    }
153
154    /**
155     * add additional version query parameter
156     * @param op builder for the value to be added
157     * @return ByProjectKeyCategoriesByIDDelete
158     */
159    public ByProjectKeyCategoriesByIDDelete addVersion(final Function<StringBuilder, StringBuilder> op) {
160        return copy().addQueryParam("version", op.apply(new StringBuilder()));
161    }
162
163    /**
164     * set version with the specified values
165     * @param version values to be set
166     * @param <TValue> value type
167     * @return ByProjectKeyCategoriesByIDDelete
168     */
169    public <TValue> ByProjectKeyCategoriesByIDDelete withVersion(final Collection<TValue> version) {
170        return copy().withoutQueryParam("version")
171                .addQueryParams(
172                    version.stream().map(s -> new ParamEntry<>("version", s.toString())).collect(Collectors.toList()));
173    }
174
175    /**
176     * add additional version query parameters
177     * @param version values to be added
178     * @param <TValue> value type
179     * @return ByProjectKeyCategoriesByIDDelete
180     */
181    public <TValue> ByProjectKeyCategoriesByIDDelete addVersion(final Collection<TValue> version) {
182        return copy().addQueryParams(
183            version.stream().map(s -> new ParamEntry<>("version", s.toString())).collect(Collectors.toList()));
184    }
185
186    /**
187     * set expand with the specified value
188     * @param expand value to be set
189     * @param <TValue> value type
190     * @return ByProjectKeyCategoriesByIDDelete
191     */
192    public <TValue> ByProjectKeyCategoriesByIDDelete withExpand(final TValue expand) {
193        return copy().withQueryParam("expand", expand);
194    }
195
196    /**
197     * add additional expand query parameter
198     * @param expand value to be added
199     * @param <TValue> value type
200     * @return ByProjectKeyCategoriesByIDDelete
201     */
202    public <TValue> ByProjectKeyCategoriesByIDDelete addExpand(final TValue expand) {
203        return copy().addQueryParam("expand", expand);
204    }
205
206    /**
207     * set expand with the specified value
208     * @param supplier supplier for the value to be set
209     * @return ByProjectKeyCategoriesByIDDelete
210     */
211    public ByProjectKeyCategoriesByIDDelete withExpand(final Supplier<String> supplier) {
212        return copy().withQueryParam("expand", supplier.get());
213    }
214
215    /**
216     * add additional expand query parameter
217     * @param supplier supplier for the value to be added
218     * @return ByProjectKeyCategoriesByIDDelete
219     */
220    public ByProjectKeyCategoriesByIDDelete addExpand(final Supplier<String> supplier) {
221        return copy().addQueryParam("expand", supplier.get());
222    }
223
224    /**
225     * set expand with the specified value
226     * @param op builder for the value to be set
227     * @return ByProjectKeyCategoriesByIDDelete
228     */
229    public ByProjectKeyCategoriesByIDDelete withExpand(final Function<StringBuilder, StringBuilder> op) {
230        return copy().withQueryParam("expand", op.apply(new StringBuilder()));
231    }
232
233    /**
234     * add additional expand query parameter
235     * @param op builder for the value to be added
236     * @return ByProjectKeyCategoriesByIDDelete
237     */
238    public ByProjectKeyCategoriesByIDDelete addExpand(final Function<StringBuilder, StringBuilder> op) {
239        return copy().addQueryParam("expand", op.apply(new StringBuilder()));
240    }
241
242    /**
243     * set expand with the specified values
244     * @param expand values to be set
245     * @param <TValue> value type
246     * @return ByProjectKeyCategoriesByIDDelete
247     */
248    public <TValue> ByProjectKeyCategoriesByIDDelete withExpand(final Collection<TValue> expand) {
249        return copy().withoutQueryParam("expand")
250                .addQueryParams(
251                    expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList()));
252    }
253
254    /**
255     * add additional expand query parameters
256     * @param expand values to be added
257     * @param <TValue> value type
258     * @return ByProjectKeyCategoriesByIDDelete
259     */
260    public <TValue> ByProjectKeyCategoriesByIDDelete addExpand(final Collection<TValue> expand) {
261        return copy().addQueryParams(
262            expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList()));
263    }
264
265    @Override
266    public boolean equals(Object o) {
267        if (this == o)
268            return true;
269
270        if (o == null || getClass() != o.getClass())
271            return false;
272
273        ByProjectKeyCategoriesByIDDelete that = (ByProjectKeyCategoriesByIDDelete) o;
274
275        return new EqualsBuilder().append(projectKey, that.projectKey).append(ID, that.ID).isEquals();
276    }
277
278    @Override
279    public int hashCode() {
280        return new HashCodeBuilder(17, 37).append(projectKey).append(ID).toHashCode();
281    }
282
283    @Override
284    protected ByProjectKeyCategoriesByIDDelete copy() {
285        return new ByProjectKeyCategoriesByIDDelete(this);
286    }
287}