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>Check if a Product exists with a specified <code>key</code>. Responds with a <code>200 OK</code> status if the Product exists or <code>404 Not Found</code> otherwise.</p>
018 *
019 * <hr>
020 * <div class=code-example>
021 * <pre><code class='java'>{@code
022 *   CompletableFuture<ApiHttpResponse<com.fasterxml.jackson.databind.JsonNode>> result = apiRoot
023 *            .withProjectKey("{projectKey}")
024 *            .products()
025 *            .withKey("{key}")
026 *            .head()
027 *            .execute()
028 * }</code></pre>
029 * </div>
030 */
031@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
032public class ByProjectKeyProductsKeyByKeyHead
033        extends ApiMethod<ByProjectKeyProductsKeyByKeyHead, com.fasterxml.jackson.databind.JsonNode>
034        implements com.commercetools.api.client.ErrorableTrait<ByProjectKeyProductsKeyByKeyHead>,
035        com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyProductsKeyByKeyHead> {
036
037    private String projectKey;
038    private String key;
039
040    public ByProjectKeyProductsKeyByKeyHead(final ApiHttpClient apiHttpClient, String projectKey, String key) {
041        super(apiHttpClient);
042        this.projectKey = projectKey;
043        this.key = key;
044    }
045
046    public ByProjectKeyProductsKeyByKeyHead(ByProjectKeyProductsKeyByKeyHead t) {
047        super(t);
048        this.projectKey = t.projectKey;
049        this.key = t.key;
050    }
051
052    @Override
053    protected ApiHttpRequest buildHttpRequest() {
054        List<String> params = new ArrayList<>(getQueryParamUriStrings());
055        String httpRequestPath = String.format("%s/products/key=%s", this.projectKey, this.key);
056        if (!params.isEmpty()) {
057            httpRequestPath += "?" + String.join("&", params);
058        }
059        return new ApiHttpRequest(ApiHttpMethod.HEAD, URI.create(httpRequestPath), getHeaders(), null);
060    }
061
062    @Override
063    public ApiHttpResponse<com.fasterxml.jackson.databind.JsonNode> executeBlocking(final ApiHttpClient client,
064            final Duration timeout) {
065        return executeBlocking(client, timeout, com.fasterxml.jackson.databind.JsonNode.class);
066    }
067
068    @Override
069    public CompletableFuture<ApiHttpResponse<com.fasterxml.jackson.databind.JsonNode>> execute(
070            final ApiHttpClient client) {
071        return execute(client, com.fasterxml.jackson.databind.JsonNode.class);
072    }
073
074    public String getProjectKey() {
075        return this.projectKey;
076    }
077
078    public String getKey() {
079        return this.key;
080    }
081
082    public void setProjectKey(final String projectKey) {
083        this.projectKey = projectKey;
084    }
085
086    public void setKey(final String key) {
087        this.key = key;
088    }
089
090    @Override
091    public boolean equals(Object o) {
092        if (this == o)
093            return true;
094
095        if (o == null || getClass() != o.getClass())
096            return false;
097
098        ByProjectKeyProductsKeyByKeyHead that = (ByProjectKeyProductsKeyByKeyHead) o;
099
100        return new EqualsBuilder().append(projectKey, that.projectKey).append(key, that.key).isEquals();
101    }
102
103    @Override
104    public int hashCode() {
105        return new HashCodeBuilder(17, 37).append(projectKey).append(key).toHashCode();
106    }
107
108    @Override
109    protected ByProjectKeyProductsKeyByKeyHead copy() {
110        return new ByProjectKeyProductsKeyByKeyHead(this);
111    }
112}