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