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 Customer exists in the Project but the <code>stores</code> field references a different Store, this method returns a ResourceNotFound error.</p>
022 *
023 * <hr>
024 * <div class=code-example>
025 * <pre><code class='java'>{@code
026 *   CompletableFuture<ApiHttpResponse<com.commercetools.api.models.customer.Customer>> result = apiRoot
027 *            .withProjectKey("{projectKey}")
028 *            .inStoreKeyWithStoreKeyValue("{storeKey}")
029 *            .customers()
030 *            .withPasswordToken("{passwordToken}")
031 *            .get()
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 ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet extends
038        ApiMethod<ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet, com.commercetools.api.models.customer.Customer>
039        implements
040        com.commercetools.api.client.ExpandableTrait<ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet>,
041        com.commercetools.api.client.ErrorableTrait<ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet>,
042        com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet> {
043
044    private String projectKey;
045    private String storeKey;
046    private String passwordToken;
047
048    public ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet(final ApiHttpClient apiHttpClient,
049            String projectKey, String storeKey, String passwordToken) {
050        super(apiHttpClient);
051        this.projectKey = projectKey;
052        this.storeKey = storeKey;
053        this.passwordToken = passwordToken;
054    }
055
056    public ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet(
057            ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet t) {
058        super(t);
059        this.projectKey = t.projectKey;
060        this.storeKey = t.storeKey;
061        this.passwordToken = t.passwordToken;
062    }
063
064    @Override
065    protected ApiHttpRequest buildHttpRequest() {
066        List<String> params = new ArrayList<>(getQueryParamUriStrings());
067        String httpRequestPath = String.format("%s/in-store/key=%s/customers/password-token=%s", this.projectKey,
068            this.storeKey, this.passwordToken);
069        if (!params.isEmpty()) {
070            httpRequestPath += "?" + String.join("&", params);
071        }
072        return new ApiHttpRequest(ApiHttpMethod.GET, URI.create(httpRequestPath), getHeaders(), null);
073    }
074
075    @Override
076    public ApiHttpResponse<com.commercetools.api.models.customer.Customer> executeBlocking(final ApiHttpClient client,
077            final Duration timeout) {
078        return executeBlocking(client, timeout, com.commercetools.api.models.customer.Customer.class);
079    }
080
081    @Override
082    public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.customer.Customer>> execute(
083            final ApiHttpClient client) {
084        return execute(client, com.commercetools.api.models.customer.Customer.class);
085    }
086
087    public String getProjectKey() {
088        return this.projectKey;
089    }
090
091    public String getStoreKey() {
092        return this.storeKey;
093    }
094
095    public String getPasswordToken() {
096        return this.passwordToken;
097    }
098
099    public List<String> getExpand() {
100        return this.getQueryParam("expand");
101    }
102
103    public void setProjectKey(final String projectKey) {
104        this.projectKey = projectKey;
105    }
106
107    public void setStoreKey(final String storeKey) {
108        this.storeKey = storeKey;
109    }
110
111    public void setPasswordToken(final String passwordToken) {
112        this.passwordToken = passwordToken;
113    }
114
115    /**
116     * set expand with the specified value
117     * @param expand value to be set
118     * @param <TValue> value type
119     * @return ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet
120     */
121    public <TValue> ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet withExpand(
122            final TValue expand) {
123        return copy().withQueryParam("expand", expand);
124    }
125
126    /**
127     * add additional expand query parameter
128     * @param expand value to be added
129     * @param <TValue> value type
130     * @return ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet
131     */
132    public <TValue> ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet addExpand(
133            final TValue expand) {
134        return copy().addQueryParam("expand", expand);
135    }
136
137    /**
138     * set expand with the specified value
139     * @param supplier supplier for the value to be set
140     * @return ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet
141     */
142    public ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet withExpand(
143            final Supplier<String> supplier) {
144        return copy().withQueryParam("expand", supplier.get());
145    }
146
147    /**
148     * add additional expand query parameter
149     * @param supplier supplier for the value to be added
150     * @return ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet
151     */
152    public ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet addExpand(
153            final Supplier<String> supplier) {
154        return copy().addQueryParam("expand", supplier.get());
155    }
156
157    /**
158     * set expand with the specified value
159     * @param op builder for the value to be set
160     * @return ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet
161     */
162    public ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet withExpand(
163            final Function<StringBuilder, StringBuilder> op) {
164        return copy().withQueryParam("expand", op.apply(new StringBuilder()));
165    }
166
167    /**
168     * add additional expand query parameter
169     * @param op builder for the value to be added
170     * @return ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet
171     */
172    public ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet addExpand(
173            final Function<StringBuilder, StringBuilder> op) {
174        return copy().addQueryParam("expand", op.apply(new StringBuilder()));
175    }
176
177    /**
178     * set expand with the specified values
179     * @param expand values to be set
180     * @param <TValue> value type
181     * @return ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet
182     */
183    public <TValue> ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet withExpand(
184            final Collection<TValue> expand) {
185        return copy().withoutQueryParam("expand")
186                .addQueryParams(
187                    expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList()));
188    }
189
190    /**
191     * add additional expand query parameters
192     * @param expand values to be added
193     * @param <TValue> value type
194     * @return ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet
195     */
196    public <TValue> ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet addExpand(
197            final Collection<TValue> expand) {
198        return copy().addQueryParams(
199            expand.stream().map(s -> new ParamEntry<>("expand", s.toString())).collect(Collectors.toList()));
200    }
201
202    @Override
203    public boolean equals(Object o) {
204        if (this == o)
205            return true;
206
207        if (o == null || getClass() != o.getClass())
208            return false;
209
210        ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet that = (ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet) o;
211
212        return new EqualsBuilder().append(projectKey, that.projectKey)
213                .append(storeKey, that.storeKey)
214                .append(passwordToken, that.passwordToken)
215                .isEquals();
216    }
217
218    @Override
219    public int hashCode() {
220        return new HashCodeBuilder(17, 37).append(projectKey).append(storeKey).append(passwordToken).toHashCode();
221    }
222
223    @Override
224    protected ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet copy() {
225        return new ByProjectKeyInStoreKeyByStoreKeyCustomersPasswordTokenByPasswordTokenGet(this);
226    }
227}