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>This endpoint takes arbitrary product names or image URLs and generates recommendations from a general set of categories, which cover a broad range of industries. The full list of supported categories can be found here. These are independent of the categories that are actually defined in your project. The main purpose of this API is to provide a quick way to test the behavior of the category recommendations engine for different names and images. In contrast to the project-specific endpoint, this endpoint does not have activation criteria and is enabled for all projects.</p>
022 *
023 * <hr>
024 * <div class=code-example>
025 * <pre><code class='java'>{@code
026 *   CompletableFuture<ApiHttpResponse<com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendationPagedQueryResponse>> result = apiRoot
027 *            .withProjectKey("{projectKey}")
028 *            .recommendations()
029 *            .generalCategories()
030 *            .get()
031 *            .withProductName(productName)
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 ByProjectKeyRecommendationsGeneralCategoriesGet extends
038        ApiMethod<ByProjectKeyRecommendationsGeneralCategoriesGet, com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendationPagedQueryResponse> {
039
040    private String projectKey;
041
042    public ByProjectKeyRecommendationsGeneralCategoriesGet(final ApiHttpClient apiHttpClient, String projectKey) {
043        super(apiHttpClient);
044        this.projectKey = projectKey;
045    }
046
047    public ByProjectKeyRecommendationsGeneralCategoriesGet(ByProjectKeyRecommendationsGeneralCategoriesGet t) {
048        super(t);
049        this.projectKey = t.projectKey;
050    }
051
052    @Override
053    protected ApiHttpRequest buildHttpRequest() {
054        List<String> params = new ArrayList<>(getQueryParamUriStrings());
055        String httpRequestPath = String.format("/%s/recommendations/general-categories", this.projectKey);
056        if (!params.isEmpty()) {
057            httpRequestPath += "?" + String.join("&", params);
058        }
059        return new ApiHttpRequest(ApiHttpMethod.GET, URI.create(httpRequestPath), getHeaders(), null);
060    }
061
062    @Override
063    public ApiHttpResponse<com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendationPagedQueryResponse> executeBlocking(
064            final ApiHttpClient client, final Duration timeout) {
065        return executeBlocking(client, timeout,
066            com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendationPagedQueryResponse.class);
067    }
068
069    @Override
070    public CompletableFuture<ApiHttpResponse<com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendationPagedQueryResponse>> execute(
071            final ApiHttpClient client) {
072        return execute(client,
073            com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendationPagedQueryResponse.class);
074    }
075
076    public String getProjectKey() {
077        return this.projectKey;
078    }
079
080    public List<String> getProductImageUrl() {
081        return this.getQueryParam("productImageUrl");
082    }
083
084    public List<String> getProductName() {
085        return this.getQueryParam("productName");
086    }
087
088    public List<String> getLimit() {
089        return this.getQueryParam("limit");
090    }
091
092    public List<String> getOffset() {
093        return this.getQueryParam("offset");
094    }
095
096    public List<String> getConfidenceMin() {
097        return this.getQueryParam("confidenceMin");
098    }
099
100    public List<String> getConfidenceMax() {
101        return this.getQueryParam("confidenceMax");
102    }
103
104    public void setProjectKey(final String projectKey) {
105        this.projectKey = projectKey;
106    }
107
108    /**
109     * set productImageUrl with the specified value
110     */
111    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet withProductImageUrl(final TValue productImageUrl) {
112        return copy().withQueryParam("productImageUrl", productImageUrl);
113    }
114
115    /**
116     * add additional productImageUrl query parameter
117     */
118    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet addProductImageUrl(final TValue productImageUrl) {
119        return copy().addQueryParam("productImageUrl", productImageUrl);
120    }
121
122    /**
123     * set productImageUrl with the specified value
124     */
125    public ByProjectKeyRecommendationsGeneralCategoriesGet withProductImageUrl(final Supplier<String> supplier) {
126        return copy().withQueryParam("productImageUrl", supplier.get());
127    }
128
129    /**
130     * add additional productImageUrl query parameter
131     */
132    public ByProjectKeyRecommendationsGeneralCategoriesGet addProductImageUrl(final Supplier<String> supplier) {
133        return copy().addQueryParam("productImageUrl", supplier.get());
134    }
135
136    /**
137     * set productImageUrl with the specified value
138     */
139    public ByProjectKeyRecommendationsGeneralCategoriesGet withProductImageUrl(
140            final Function<StringBuilder, StringBuilder> op) {
141        return copy().withQueryParam("productImageUrl", op.apply(new StringBuilder()));
142    }
143
144    /**
145     * add additional productImageUrl query parameter
146     */
147    public ByProjectKeyRecommendationsGeneralCategoriesGet addProductImageUrl(
148            final Function<StringBuilder, StringBuilder> op) {
149        return copy().addQueryParam("productImageUrl", op.apply(new StringBuilder()));
150    }
151
152    /**
153     * set productImageUrl with the specified values
154     */
155    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet withProductImageUrl(
156            final Collection<TValue> productImageUrl) {
157        return copy().withoutQueryParam("productImageUrl")
158                .addQueryParams(productImageUrl.stream()
159                        .map(s -> new ParamEntry<>("productImageUrl", s.toString()))
160                        .collect(Collectors.toList()));
161    }
162
163    /**
164     * add additional productImageUrl query parameters
165     */
166    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet addProductImageUrl(
167            final Collection<TValue> productImageUrl) {
168        return copy().addQueryParams(productImageUrl.stream()
169                .map(s -> new ParamEntry<>("productImageUrl", s.toString()))
170                .collect(Collectors.toList()));
171    }
172
173    /**
174     * set productName with the specified value
175     */
176    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet withProductName(final TValue productName) {
177        return copy().withQueryParam("productName", productName);
178    }
179
180    /**
181     * add additional productName query parameter
182     */
183    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet addProductName(final TValue productName) {
184        return copy().addQueryParam("productName", productName);
185    }
186
187    /**
188     * set productName with the specified value
189     */
190    public ByProjectKeyRecommendationsGeneralCategoriesGet withProductName(final Supplier<String> supplier) {
191        return copy().withQueryParam("productName", supplier.get());
192    }
193
194    /**
195     * add additional productName query parameter
196     */
197    public ByProjectKeyRecommendationsGeneralCategoriesGet addProductName(final Supplier<String> supplier) {
198        return copy().addQueryParam("productName", supplier.get());
199    }
200
201    /**
202     * set productName with the specified value
203     */
204    public ByProjectKeyRecommendationsGeneralCategoriesGet withProductName(
205            final Function<StringBuilder, StringBuilder> op) {
206        return copy().withQueryParam("productName", op.apply(new StringBuilder()));
207    }
208
209    /**
210     * add additional productName query parameter
211     */
212    public ByProjectKeyRecommendationsGeneralCategoriesGet addProductName(
213            final Function<StringBuilder, StringBuilder> op) {
214        return copy().addQueryParam("productName", op.apply(new StringBuilder()));
215    }
216
217    /**
218     * set productName with the specified values
219     */
220    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet withProductName(
221            final Collection<TValue> productName) {
222        return copy().withoutQueryParam("productName")
223                .addQueryParams(productName.stream()
224                        .map(s -> new ParamEntry<>("productName", s.toString()))
225                        .collect(Collectors.toList()));
226    }
227
228    /**
229     * add additional productName query parameters
230     */
231    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet addProductName(
232            final Collection<TValue> productName) {
233        return copy().addQueryParams(
234            productName.stream().map(s -> new ParamEntry<>("productName", s.toString())).collect(Collectors.toList()));
235    }
236
237    /**
238     * set limit with the specified value
239     */
240    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet withLimit(final TValue limit) {
241        return copy().withQueryParam("limit", limit);
242    }
243
244    /**
245     * add additional limit query parameter
246     */
247    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet addLimit(final TValue limit) {
248        return copy().addQueryParam("limit", limit);
249    }
250
251    /**
252     * set limit with the specified value
253     */
254    public ByProjectKeyRecommendationsGeneralCategoriesGet withLimit(final Supplier<Integer> supplier) {
255        return copy().withQueryParam("limit", supplier.get());
256    }
257
258    /**
259     * add additional limit query parameter
260     */
261    public ByProjectKeyRecommendationsGeneralCategoriesGet addLimit(final Supplier<Integer> supplier) {
262        return copy().addQueryParam("limit", supplier.get());
263    }
264
265    /**
266     * set limit with the specified value
267     */
268    public ByProjectKeyRecommendationsGeneralCategoriesGet withLimit(final Function<StringBuilder, StringBuilder> op) {
269        return copy().withQueryParam("limit", op.apply(new StringBuilder()));
270    }
271
272    /**
273     * add additional limit query parameter
274     */
275    public ByProjectKeyRecommendationsGeneralCategoriesGet addLimit(final Function<StringBuilder, StringBuilder> op) {
276        return copy().addQueryParam("limit", op.apply(new StringBuilder()));
277    }
278
279    /**
280     * set limit with the specified values
281     */
282    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet withLimit(final Collection<TValue> limit) {
283        return copy().withoutQueryParam("limit")
284                .addQueryParams(
285                    limit.stream().map(s -> new ParamEntry<>("limit", s.toString())).collect(Collectors.toList()));
286    }
287
288    /**
289     * add additional limit query parameters
290     */
291    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet addLimit(final Collection<TValue> limit) {
292        return copy().addQueryParams(
293            limit.stream().map(s -> new ParamEntry<>("limit", s.toString())).collect(Collectors.toList()));
294    }
295
296    /**
297     * set offset with the specified value
298     */
299    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet withOffset(final TValue offset) {
300        return copy().withQueryParam("offset", offset);
301    }
302
303    /**
304     * add additional offset query parameter
305     */
306    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet addOffset(final TValue offset) {
307        return copy().addQueryParam("offset", offset);
308    }
309
310    /**
311     * set offset with the specified value
312     */
313    public ByProjectKeyRecommendationsGeneralCategoriesGet withOffset(final Supplier<Integer> supplier) {
314        return copy().withQueryParam("offset", supplier.get());
315    }
316
317    /**
318     * add additional offset query parameter
319     */
320    public ByProjectKeyRecommendationsGeneralCategoriesGet addOffset(final Supplier<Integer> supplier) {
321        return copy().addQueryParam("offset", supplier.get());
322    }
323
324    /**
325     * set offset with the specified value
326     */
327    public ByProjectKeyRecommendationsGeneralCategoriesGet withOffset(final Function<StringBuilder, StringBuilder> op) {
328        return copy().withQueryParam("offset", op.apply(new StringBuilder()));
329    }
330
331    /**
332     * add additional offset query parameter
333     */
334    public ByProjectKeyRecommendationsGeneralCategoriesGet addOffset(final Function<StringBuilder, StringBuilder> op) {
335        return copy().addQueryParam("offset", op.apply(new StringBuilder()));
336    }
337
338    /**
339     * set offset with the specified values
340     */
341    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet withOffset(final Collection<TValue> offset) {
342        return copy().withoutQueryParam("offset")
343                .addQueryParams(
344                    offset.stream().map(s -> new ParamEntry<>("offset", s.toString())).collect(Collectors.toList()));
345    }
346
347    /**
348     * add additional offset query parameters
349     */
350    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet addOffset(final Collection<TValue> offset) {
351        return copy().addQueryParams(
352            offset.stream().map(s -> new ParamEntry<>("offset", s.toString())).collect(Collectors.toList()));
353    }
354
355    /**
356     * set confidenceMin with the specified value
357     */
358    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet withConfidenceMin(final TValue confidenceMin) {
359        return copy().withQueryParam("confidenceMin", confidenceMin);
360    }
361
362    /**
363     * add additional confidenceMin query parameter
364     */
365    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet addConfidenceMin(final TValue confidenceMin) {
366        return copy().addQueryParam("confidenceMin", confidenceMin);
367    }
368
369    /**
370     * set confidenceMin with the specified value
371     */
372    public ByProjectKeyRecommendationsGeneralCategoriesGet withConfidenceMin(final Supplier<Double> supplier) {
373        return copy().withQueryParam("confidenceMin", supplier.get());
374    }
375
376    /**
377     * add additional confidenceMin query parameter
378     */
379    public ByProjectKeyRecommendationsGeneralCategoriesGet addConfidenceMin(final Supplier<Double> supplier) {
380        return copy().addQueryParam("confidenceMin", supplier.get());
381    }
382
383    /**
384     * set confidenceMin with the specified value
385     */
386    public ByProjectKeyRecommendationsGeneralCategoriesGet withConfidenceMin(
387            final Function<StringBuilder, StringBuilder> op) {
388        return copy().withQueryParam("confidenceMin", op.apply(new StringBuilder()));
389    }
390
391    /**
392     * add additional confidenceMin query parameter
393     */
394    public ByProjectKeyRecommendationsGeneralCategoriesGet addConfidenceMin(
395            final Function<StringBuilder, StringBuilder> op) {
396        return copy().addQueryParam("confidenceMin", op.apply(new StringBuilder()));
397    }
398
399    /**
400     * set confidenceMin with the specified values
401     */
402    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet withConfidenceMin(
403            final Collection<TValue> confidenceMin) {
404        return copy().withoutQueryParam("confidenceMin")
405                .addQueryParams(confidenceMin.stream()
406                        .map(s -> new ParamEntry<>("confidenceMin", s.toString()))
407                        .collect(Collectors.toList()));
408    }
409
410    /**
411     * add additional confidenceMin query parameters
412     */
413    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet addConfidenceMin(
414            final Collection<TValue> confidenceMin) {
415        return copy().addQueryParams(confidenceMin.stream()
416                .map(s -> new ParamEntry<>("confidenceMin", s.toString()))
417                .collect(Collectors.toList()));
418    }
419
420    /**
421     * set confidenceMax with the specified value
422     */
423    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet withConfidenceMax(final TValue confidenceMax) {
424        return copy().withQueryParam("confidenceMax", confidenceMax);
425    }
426
427    /**
428     * add additional confidenceMax query parameter
429     */
430    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet addConfidenceMax(final TValue confidenceMax) {
431        return copy().addQueryParam("confidenceMax", confidenceMax);
432    }
433
434    /**
435     * set confidenceMax with the specified value
436     */
437    public ByProjectKeyRecommendationsGeneralCategoriesGet withConfidenceMax(final Supplier<Double> supplier) {
438        return copy().withQueryParam("confidenceMax", supplier.get());
439    }
440
441    /**
442     * add additional confidenceMax query parameter
443     */
444    public ByProjectKeyRecommendationsGeneralCategoriesGet addConfidenceMax(final Supplier<Double> supplier) {
445        return copy().addQueryParam("confidenceMax", supplier.get());
446    }
447
448    /**
449     * set confidenceMax with the specified value
450     */
451    public ByProjectKeyRecommendationsGeneralCategoriesGet withConfidenceMax(
452            final Function<StringBuilder, StringBuilder> op) {
453        return copy().withQueryParam("confidenceMax", op.apply(new StringBuilder()));
454    }
455
456    /**
457     * add additional confidenceMax query parameter
458     */
459    public ByProjectKeyRecommendationsGeneralCategoriesGet addConfidenceMax(
460            final Function<StringBuilder, StringBuilder> op) {
461        return copy().addQueryParam("confidenceMax", op.apply(new StringBuilder()));
462    }
463
464    /**
465     * set confidenceMax with the specified values
466     */
467    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet withConfidenceMax(
468            final Collection<TValue> confidenceMax) {
469        return copy().withoutQueryParam("confidenceMax")
470                .addQueryParams(confidenceMax.stream()
471                        .map(s -> new ParamEntry<>("confidenceMax", s.toString()))
472                        .collect(Collectors.toList()));
473    }
474
475    /**
476     * add additional confidenceMax query parameters
477     */
478    public <TValue> ByProjectKeyRecommendationsGeneralCategoriesGet addConfidenceMax(
479            final Collection<TValue> confidenceMax) {
480        return copy().addQueryParams(confidenceMax.stream()
481                .map(s -> new ParamEntry<>("confidenceMax", s.toString()))
482                .collect(Collectors.toList()));
483    }
484
485    @Override
486    public boolean equals(Object o) {
487        if (this == o)
488            return true;
489
490        if (o == null || getClass() != o.getClass())
491            return false;
492
493        ByProjectKeyRecommendationsGeneralCategoriesGet that = (ByProjectKeyRecommendationsGeneralCategoriesGet) o;
494
495        return new EqualsBuilder().append(projectKey, that.projectKey).isEquals();
496    }
497
498    @Override
499    public int hashCode() {
500        return new HashCodeBuilder(17, 37).append(projectKey).toHashCode();
501    }
502
503    @Override
504    protected ByProjectKeyRecommendationsGeneralCategoriesGet copy() {
505        return new ByProjectKeyRecommendationsGeneralCategoriesGet(this);
506    }
507}