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     * @param limit value to be set
121     * @param <TValue> value type
122     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
123     */
124    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withLimit(final TValue limit) {
125        return copy().withQueryParam("limit", limit);
126    }
127
128    /**
129     * add additional limit query parameter
130     * @param limit value to be added
131     * @param <TValue> value type
132     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
133     */
134    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addLimit(final TValue limit) {
135        return copy().addQueryParam("limit", limit);
136    }
137
138    /**
139     * set limit with the specified value
140     * @param supplier supplier for the value to be set
141     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
142     */
143    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withLimit(final Supplier<Integer> supplier) {
144        return copy().withQueryParam("limit", supplier.get());
145    }
146
147    /**
148     * add additional limit query parameter
149     * @param supplier supplier for the value to be added
150     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
151     */
152    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addLimit(final Supplier<Integer> supplier) {
153        return copy().addQueryParam("limit", supplier.get());
154    }
155
156    /**
157     * set limit with the specified value
158     * @param op builder for the value to be set
159     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
160     */
161    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withLimit(
162            final Function<StringBuilder, StringBuilder> op) {
163        return copy().withQueryParam("limit", op.apply(new StringBuilder()));
164    }
165
166    /**
167     * add additional limit query parameter
168     * @param op builder for the value to be added
169     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
170     */
171    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addLimit(
172            final Function<StringBuilder, StringBuilder> op) {
173        return copy().addQueryParam("limit", op.apply(new StringBuilder()));
174    }
175
176    /**
177     * set limit with the specified values
178     * @param limit values to be set
179     * @param <TValue> value type
180     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
181     */
182    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withLimit(
183            final Collection<TValue> limit) {
184        return copy().withoutQueryParam("limit")
185                .addQueryParams(
186                    limit.stream().map(s -> new ParamEntry<>("limit", s.toString())).collect(Collectors.toList()));
187    }
188
189    /**
190     * add additional limit query parameters
191     * @param limit values to be added
192     * @param <TValue> value type
193     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
194     */
195    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addLimit(
196            final Collection<TValue> limit) {
197        return copy().addQueryParams(
198            limit.stream().map(s -> new ParamEntry<>("limit", s.toString())).collect(Collectors.toList()));
199    }
200
201    /**
202     * set offset with the specified value
203     * @param offset value to be set
204     * @param <TValue> value type
205     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
206     */
207    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withOffset(final TValue offset) {
208        return copy().withQueryParam("offset", offset);
209    }
210
211    /**
212     * add additional offset query parameter
213     * @param offset value to be added
214     * @param <TValue> value type
215     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
216     */
217    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addOffset(final TValue offset) {
218        return copy().addQueryParam("offset", offset);
219    }
220
221    /**
222     * set offset with the specified value
223     * @param supplier supplier for the value to be set
224     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
225     */
226    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withOffset(final Supplier<Integer> supplier) {
227        return copy().withQueryParam("offset", supplier.get());
228    }
229
230    /**
231     * add additional offset query parameter
232     * @param supplier supplier for the value to be added
233     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
234     */
235    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addOffset(final Supplier<Integer> supplier) {
236        return copy().addQueryParam("offset", supplier.get());
237    }
238
239    /**
240     * set offset with the specified value
241     * @param op builder for the value to be set
242     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
243     */
244    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withOffset(
245            final Function<StringBuilder, StringBuilder> op) {
246        return copy().withQueryParam("offset", op.apply(new StringBuilder()));
247    }
248
249    /**
250     * add additional offset query parameter
251     * @param op builder for the value to be added
252     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
253     */
254    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addOffset(
255            final Function<StringBuilder, StringBuilder> op) {
256        return copy().addQueryParam("offset", op.apply(new StringBuilder()));
257    }
258
259    /**
260     * set offset with the specified values
261     * @param offset values to be set
262     * @param <TValue> value type
263     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
264     */
265    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withOffset(
266            final Collection<TValue> offset) {
267        return copy().withoutQueryParam("offset")
268                .addQueryParams(
269                    offset.stream().map(s -> new ParamEntry<>("offset", s.toString())).collect(Collectors.toList()));
270    }
271
272    /**
273     * add additional offset query parameters
274     * @param offset values to be added
275     * @param <TValue> value type
276     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
277     */
278    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addOffset(
279            final Collection<TValue> offset) {
280        return copy().addQueryParams(
281            offset.stream().map(s -> new ParamEntry<>("offset", s.toString())).collect(Collectors.toList()));
282    }
283
284    /**
285     * set staged with the specified value
286     * @param staged value to be set
287     * @param <TValue> value type
288     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
289     */
290    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withStaged(final TValue staged) {
291        return copy().withQueryParam("staged", staged);
292    }
293
294    /**
295     * add additional staged query parameter
296     * @param staged value to be added
297     * @param <TValue> value type
298     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
299     */
300    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addStaged(final TValue staged) {
301        return copy().addQueryParam("staged", staged);
302    }
303
304    /**
305     * set staged with the specified value
306     * @param supplier supplier for the value to be set
307     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
308     */
309    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withStaged(final Supplier<Boolean> supplier) {
310        return copy().withQueryParam("staged", supplier.get());
311    }
312
313    /**
314     * add additional staged query parameter
315     * @param supplier supplier for the value to be added
316     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
317     */
318    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addStaged(final Supplier<Boolean> supplier) {
319        return copy().addQueryParam("staged", supplier.get());
320    }
321
322    /**
323     * set staged with the specified value
324     * @param op builder for the value to be set
325     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
326     */
327    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withStaged(
328            final Function<StringBuilder, StringBuilder> op) {
329        return copy().withQueryParam("staged", op.apply(new StringBuilder()));
330    }
331
332    /**
333     * add additional staged query parameter
334     * @param op builder for the value to be added
335     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
336     */
337    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addStaged(
338            final Function<StringBuilder, StringBuilder> op) {
339        return copy().addQueryParam("staged", op.apply(new StringBuilder()));
340    }
341
342    /**
343     * set staged with the specified values
344     * @param staged values to be set
345     * @param <TValue> value type
346     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
347     */
348    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withStaged(
349            final Collection<TValue> staged) {
350        return copy().withoutQueryParam("staged")
351                .addQueryParams(
352                    staged.stream().map(s -> new ParamEntry<>("staged", s.toString())).collect(Collectors.toList()));
353    }
354
355    /**
356     * add additional staged query parameters
357     * @param staged values to be added
358     * @param <TValue> value type
359     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
360     */
361    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addStaged(
362            final Collection<TValue> staged) {
363        return copy().addQueryParams(
364            staged.stream().map(s -> new ParamEntry<>("staged", s.toString())).collect(Collectors.toList()));
365    }
366
367    /**
368     * set confidenceMin with the specified value
369     * @param confidenceMin value to be set
370     * @param <TValue> value type
371     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
372     */
373    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withConfidenceMin(
374            final TValue confidenceMin) {
375        return copy().withQueryParam("confidenceMin", confidenceMin);
376    }
377
378    /**
379     * add additional confidenceMin query parameter
380     * @param confidenceMin value to be added
381     * @param <TValue> value type
382     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
383     */
384    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addConfidenceMin(
385            final TValue confidenceMin) {
386        return copy().addQueryParam("confidenceMin", confidenceMin);
387    }
388
389    /**
390     * set confidenceMin with the specified value
391     * @param supplier supplier for the value to be set
392     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
393     */
394    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withConfidenceMin(
395            final Supplier<Double> supplier) {
396        return copy().withQueryParam("confidenceMin", supplier.get());
397    }
398
399    /**
400     * add additional confidenceMin query parameter
401     * @param supplier supplier for the value to be added
402     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
403     */
404    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addConfidenceMin(
405            final Supplier<Double> supplier) {
406        return copy().addQueryParam("confidenceMin", supplier.get());
407    }
408
409    /**
410     * set confidenceMin with the specified value
411     * @param op builder for the value to be set
412     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
413     */
414    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withConfidenceMin(
415            final Function<StringBuilder, StringBuilder> op) {
416        return copy().withQueryParam("confidenceMin", op.apply(new StringBuilder()));
417    }
418
419    /**
420     * add additional confidenceMin query parameter
421     * @param op builder for the value to be added
422     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
423     */
424    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addConfidenceMin(
425            final Function<StringBuilder, StringBuilder> op) {
426        return copy().addQueryParam("confidenceMin", op.apply(new StringBuilder()));
427    }
428
429    /**
430     * set confidenceMin with the specified values
431     * @param confidenceMin values to be set
432     * @param <TValue> value type
433     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
434     */
435    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withConfidenceMin(
436            final Collection<TValue> confidenceMin) {
437        return copy().withoutQueryParam("confidenceMin")
438                .addQueryParams(confidenceMin.stream()
439                        .map(s -> new ParamEntry<>("confidenceMin", s.toString()))
440                        .collect(Collectors.toList()));
441    }
442
443    /**
444     * add additional confidenceMin query parameters
445     * @param confidenceMin values to be added
446     * @param <TValue> value type
447     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
448     */
449    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addConfidenceMin(
450            final Collection<TValue> confidenceMin) {
451        return copy().addQueryParams(confidenceMin.stream()
452                .map(s -> new ParamEntry<>("confidenceMin", s.toString()))
453                .collect(Collectors.toList()));
454    }
455
456    /**
457     * set confidenceMax with the specified value
458     * @param confidenceMax value to be set
459     * @param <TValue> value type
460     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
461     */
462    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withConfidenceMax(
463            final TValue confidenceMax) {
464        return copy().withQueryParam("confidenceMax", confidenceMax);
465    }
466
467    /**
468     * add additional confidenceMax query parameter
469     * @param confidenceMax value to be added
470     * @param <TValue> value type
471     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
472     */
473    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addConfidenceMax(
474            final TValue confidenceMax) {
475        return copy().addQueryParam("confidenceMax", confidenceMax);
476    }
477
478    /**
479     * set confidenceMax with the specified value
480     * @param supplier supplier for the value to be set
481     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
482     */
483    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withConfidenceMax(
484            final Supplier<Double> supplier) {
485        return copy().withQueryParam("confidenceMax", supplier.get());
486    }
487
488    /**
489     * add additional confidenceMax query parameter
490     * @param supplier supplier for the value to be added
491     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
492     */
493    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addConfidenceMax(
494            final Supplier<Double> supplier) {
495        return copy().addQueryParam("confidenceMax", supplier.get());
496    }
497
498    /**
499     * set confidenceMax with the specified value
500     * @param op builder for the value to be set
501     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
502     */
503    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withConfidenceMax(
504            final Function<StringBuilder, StringBuilder> op) {
505        return copy().withQueryParam("confidenceMax", op.apply(new StringBuilder()));
506    }
507
508    /**
509     * add additional confidenceMax query parameter
510     * @param op builder for the value to be added
511     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
512     */
513    public ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addConfidenceMax(
514            final Function<StringBuilder, StringBuilder> op) {
515        return copy().addQueryParam("confidenceMax", op.apply(new StringBuilder()));
516    }
517
518    /**
519     * set confidenceMax with the specified values
520     * @param confidenceMax values to be set
521     * @param <TValue> value type
522     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
523     */
524    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet withConfidenceMax(
525            final Collection<TValue> confidenceMax) {
526        return copy().withoutQueryParam("confidenceMax")
527                .addQueryParams(confidenceMax.stream()
528                        .map(s -> new ParamEntry<>("confidenceMax", s.toString()))
529                        .collect(Collectors.toList()));
530    }
531
532    /**
533     * add additional confidenceMax query parameters
534     * @param confidenceMax values to be added
535     * @param <TValue> value type
536     * @return ByProjectKeyRecommendationsProjectCategoriesByProductIdGet
537     */
538    public <TValue> ByProjectKeyRecommendationsProjectCategoriesByProductIdGet addConfidenceMax(
539            final Collection<TValue> confidenceMax) {
540        return copy().addQueryParams(confidenceMax.stream()
541                .map(s -> new ParamEntry<>("confidenceMax", s.toString()))
542                .collect(Collectors.toList()));
543    }
544
545    @Override
546    public boolean equals(Object o) {
547        if (this == o)
548            return true;
549
550        if (o == null || getClass() != o.getClass())
551            return false;
552
553        ByProjectKeyRecommendationsProjectCategoriesByProductIdGet that = (ByProjectKeyRecommendationsProjectCategoriesByProductIdGet) o;
554
555        return new EqualsBuilder().append(projectKey, that.projectKey).append(productId, that.productId).isEquals();
556    }
557
558    @Override
559    public int hashCode() {
560        return new HashCodeBuilder(17, 37).append(projectKey).append(productId).toHashCode();
561    }
562
563    @Override
564    protected ByProjectKeyRecommendationsProjectCategoriesByProductIdGet copy() {
565        return new ByProjectKeyRecommendationsProjectCategoriesByProductIdGet(this);
566    }
567}