|
| 1 | + |
| 2 | +package com.commercetools.api.client; |
| 3 | + |
| 4 | +import java.net.URI; |
| 5 | +import java.time.Duration; |
| 6 | +import java.util.ArrayList; |
| 7 | +import java.util.Collection; |
| 8 | +import java.util.List; |
| 9 | +import java.util.concurrent.CompletableFuture; |
| 10 | +import java.util.function.Function; |
| 11 | +import java.util.function.Supplier; |
| 12 | +import java.util.stream.Collectors; |
| 13 | + |
| 14 | +import com.fasterxml.jackson.core.type.TypeReference; |
| 15 | + |
| 16 | +import io.vrap.rmf.base.client.*; |
| 17 | +import io.vrap.rmf.base.client.utils.Generated; |
| 18 | + |
| 19 | +import org.apache.commons.lang3.builder.EqualsBuilder; |
| 20 | +import org.apache.commons.lang3.builder.HashCodeBuilder; |
| 21 | + |
| 22 | +/** |
| 23 | + * <p>Checks if a ProductTailoring exists for a given Query Predicate. Returns a <code>200 OK</code> status if any ProductTailoring match the Query Predicate or a <code>404 Not Found</code> otherwise.</p> |
| 24 | + * |
| 25 | + * <hr> |
| 26 | + * <div class=code-example> |
| 27 | + * <pre><code class='java'>{@code |
| 28 | + * CompletableFuture<ApiHttpResponse<com.fasterxml.jackson.databind.JsonNode>> result = apiRoot |
| 29 | + * .withProjectKey("{projectKey}") |
| 30 | + * .productTailoring() |
| 31 | + * .head() |
| 32 | + * .execute() |
| 33 | + * }</code></pre> |
| 34 | + * </div> |
| 35 | + */ |
| 36 | +@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") |
| 37 | +public class ByProjectKeyProductTailoringHead |
| 38 | + extends TypeApiMethod<ByProjectKeyProductTailoringHead, com.fasterxml.jackson.databind.JsonNode> |
| 39 | + implements com.commercetools.api.client.ErrorableTrait<ByProjectKeyProductTailoringHead>, |
| 40 | + com.commercetools.api.client.Deprecatable200Trait<ByProjectKeyProductTailoringHead> { |
| 41 | + |
| 42 | + @Override |
| 43 | + public TypeReference<com.fasterxml.jackson.databind.JsonNode> resultType() { |
| 44 | + return new TypeReference<com.fasterxml.jackson.databind.JsonNode>() { |
| 45 | + }; |
| 46 | + } |
| 47 | + |
| 48 | + private String projectKey; |
| 49 | + |
| 50 | + public ByProjectKeyProductTailoringHead(final ApiHttpClient apiHttpClient, String projectKey) { |
| 51 | + super(apiHttpClient); |
| 52 | + this.projectKey = projectKey; |
| 53 | + } |
| 54 | + |
| 55 | + public ByProjectKeyProductTailoringHead(ByProjectKeyProductTailoringHead t) { |
| 56 | + super(t); |
| 57 | + this.projectKey = t.projectKey; |
| 58 | + } |
| 59 | + |
| 60 | + @Override |
| 61 | + protected ApiHttpRequest buildHttpRequest() { |
| 62 | + List<String> params = new ArrayList<>(getQueryParamUriStrings()); |
| 63 | + String httpRequestPath = String.format("%s/product-tailoring", encodePathParam(this.projectKey)); |
| 64 | + if (!params.isEmpty()) { |
| 65 | + httpRequestPath += "?" + String.join("&", params); |
| 66 | + } |
| 67 | + return new ApiHttpRequest(ApiHttpMethod.HEAD, URI.create(httpRequestPath), getHeaders(), null); |
| 68 | + } |
| 69 | + |
| 70 | + @Override |
| 71 | + public ApiHttpResponse<com.fasterxml.jackson.databind.JsonNode> executeBlocking(final ApiHttpClient client, |
| 72 | + final Duration timeout) { |
| 73 | + return executeBlocking(client, timeout, com.fasterxml.jackson.databind.JsonNode.class); |
| 74 | + } |
| 75 | + |
| 76 | + @Override |
| 77 | + public CompletableFuture<ApiHttpResponse<com.fasterxml.jackson.databind.JsonNode>> execute( |
| 78 | + final ApiHttpClient client) { |
| 79 | + return execute(client, com.fasterxml.jackson.databind.JsonNode.class); |
| 80 | + } |
| 81 | + |
| 82 | + public String getProjectKey() { |
| 83 | + return this.projectKey; |
| 84 | + } |
| 85 | + |
| 86 | + public List<String> getWhere() { |
| 87 | + return this.getQueryParam("where"); |
| 88 | + } |
| 89 | + |
| 90 | + public void setProjectKey(final String projectKey) { |
| 91 | + this.projectKey = projectKey; |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * set where with the specified value |
| 96 | + * @param where value to be set |
| 97 | + * @param <TValue> value type |
| 98 | + * @return ByProjectKeyProductTailoringHead |
| 99 | + */ |
| 100 | + public <TValue> ByProjectKeyProductTailoringHead withWhere(final TValue where) { |
| 101 | + return copy().withQueryParam("where", where); |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * add additional where query parameter |
| 106 | + * @param where value to be added |
| 107 | + * @param <TValue> value type |
| 108 | + * @return ByProjectKeyProductTailoringHead |
| 109 | + */ |
| 110 | + public <TValue> ByProjectKeyProductTailoringHead addWhere(final TValue where) { |
| 111 | + return copy().addQueryParam("where", where); |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * set where with the specified value |
| 116 | + * @param supplier supplier for the value to be set |
| 117 | + * @return ByProjectKeyProductTailoringHead |
| 118 | + */ |
| 119 | + public ByProjectKeyProductTailoringHead withWhere(final Supplier<String> supplier) { |
| 120 | + return copy().withQueryParam("where", supplier.get()); |
| 121 | + } |
| 122 | + |
| 123 | + /** |
| 124 | + * add additional where query parameter |
| 125 | + * @param supplier supplier for the value to be added |
| 126 | + * @return ByProjectKeyProductTailoringHead |
| 127 | + */ |
| 128 | + public ByProjectKeyProductTailoringHead addWhere(final Supplier<String> supplier) { |
| 129 | + return copy().addQueryParam("where", supplier.get()); |
| 130 | + } |
| 131 | + |
| 132 | + /** |
| 133 | + * set where with the specified value |
| 134 | + * @param op builder for the value to be set |
| 135 | + * @return ByProjectKeyProductTailoringHead |
| 136 | + */ |
| 137 | + public ByProjectKeyProductTailoringHead withWhere(final Function<StringBuilder, StringBuilder> op) { |
| 138 | + return copy().withQueryParam("where", op.apply(new StringBuilder())); |
| 139 | + } |
| 140 | + |
| 141 | + /** |
| 142 | + * add additional where query parameter |
| 143 | + * @param op builder for the value to be added |
| 144 | + * @return ByProjectKeyProductTailoringHead |
| 145 | + */ |
| 146 | + public ByProjectKeyProductTailoringHead addWhere(final Function<StringBuilder, StringBuilder> op) { |
| 147 | + return copy().addQueryParam("where", op.apply(new StringBuilder())); |
| 148 | + } |
| 149 | + |
| 150 | + /** |
| 151 | + * set where with the specified values |
| 152 | + * @param where values to be set |
| 153 | + * @param <TValue> value type |
| 154 | + * @return ByProjectKeyProductTailoringHead |
| 155 | + */ |
| 156 | + public <TValue> ByProjectKeyProductTailoringHead withWhere(final Collection<TValue> where) { |
| 157 | + return copy().withoutQueryParam("where") |
| 158 | + .addQueryParams( |
| 159 | + where.stream().map(s -> new ParamEntry<>("where", s.toString())).collect(Collectors.toList())); |
| 160 | + } |
| 161 | + |
| 162 | + /** |
| 163 | + * add additional where query parameters |
| 164 | + * @param where values to be added |
| 165 | + * @param <TValue> value type |
| 166 | + * @return ByProjectKeyProductTailoringHead |
| 167 | + */ |
| 168 | + public <TValue> ByProjectKeyProductTailoringHead addWhere(final Collection<TValue> where) { |
| 169 | + return copy().addQueryParams( |
| 170 | + where.stream().map(s -> new ParamEntry<>("where", s.toString())).collect(Collectors.toList())); |
| 171 | + } |
| 172 | + |
| 173 | + @Override |
| 174 | + public boolean equals(Object o) { |
| 175 | + if (this == o) |
| 176 | + return true; |
| 177 | + |
| 178 | + if (o == null || getClass() != o.getClass()) |
| 179 | + return false; |
| 180 | + |
| 181 | + ByProjectKeyProductTailoringHead that = (ByProjectKeyProductTailoringHead) o; |
| 182 | + |
| 183 | + return new EqualsBuilder().append(projectKey, that.projectKey).isEquals(); |
| 184 | + } |
| 185 | + |
| 186 | + @Override |
| 187 | + public int hashCode() { |
| 188 | + return new HashCodeBuilder(17, 37).append(projectKey).toHashCode(); |
| 189 | + } |
| 190 | + |
| 191 | + @Override |
| 192 | + protected ByProjectKeyProductTailoringHead copy() { |
| 193 | + return new ByProjectKeyProductTailoringHead(this); |
| 194 | + } |
| 195 | +} |
0 commit comments