001 002package com.commercetools.ml.client; 003 004import java.net.URI; 005import java.time.Duration; 006import java.util.ArrayList; 007import java.util.Collection; 008import java.util.List; 009import java.util.concurrent.CompletableFuture; 010import java.util.function.Function; 011import java.util.function.Supplier; 012import java.util.stream.Collectors; 013 014import io.vrap.rmf.base.client.*; 015import io.vrap.rmf.base.client.utils.Generated; 016 017import org.apache.commons.lang3.builder.EqualsBuilder; 018import org.apache.commons.lang3.builder.HashCodeBuilder; 019 020/** 021 * <p>Response Representation: PagedQueryResult with a results array of ProjectCategoryrecommendation, sorted by confidence scores in descending order and the meta information of ProjectCategoryrecommendationMeta.</p> 022 * 023 * <hr> 024 * <div class=code-example> 025 * <pre><code class='java'>{@code 026 * CompletableFuture<ApiHttpResponse<com.commercetools.ml.models.category_recommendations.ProjectCategoryRecommendationPagedQueryResponse>> result = apiRoot 027 * .withProjectKey("{projectKey}") 028 * .recommendations() 029 * .projectCategories() 030 * .withProductId("{productId}") 031 * .get() 032 * .execute() 033 * }</code></pre> 034 * </div> 035 */ 036@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 037public class ByProjectKeyRecommendationsProjectCategoriesByProductIdGet extends 038 ApiMethod<ByProjectKeyRecommendationsProjectCategoriesByProductIdGet, com.commercetools.ml.models.category_recommendations.ProjectCategoryRecommendationPagedQueryResponse> { 039 040 private String projectKey; 041 private String productId; 042 043 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet(final ApiHttpClient apiHttpClient, 044 String projectKey, String productId) { 045 super(apiHttpClient); 046 this.projectKey = projectKey; 047 this.productId = productId; 048 } 049 050 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet( 051 ByProjectKeyRecommendationsProjectCategoriesByProductIdGet t) { 052 super(t); 053 this.projectKey = t.projectKey; 054 this.productId = t.productId; 055 } 056 057 @Override 058 protected ApiHttpRequest buildHttpRequest() { 059 List<String> params = new ArrayList<>(getQueryParamUriStrings()); 060 String httpRequestPath = String.format("/%s/recommendations/project-categories/%s", this.projectKey, 061 this.productId); 062 if (!params.isEmpty()) { 063 httpRequestPath += "?" + String.join("&", params); 064 } 065 return new ApiHttpRequest(ApiHttpMethod.GET, URI.create(httpRequestPath), getHeaders(), null); 066 } 067 068 @Override 069 public ApiHttpResponse<com.commercetools.ml.models.category_recommendations.ProjectCategoryRecommendationPagedQueryResponse> executeBlocking( 070 final ApiHttpClient client, final Duration timeout) { 071 return executeBlocking(client, timeout, 072 com.commercetools.ml.models.category_recommendations.ProjectCategoryRecommendationPagedQueryResponse.class); 073 } 074 075 @Override 076 public CompletableFuture<ApiHttpResponse<com.commercetools.ml.models.category_recommendations.ProjectCategoryRecommendationPagedQueryResponse>> execute( 077 final ApiHttpClient client) { 078 return execute(client, 079 com.commercetools.ml.models.category_recommendations.ProjectCategoryRecommendationPagedQueryResponse.class); 080 } 081 082 public String getProjectKey() { 083 return this.projectKey; 084 } 085 086 public String getProductId() { 087 return this.productId; 088 } 089 090 public List<String> getLimit() { 091 return this.getQueryParam("limit"); 092 } 093 094 public List<String> getOffset() { 095 return this.getQueryParam("offset"); 096 } 097 098 public List<String> getStaged() { 099 return this.getQueryParam("staged"); 100 } 101 102 public List<String> getConfidenceMin() { 103 return this.getQueryParam("confidenceMin"); 104 } 105 106 public List<String> getConfidenceMax() { 107 return this.getQueryParam("confidenceMax"); 108 } 109 110 public void setProjectKey(final String projectKey) { 111 this.projectKey = projectKey; 112 } 113 114 public void setProductId(final String productId) { 115 this.productId = productId; 116 } 117 118 /** 119 * set limit with the specified value 120 */ 121 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withLimit(final TValue limit) { 122 return copy().withQueryParam("limit", limit); 123 } 124 125 /** 126 * add additional limit query parameter 127 */ 128 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addLimit(final TValue limit) { 129 return copy().addQueryParam("limit", limit); 130 } 131 132 /** 133 * set limit with the specified value 134 */ 135 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withLimit(final Supplier<Integer> supplier) { 136 return copy().withQueryParam("limit", supplier.get()); 137 } 138 139 /** 140 * add additional limit query parameter 141 */ 142 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addLimit(final Supplier<Integer> supplier) { 143 return copy().addQueryParam("limit", supplier.get()); 144 } 145 146 /** 147 * set limit with the specified value 148 */ 149 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withLimit( 150 final Function<StringBuilder, StringBuilder> op) { 151 return copy().withQueryParam("limit", op.apply(new StringBuilder())); 152 } 153 154 /** 155 * add additional limit query parameter 156 */ 157 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addLimit( 158 final Function<StringBuilder, StringBuilder> op) { 159 return copy().addQueryParam("limit", op.apply(new StringBuilder())); 160 } 161 162 /** 163 * set limit with the specified values 164 */ 165 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withLimit( 166 final Collection<TValue> limit) { 167 return copy().withoutQueryParam("limit") 168 .addQueryParams( 169 limit.stream().map(s -> new ParamEntry<>("limit", s.toString())).collect(Collectors.toList())); 170 } 171 172 /** 173 * add additional limit query parameters 174 */ 175 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addLimit( 176 final Collection<TValue> limit) { 177 return copy().addQueryParams( 178 limit.stream().map(s -> new ParamEntry<>("limit", s.toString())).collect(Collectors.toList())); 179 } 180 181 /** 182 * set offset with the specified value 183 */ 184 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withOffset(final TValue offset) { 185 return copy().withQueryParam("offset", offset); 186 } 187 188 /** 189 * add additional offset query parameter 190 */ 191 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addOffset(final TValue offset) { 192 return copy().addQueryParam("offset", offset); 193 } 194 195 /** 196 * set offset with the specified value 197 */ 198 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withOffset(final Supplier<Integer> supplier) { 199 return copy().withQueryParam("offset", supplier.get()); 200 } 201 202 /** 203 * add additional offset query parameter 204 */ 205 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addOffset(final Supplier<Integer> supplier) { 206 return copy().addQueryParam("offset", supplier.get()); 207 } 208 209 /** 210 * set offset with the specified value 211 */ 212 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withOffset( 213 final Function<StringBuilder, StringBuilder> op) { 214 return copy().withQueryParam("offset", op.apply(new StringBuilder())); 215 } 216 217 /** 218 * add additional offset query parameter 219 */ 220 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addOffset( 221 final Function<StringBuilder, StringBuilder> op) { 222 return copy().addQueryParam("offset", op.apply(new StringBuilder())); 223 } 224 225 /** 226 * set offset with the specified values 227 */ 228 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withOffset( 229 final Collection<TValue> offset) { 230 return copy().withoutQueryParam("offset") 231 .addQueryParams( 232 offset.stream().map(s -> new ParamEntry<>("offset", s.toString())).collect(Collectors.toList())); 233 } 234 235 /** 236 * add additional offset query parameters 237 */ 238 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addOffset( 239 final Collection<TValue> offset) { 240 return copy().addQueryParams( 241 offset.stream().map(s -> new ParamEntry<>("offset", s.toString())).collect(Collectors.toList())); 242 } 243 244 /** 245 * set staged with the specified value 246 */ 247 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withStaged(final TValue staged) { 248 return copy().withQueryParam("staged", staged); 249 } 250 251 /** 252 * add additional staged query parameter 253 */ 254 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addStaged(final TValue staged) { 255 return copy().addQueryParam("staged", staged); 256 } 257 258 /** 259 * set staged with the specified value 260 */ 261 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withStaged(final Supplier<Boolean> supplier) { 262 return copy().withQueryParam("staged", supplier.get()); 263 } 264 265 /** 266 * add additional staged query parameter 267 */ 268 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addStaged(final Supplier<Boolean> supplier) { 269 return copy().addQueryParam("staged", supplier.get()); 270 } 271 272 /** 273 * set staged with the specified value 274 */ 275 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withStaged( 276 final Function<StringBuilder, StringBuilder> op) { 277 return copy().withQueryParam("staged", op.apply(new StringBuilder())); 278 } 279 280 /** 281 * add additional staged query parameter 282 */ 283 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addStaged( 284 final Function<StringBuilder, StringBuilder> op) { 285 return copy().addQueryParam("staged", op.apply(new StringBuilder())); 286 } 287 288 /** 289 * set staged with the specified values 290 */ 291 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withStaged( 292 final Collection<TValue> staged) { 293 return copy().withoutQueryParam("staged") 294 .addQueryParams( 295 staged.stream().map(s -> new ParamEntry<>("staged", s.toString())).collect(Collectors.toList())); 296 } 297 298 /** 299 * add additional staged query parameters 300 */ 301 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addStaged( 302 final Collection<TValue> staged) { 303 return copy().addQueryParams( 304 staged.stream().map(s -> new ParamEntry<>("staged", s.toString())).collect(Collectors.toList())); 305 } 306 307 /** 308 * set confidenceMin with the specified value 309 */ 310 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withConfidenceMin( 311 final TValue confidenceMin) { 312 return copy().withQueryParam("confidenceMin", confidenceMin); 313 } 314 315 /** 316 * add additional confidenceMin query parameter 317 */ 318 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addConfidenceMin( 319 final TValue confidenceMin) { 320 return copy().addQueryParam("confidenceMin", confidenceMin); 321 } 322 323 /** 324 * set confidenceMin with the specified value 325 */ 326 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withConfidenceMin( 327 final Supplier<Double> supplier) { 328 return copy().withQueryParam("confidenceMin", supplier.get()); 329 } 330 331 /** 332 * add additional confidenceMin query parameter 333 */ 334 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addConfidenceMin( 335 final Supplier<Double> supplier) { 336 return copy().addQueryParam("confidenceMin", supplier.get()); 337 } 338 339 /** 340 * set confidenceMin with the specified value 341 */ 342 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withConfidenceMin( 343 final Function<StringBuilder, StringBuilder> op) { 344 return copy().withQueryParam("confidenceMin", op.apply(new StringBuilder())); 345 } 346 347 /** 348 * add additional confidenceMin query parameter 349 */ 350 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addConfidenceMin( 351 final Function<StringBuilder, StringBuilder> op) { 352 return copy().addQueryParam("confidenceMin", op.apply(new StringBuilder())); 353 } 354 355 /** 356 * set confidenceMin with the specified values 357 */ 358 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withConfidenceMin( 359 final Collection<TValue> confidenceMin) { 360 return copy().withoutQueryParam("confidenceMin") 361 .addQueryParams(confidenceMin.stream() 362 .map(s -> new ParamEntry<>("confidenceMin", s.toString())) 363 .collect(Collectors.toList())); 364 } 365 366 /** 367 * add additional confidenceMin query parameters 368 */ 369 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addConfidenceMin( 370 final Collection<TValue> confidenceMin) { 371 return copy().addQueryParams(confidenceMin.stream() 372 .map(s -> new ParamEntry<>("confidenceMin", s.toString())) 373 .collect(Collectors.toList())); 374 } 375 376 /** 377 * set confidenceMax with the specified value 378 */ 379 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withConfidenceMax( 380 final TValue confidenceMax) { 381 return copy().withQueryParam("confidenceMax", confidenceMax); 382 } 383 384 /** 385 * add additional confidenceMax query parameter 386 */ 387 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addConfidenceMax( 388 final TValue confidenceMax) { 389 return copy().addQueryParam("confidenceMax", confidenceMax); 390 } 391 392 /** 393 * set confidenceMax with the specified value 394 */ 395 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withConfidenceMax( 396 final Supplier<Double> supplier) { 397 return copy().withQueryParam("confidenceMax", supplier.get()); 398 } 399 400 /** 401 * add additional confidenceMax query parameter 402 */ 403 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addConfidenceMax( 404 final Supplier<Double> supplier) { 405 return copy().addQueryParam("confidenceMax", supplier.get()); 406 } 407 408 /** 409 * set confidenceMax with the specified value 410 */ 411 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withConfidenceMax( 412 final Function<StringBuilder, StringBuilder> op) { 413 return copy().withQueryParam("confidenceMax", op.apply(new StringBuilder())); 414 } 415 416 /** 417 * add additional confidenceMax query parameter 418 */ 419 public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addConfidenceMax( 420 final Function<StringBuilder, StringBuilder> op) { 421 return copy().addQueryParam("confidenceMax", op.apply(new StringBuilder())); 422 } 423 424 /** 425 * set confidenceMax with the specified values 426 */ 427 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withConfidenceMax( 428 final Collection<TValue> confidenceMax) { 429 return copy().withoutQueryParam("confidenceMax") 430 .addQueryParams(confidenceMax.stream() 431 .map(s -> new ParamEntry<>("confidenceMax", s.toString())) 432 .collect(Collectors.toList())); 433 } 434 435 /** 436 * add additional confidenceMax query parameters 437 */ 438 public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addConfidenceMax( 439 final Collection<TValue> confidenceMax) { 440 return copy().addQueryParams(confidenceMax.stream() 441 .map(s -> new ParamEntry<>("confidenceMax", s.toString())) 442 .collect(Collectors.toList())); 443 } 444 445 @Override 446 public boolean equals(Object o) { 447 if (this == o) 448 return true; 449 450 if (o == null || getClass() != o.getClass()) 451 return false; 452 453 ByProjectKeyRecommendationsProjectCategoriesByProductIdGet that = (ByProjectKeyRecommendationsProjectCategoriesByProductIdGet) o; 454 455 return new EqualsBuilder().append(projectKey, that.projectKey).append(productId, that.productId).isEquals(); 456 } 457 458 @Override 459 public int hashCode() { 460 return new HashCodeBuilder(17, 37).append(projectKey).append(productId).toHashCode(); 461 } 462 463 @Override 464 protected ByProjectKeyRecommendationsProjectCategoriesByProductIdGet copy() { 465 return new ByProjectKeyRecommendationsProjectCategoriesByProductIdGet(this); 466 } 467}