001
002package com.commercetools.api.client;
003
004import java.net.URI;
005import java.time.Duration;
006import java.util.ArrayList;
007import java.util.List;
008import java.util.concurrent.CompletableFuture;
009
010import io.vrap.rmf.base.client.*;
011import io.vrap.rmf.base.client.utils.Generated;
012
013import org.apache.commons.lang3.builder.EqualsBuilder;
014import org.apache.commons.lang3.builder.HashCodeBuilder;
015
016/**
017 *  <p>The customer verifies the email using the token value. Verifying the email of the Customer produces the CustomerEmailVerified Message.</p>
018 *  <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>
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 *            .customers()
027 *            .emailConfirm()
028 *            .post(null)
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 ByProjectKeyInStoreKeyByStoreKeyCustomersEmailConfirmPost extends
035        BodyApiMethod<ByProjectKeyInStoreKeyByStoreKeyCustomersEmailConfirmPost, com.commercetools.api.models.customer.Customer, com.commercetools.api.models.customer.CustomerEmailVerify>
036        implements
037        com.commercetools.api.client.ErrorableTrait<ByProjectKeyInStoreKeyByStoreKeyCustomersEmailConfirmPost> {
038
039    private String projectKey;
040    private String storeKey;
041
042    private com.commercetools.api.models.customer.CustomerEmailVerify customerEmailVerify;
043
044    public ByProjectKeyInStoreKeyByStoreKeyCustomersEmailConfirmPost(final ApiHttpClient apiHttpClient,
045            String projectKey, String storeKey,
046            com.commercetools.api.models.customer.CustomerEmailVerify customerEmailVerify) {
047        super(apiHttpClient);
048        this.projectKey = projectKey;
049        this.storeKey = storeKey;
050        this.customerEmailVerify = customerEmailVerify;
051    }
052
053    public ByProjectKeyInStoreKeyByStoreKeyCustomersEmailConfirmPost(
054            ByProjectKeyInStoreKeyByStoreKeyCustomersEmailConfirmPost t) {
055        super(t);
056        this.projectKey = t.projectKey;
057        this.storeKey = t.storeKey;
058        this.customerEmailVerify = t.customerEmailVerify;
059    }
060
061    @Override
062    protected ApiHttpRequest buildHttpRequest() {
063        List<String> params = new ArrayList<>(getQueryParamUriStrings());
064        String httpRequestPath = String.format("%s/in-store/key=%s/customers/email/confirm", this.projectKey,
065            this.storeKey);
066        if (!params.isEmpty()) {
067            httpRequestPath += "?" + String.join("&", params);
068        }
069        return new ApiHttpRequest(ApiHttpMethod.POST, URI.create(httpRequestPath), getHeaders(),
070            io.vrap.rmf.base.client.utils.json.JsonUtils
071                    .executing(() -> apiHttpClient().getSerializerService().toJsonByteArray(customerEmailVerify)));
072
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 void setProjectKey(final String projectKey) {
096        this.projectKey = projectKey;
097    }
098
099    public void setStoreKey(final String storeKey) {
100        this.storeKey = storeKey;
101    }
102
103    public com.commercetools.api.models.customer.CustomerEmailVerify getBody() {
104        return customerEmailVerify;
105    }
106
107    public ByProjectKeyInStoreKeyByStoreKeyCustomersEmailConfirmPost withBody(
108            com.commercetools.api.models.customer.CustomerEmailVerify customerEmailVerify) {
109        ByProjectKeyInStoreKeyByStoreKeyCustomersEmailConfirmPost t = copy();
110        t.customerEmailVerify = customerEmailVerify;
111        return t;
112    }
113
114    @Override
115    public boolean equals(Object o) {
116        if (this == o)
117            return true;
118
119        if (o == null || getClass() != o.getClass())
120            return false;
121
122        ByProjectKeyInStoreKeyByStoreKeyCustomersEmailConfirmPost that = (ByProjectKeyInStoreKeyByStoreKeyCustomersEmailConfirmPost) o;
123
124        return new EqualsBuilder().append(projectKey, that.projectKey)
125                .append(storeKey, that.storeKey)
126                .append(customerEmailVerify, that.customerEmailVerify)
127                .isEquals();
128    }
129
130    @Override
131    public int hashCode() {
132        return new HashCodeBuilder(17, 37).append(projectKey).append(storeKey).append(customerEmailVerify).toHashCode();
133    }
134
135    @Override
136    protected ByProjectKeyInStoreKeyByStoreKeyCustomersEmailConfirmPost copy() {
137        return new ByProjectKeyInStoreKeyByStoreKeyCustomersEmailConfirmPost(this);
138    }
139}