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.List;
009import java.util.concurrent.CompletableFuture;
010
011import io.vrap.rmf.base.client.*;
012import io.vrap.rmf.base.client.utils.Generated;
013
014import org.apache.commons.lang3.builder.EqualsBuilder;
015import org.apache.commons.lang3.builder.HashCodeBuilder;
016
017/**
018 *  <p>Changing the password produces the CustomerPasswordUpdated Message with <code>reset=false</code>.</p>
019 *
020 * <hr>
021 * <div class=code-example>
022 * <pre><code class='java'>{@code
023 *   CompletableFuture<ApiHttpResponse<com.commercetools.api.models.customer.Customer>> result = apiRoot
024 *            .withProjectKey("{projectKey}")
025 *            .customers()
026 *            .password()
027 *            .post("")
028 *            .execute()
029 * }</code></pre>
030 * </div>
031 */
032@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
033public class ByProjectKeyCustomersPasswordPostString extends
034        StringBodyApiMethod<ByProjectKeyCustomersPasswordPostString, com.commercetools.api.models.customer.Customer>
035        implements com.commercetools.api.client.ErrorableTrait<ByProjectKeyCustomersPasswordPostString> {
036
037    private String projectKey;
038
039    private String customerChangePassword;
040
041    public ByProjectKeyCustomersPasswordPostString(final ApiHttpClient apiHttpClient, String projectKey,
042            String customerChangePassword) {
043        super(apiHttpClient);
044        this.projectKey = projectKey;
045        this.customerChangePassword = customerChangePassword;
046    }
047
048    public ByProjectKeyCustomersPasswordPostString(ByProjectKeyCustomersPasswordPostString t) {
049        super(t);
050        this.projectKey = t.projectKey;
051        this.customerChangePassword = t.customerChangePassword;
052    }
053
054    @Override
055    protected ApiHttpRequest buildHttpRequest() {
056        List<String> params = new ArrayList<>(getQueryParamUriStrings());
057        String httpRequestPath = String.format("%s/customers/password", this.projectKey);
058        if (!params.isEmpty()) {
059            httpRequestPath += "?" + String.join("&", params);
060        }
061        return new ApiHttpRequest(ApiHttpMethod.POST, URI.create(httpRequestPath), getHeaders(),
062            customerChangePassword.getBytes(StandardCharsets.UTF_8));
063
064    }
065
066    @Override
067    public ApiHttpResponse<com.commercetools.api.models.customer.Customer> executeBlocking(final ApiHttpClient client,
068            final Duration timeout) {
069        return executeBlocking(client, timeout, com.commercetools.api.models.customer.Customer.class);
070    }
071
072    @Override
073    public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.customer.Customer>> execute(
074            final ApiHttpClient client) {
075        return execute(client, com.commercetools.api.models.customer.Customer.class);
076    }
077
078    public String getProjectKey() {
079        return this.projectKey;
080    }
081
082    public void setProjectKey(final String projectKey) {
083        this.projectKey = projectKey;
084    }
085
086    public String getBody() {
087        return customerChangePassword;
088    }
089
090    public ByProjectKeyCustomersPasswordPostString withBody(String customerChangePassword) {
091        ByProjectKeyCustomersPasswordPostString t = copy();
092        t.customerChangePassword = customerChangePassword;
093        return t;
094    }
095
096    @Override
097    public boolean equals(Object o) {
098        if (this == o)
099            return true;
100
101        if (o == null || getClass() != o.getClass())
102            return false;
103
104        ByProjectKeyCustomersPasswordPostString that = (ByProjectKeyCustomersPasswordPostString) o;
105
106        return new EqualsBuilder().append(projectKey, that.projectKey)
107                .append(customerChangePassword, that.customerChangePassword)
108                .isEquals();
109    }
110
111    @Override
112    public int hashCode() {
113        return new HashCodeBuilder(17, 37).append(projectKey).append(customerChangePassword).toHashCode();
114    }
115
116    @Override
117    protected ByProjectKeyCustomersPasswordPostString copy() {
118        return new ByProjectKeyCustomersPasswordPostString(this);
119    }
120}