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.zone.Zone>> result = apiRoot
027 *            .withProjectKey("{projectKey}")
028 *            .zones()
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 ByProjectKeyZonesByIDDelete
038        extends ApiMethod<ByProjectKeyZonesByIDDelete, com.commercetools.api.models.zone.Zone> implements
039        com.commercetools.api.client.ApiDeleteMethod<ByProjectKeyZonesByIDDelete, com.commercetools.api.models.zone.Zone>,
040        com.commercetools.api.client.VersionedTrait<ByProjectKeyZonesByIDDelete>,
041        com.commercetools.api.client.ConflictingTrait<ByProjectKeyZonesByIDDelete>,
042        com.commercetools.api.client.ExpandableTrait<ByProjectKeyZonesByIDDelete>,
043        com.commercetools.api.client.ErrorableTrait<ByProjectKeyZonesByIDDelete>,
044        com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyZonesByIDDelete> {
045
046    private String projectKey;
047    private String ID;
048
049    public ByProjectKeyZonesByIDDelete(final ApiHttpClient apiHttpClient, String projectKey, String ID) {
050        super(apiHttpClient);
051        this.projectKey = projectKey;
052        this.ID = ID;
053    }
054
055    public ByProjectKeyZonesByIDDelete(ByProjectKeyZonesByIDDelete 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/zones/%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.zone.Zone> executeBlocking(final ApiHttpClient client,
073            final Duration timeout) {
074        return executeBlocking(client, timeout, com.commercetools.api.models.zone.Zone.class);
075    }
076
077    @Override
078    public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.zone.Zone>> execute(
079            final ApiHttpClient client) {
080        return execute(client, com.commercetools.api.models.zone.Zone.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 ByProjectKeyZonesByIDDelete
112     */
113    public <TValue> ByProjectKeyZonesByIDDelete 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 ByProjectKeyZonesByIDDelete
122     */
123    public <TValue> ByProjectKeyZonesByIDDelete 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 ByProjectKeyZonesByIDDelete
131     */
132    public ByProjectKeyZonesByIDDelete 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 ByProjectKeyZonesByIDDelete
140     */
141    public ByProjectKeyZonesByIDDelete 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 ByProjectKeyZonesByIDDelete
149     */
150    public ByProjectKeyZonesByIDDelete 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 ByProjectKeyZonesByIDDelete
158     */
159    public ByProjectKeyZonesByIDDelete 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 ByProjectKeyZonesByIDDelete
168     */
169    public <TValue> ByProjectKeyZonesByIDDelete 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 ByProjectKeyZonesByIDDelete
180     */
181    public <TValue> ByProjectKeyZonesByIDDelete 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 ByProjectKeyZonesByIDDelete
191     */
192    public <TValue> ByProjectKeyZonesByIDDelete 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 ByProjectKeyZonesByIDDelete
201     */
202    public <TValue> ByProjectKeyZonesByIDDelete 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 ByProjectKeyZonesByIDDelete
210     */
211    public ByProjectKeyZonesByIDDelete 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 ByProjectKeyZonesByIDDelete
219     */
220    public ByProjectKeyZonesByIDDelete 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 ByProjectKeyZonesByIDDelete
228     */
229    public ByProjectKeyZonesByIDDelete 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 ByProjectKeyZonesByIDDelete
237     */
238    public ByProjectKeyZonesByIDDelete 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 ByProjectKeyZonesByIDDelete
247     */
248    public <TValue> ByProjectKeyZonesByIDDelete 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 ByProjectKeyZonesByIDDelete
259     */
260    public <TValue> ByProjectKeyZonesByIDDelete 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        ByProjectKeyZonesByIDDelete that = (ByProjectKeyZonesByIDDelete) 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 ByProjectKeyZonesByIDDelete copy() {
285        return new ByProjectKeyZonesByIDDelete(this);
286    }
287}