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>This is the last step in the email verification process of a Customer.</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 *            .inStoreKeyWithStoreKeyValue("{storeKey}")
026 *            .me()
027 *            .emailConfirm()
028 *            .post("")
029 *            .execute()
030 * }</code></pre>
031 * </div>
032 */
033@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
034public class ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPostString extends
035        StringBodyApiMethod<ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPostString, com.commercetools.api.models.customer.Customer>
036        implements
037        com.commercetools.api.client.ErrorableTrait<ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPostString> {
038
039    private String projectKey;
040    private String storeKey;
041
042    private String myCustomerEmailVerify;
043
044    public ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPostString(final ApiHttpClient apiHttpClient,
045            String projectKey, String storeKey, String myCustomerEmailVerify) {
046        super(apiHttpClient);
047        this.projectKey = projectKey;
048        this.storeKey = storeKey;
049        this.myCustomerEmailVerify = myCustomerEmailVerify;
050    }
051
052    public ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPostString(
053            ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPostString t) {
054        super(t);
055        this.projectKey = t.projectKey;
056        this.storeKey = t.storeKey;
057        this.myCustomerEmailVerify = t.myCustomerEmailVerify;
058    }
059
060    @Override
061    protected ApiHttpRequest buildHttpRequest() {
062        List<String> params = new ArrayList<>(getQueryParamUriStrings());
063        String httpRequestPath = String.format("%s/in-store/key=%s/me/email/confirm", this.projectKey, this.storeKey);
064        if (!params.isEmpty()) {
065            httpRequestPath += "?" + String.join("&", params);
066        }
067        return new ApiHttpRequest(ApiHttpMethod.POST, URI.create(httpRequestPath), getHeaders(),
068            myCustomerEmailVerify.getBytes(StandardCharsets.UTF_8));
069
070    }
071
072    @Override
073    public ApiHttpResponse<com.commercetools.api.models.customer.Customer> executeBlocking(final ApiHttpClient client,
074            final Duration timeout) {
075        return executeBlocking(client, timeout, com.commercetools.api.models.customer.Customer.class);
076    }
077
078    @Override
079    public CompletableFuture<ApiHttpResponse<com.commercetools.api.models.customer.Customer>> execute(
080            final ApiHttpClient client) {
081        return execute(client, com.commercetools.api.models.customer.Customer.class);
082    }
083
084    public String getProjectKey() {
085        return this.projectKey;
086    }
087
088    public String getStoreKey() {
089        return this.storeKey;
090    }
091
092    public void setProjectKey(final String projectKey) {
093        this.projectKey = projectKey;
094    }
095
096    public void setStoreKey(final String storeKey) {
097        this.storeKey = storeKey;
098    }
099
100    public String getBody() {
101        return myCustomerEmailVerify;
102    }
103
104    public ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPostString withBody(String myCustomerEmailVerify) {
105        ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPostString t = copy();
106        t.myCustomerEmailVerify = myCustomerEmailVerify;
107        return t;
108    }
109
110    @Override
111    public boolean equals(Object o) {
112        if (this == o)
113            return true;
114
115        if (o == null || getClass() != o.getClass())
116            return false;
117
118        ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPostString that = (ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPostString) o;
119
120        return new EqualsBuilder().append(projectKey, that.projectKey)
121                .append(storeKey, that.storeKey)
122                .append(myCustomerEmailVerify, that.myCustomerEmailVerify)
123                .isEquals();
124    }
125
126    @Override
127    public int hashCode() {
128        return new HashCodeBuilder(17, 37).append(projectKey)
129                .append(storeKey)
130                .append(myCustomerEmailVerify)
131                .toHashCode();
132    }
133
134    @Override
135    protected ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPostString copy() {
136        return new ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPostString(this);
137    }
138}