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 *
019 *
020 * <hr>
021 * <div class=code-example>
022 * <pre><code class='java'>{@code
023 *   CompletableFuture<ApiHttpResponse<com.commercetools.api.models.customer.CustomerToken>> result = apiRoot
024 *            .withProjectKey("{projectKey}")
025 *            .customers()
026 *            .emailToken()
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 ByProjectKeyCustomersEmailTokenPostString extends
034        StringBodyApiMethod<ByProjectKeyCustomersEmailTokenPostString, com.commercetools.api.models.customer.CustomerToken>
035        implements com.commercetools.api.client.ErrorableTrait<ByProjectKeyCustomersEmailTokenPostString> {
036
037    private String projectKey;
038
039    private String customerCreateEmailToken;
040
041    public ByProjectKeyCustomersEmailTokenPostString(final ApiHttpClient apiHttpClient, String projectKey,
042            String customerCreateEmailToken) {
043        super(apiHttpClient);
044        this.projectKey = projectKey;
045        this.customerCreateEmailToken = customerCreateEmailToken;
046    }
047
048    public ByProjectKeyCustomersEmailTokenPostString(ByProjectKeyCustomersEmailTokenPostString t) {
049        super(t);
050        this.projectKey = t.projectKey;
051        this.customerCreateEmailToken = t.customerCreateEmailToken;
052    }
053
054    @Override
055    protected ApiHttpRequest buildHttpRequest() {
056        List<String> params = new ArrayList<>(getQueryParamUriStrings());
057        String httpRequestPath = String.format("%s/customers/email-token", this.projectKey);
058        if (!params.isEmpty()) {
059            httpRequestPath += "?" + String.join("&", params);
060        }
061        return new ApiHttpRequest(ApiHttpMethod.POST, URI.create(httpRequestPath), getHeaders(),
062            customerCreateEmailToken.getBytes(StandardCharsets.UTF_8));
063
064    }
065
066    @Override
067    public ApiHttpResponse<com.commercetools.api.models.customer.CustomerToken> executeBlocking(
068            final ApiHttpClient client, final Duration timeout) {
069        return executeBlocking(client, timeout, com.commercetools.api.models.customer.CustomerToken.class);
070    }
071
072    @Override
073    public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.customer.CustomerToken>> execute(
074            final ApiHttpClient client) {
075        return execute(client, com.commercetools.api.models.customer.CustomerToken.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 customerCreateEmailToken;
088    }
089
090    public ByProjectKeyCustomersEmailTokenPostString withBody(String customerCreateEmailToken) {
091        ByProjectKeyCustomersEmailTokenPostString t = copy();
092        t.customerCreateEmailToken = customerCreateEmailToken;
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        ByProjectKeyCustomersEmailTokenPostString that = (ByProjectKeyCustomersEmailTokenPostString) o;
105
106        return new EqualsBuilder().append(projectKey, that.projectKey)
107                .append(customerCreateEmailToken, that.customerCreateEmailToken)
108                .isEquals();
109    }
110
111    @Override
112    public int hashCode() {
113        return new HashCodeBuilder(17, 37).append(projectKey).append(customerCreateEmailToken).toHashCode();
114    }
115
116    @Override
117    protected ByProjectKeyCustomersEmailTokenPostString copy() {
118        return new ByProjectKeyCustomersEmailTokenPostString(this);
119    }
120}