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 reference the requested BusinessUnit, this method returns an InvalidOperation 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 *            .asAssociate()
029 *            .withAssociateIdValue("{associateId}")
030 *            .inBusinessUnitKeyWithBusinessUnitKeyValue("{businessUnitKey}")
031 *            .orders()
032 *            .withId("{ID}")
033 *            .get()
034 *            .execute()
035 * }</code></pre>
036 * </div>
037 */
038@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
039public class ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet extends
040        ApiMethod<ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet, com.commercetools.api.models.order.Order>
041        implements
042        com.commercetools.api.client.ExpandableTrait<ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet>,
043        com.commercetools.api.client.ErrorableTrait<ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet>,
044        com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet> {
045
046    private String projectKey;
047    private String associateId;
048    private String businessUnitKey;
049    private String ID;
050
051    public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet(
052            final ApiHttpClient apiHttpClient, String projectKey, String associateId, String businessUnitKey,
053            String ID) {
054        super(apiHttpClient);
055        this.projectKey = projectKey;
056        this.associateId = associateId;
057        this.businessUnitKey = businessUnitKey;
058        this.ID = ID;
059    }
060
061    public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet(
062            ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet t) {
063        super(t);
064        this.projectKey = t.projectKey;
065        this.associateId = t.associateId;
066        this.businessUnitKey = t.businessUnitKey;
067        this.ID = t.ID;
068    }
069
070    @Override
071    protected ApiHttpRequest buildHttpRequest() {
072        List<String> params = new ArrayList<>(getQueryParamUriStrings());
073        String httpRequestPath = String.format("%s/as-associate/%s/in-business-unit/key=%s/orders/%s", this.projectKey,
074            this.associateId, this.businessUnitKey, this.ID);
075        if (!params.isEmpty()) {
076            httpRequestPath += "?" + String.join("&", params);
077        }
078        return new ApiHttpRequest(ApiHttpMethod.GET, URI.create(httpRequestPath), getHeaders(), null);
079    }
080
081    @Override
082    public ApiHttpResponse<com.commercetools.api.models.order.Order> executeBlocking(final ApiHttpClient client,
083            final Duration timeout) {
084        return executeBlocking(client, timeout, com.commercetools.api.models.order.Order.class);
085    }
086
087    @Override
088    public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.order.Order>> execute(
089            final ApiHttpClient client) {
090        return execute(client, com.commercetools.api.models.order.Order.class);
091    }
092
093    public String getProjectKey() {
094        return this.projectKey;
095    }
096
097    public String getAssociateId() {
098        return this.associateId;
099    }
100
101    public String getBusinessUnitKey() {
102        return this.businessUnitKey;
103    }
104
105    public String getID() {
106        return this.ID;
107    }
108
109    public List<String> getExpand() {
110        return this.getQueryParam("expand");
111    }
112
113    public void setProjectKey(final String projectKey) {
114        this.projectKey = projectKey;
115    }
116
117    public void setAssociateId(final String associateId) {
118        this.associateId = associateId;
119    }
120
121    public void setBusinessUnitKey(final String businessUnitKey) {
122        this.businessUnitKey = businessUnitKey;
123    }
124
125    public void setID(final String ID) {
126        this.ID = ID;
127    }
128
129    /**
130     * set expand with the specified value
131     * @param expand value to be set
132     * @param <TValue> value type
133     * @return ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet
134     */
135    public <TValue> ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet withExpand(
136            final TValue expand) {
137        return copy().withQueryParam("expand", expand);
138    }
139
140    /**
141     * add additional expand query parameter
142     * @param expand value to be added
143     * @param <TValue> value type
144     * @return ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet
145     */
146    public <TValue> ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet addExpand(
147            final TValue expand) {
148        return copy().addQueryParam("expand", expand);
149    }
150
151    /**
152     * set expand with the specified value
153     * @param supplier supplier for the value to be set
154     * @return ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet
155     */
156    public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet withExpand(
157            final Supplier<String> supplier) {
158        return copy().withQueryParam("expand", supplier.get());
159    }
160
161    /**
162     * add additional expand query parameter
163     * @param supplier supplier for the value to be added
164     * @return ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet
165     */
166    public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet addExpand(
167            final Supplier<String> supplier) {
168        return copy().addQueryParam("expand", supplier.get());
169    }
170
171    /**
172     * set expand with the specified value
173     * @param op builder for the value to be set
174     * @return ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet
175     */
176    public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet withExpand(
177            final Function<StringBuilder, StringBuilder> op) {
178        return copy().withQueryParam("expand", op.apply(new StringBuilder()));
179    }
180
181    /**
182     * add additional expand query parameter
183     * @param op builder for the value to be added
184     * @return ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet
185     */
186    public ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet addExpand(
187            final Function<StringBuilder, StringBuilder> op) {
188        return copy().addQueryParam("expand", op.apply(new StringBuilder()));
189    }
190
191    /**
192     * set expand with the specified values
193     * @param expand values to be set
194     * @param <TValue> value type
195     * @return ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet
196     */
197    public <TValue> ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet withExpand(
198            final Collection<TValue> expand) {
199        return copy().withoutQueryParam("expand")
200                .addQueryParams(
201                    expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList()));
202    }
203
204    /**
205     * add additional expand query parameters
206     * @param expand values to be added
207     * @param <TValue> value type
208     * @return ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet
209     */
210    public <TValue> ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet addExpand(
211            final Collection<TValue> expand) {
212        return copy().addQueryParams(
213            expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList()));
214    }
215
216    @Override
217    public boolean equals(Object o) {
218        if (this == o)
219            return true;
220
221        if (o == null || getClass() != o.getClass())
222            return false;
223
224        ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet that = (ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet) o;
225
226        return new EqualsBuilder().append(projectKey, that.projectKey)
227                .append(associateId, that.associateId)
228                .append(businessUnitKey, that.businessUnitKey)
229                .append(ID, that.ID)
230                .isEquals();
231    }
232
233    @Override
234    public int hashCode() {
235        return new HashCodeBuilder(17, 37).append(projectKey)
236                .append(associateId)
237                .append(businessUnitKey)
238                .append(ID)
239                .toHashCode();
240    }
241
242    @Override
243    protected ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet copy() {
244        return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrdersByIDGet(this);
245    }
246}