Skip to content

Commit 4ed233c

Browse files
feat(specs): introduce recommend source in Comp API client (generated)
algolia/api-clients-automation#6227 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Clara Muller <5667350+ClaraMuller@users.noreply.github.com>
1 parent 16e3a74 commit 4ed233c

6 files changed

Lines changed: 317 additions & 11 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost
2+
// - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
package com.algolia.model.composition;
5+
6+
import com.fasterxml.jackson.annotation.*;
7+
import com.fasterxml.jackson.databind.annotation.*;
8+
import java.util.Objects;
9+
10+
/** Injected items will originate from a recommendation request performed on the specified index. */
11+
@JsonDeserialize(as = InjectedItemRecommendSource.class)
12+
public class InjectedItemRecommendSource implements InjectedItemSource {
13+
14+
@JsonProperty("recommend")
15+
private Recommend recommend;
16+
17+
public InjectedItemRecommendSource setRecommend(Recommend recommend) {
18+
this.recommend = recommend;
19+
return this;
20+
}
21+
22+
/** Get recommend */
23+
@javax.annotation.Nonnull
24+
public Recommend getRecommend() {
25+
return recommend;
26+
}
27+
28+
@Override
29+
public boolean equals(Object o) {
30+
if (this == o) {
31+
return true;
32+
}
33+
if (o == null || getClass() != o.getClass()) {
34+
return false;
35+
}
36+
InjectedItemRecommendSource injectedItemRecommendSource = (InjectedItemRecommendSource) o;
37+
return Objects.equals(this.recommend, injectedItemRecommendSource.recommend);
38+
}
39+
40+
@Override
41+
public int hashCode() {
42+
return Objects.hash(recommend);
43+
}
44+
45+
@Override
46+
public String toString() {
47+
StringBuilder sb = new StringBuilder();
48+
sb.append("class InjectedItemRecommendSource {\n");
49+
sb.append(" recommend: ").append(toIndentedString(recommend)).append("\n");
50+
sb.append("}");
51+
return sb.toString();
52+
}
53+
54+
/**
55+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
56+
*/
57+
private String toIndentedString(Object o) {
58+
if (o == null) {
59+
return "null";
60+
}
61+
return o.toString().replace("\n", "\n ");
62+
}
63+
}

algoliasearch/src/main/java/com/algolia/model/composition/InjectedItemSource.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ public InjectedItemSource deserialize(JsonParser jp, DeserializationContext ctxt
4343
);
4444
}
4545
}
46+
// deserialize InjectedItemRecommendSource
47+
if (tree.isObject() && tree.has("recommend")) {
48+
try (JsonParser parser = tree.traverse(jp.getCodec())) {
49+
return parser.readValueAs(InjectedItemRecommendSource.class);
50+
} catch (Exception e) {
51+
// deserialization failed, continue
52+
LOGGER.finest(
53+
"Failed to deserialize oneOf InjectedItemRecommendSource (error: " + e.getMessage() + ") (type: InjectedItemRecommendSource)"
54+
);
55+
}
56+
}
4657
throw new AlgoliaRuntimeException(String.format("Failed to deserialize json element: %s", tree));
4758
}
4859

algoliasearch/src/main/java/com/algolia/model/composition/MainRecommend.java

Lines changed: 76 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,74 @@
1010
/** MainRecommend */
1111
public class MainRecommend {
1212

13-
@JsonProperty("index")
14-
private String index;
13+
@JsonProperty("indexName")
14+
private String indexName;
1515

16-
public MainRecommend setIndex(String index) {
17-
this.index = index;
16+
@JsonProperty("model")
17+
private Model model;
18+
19+
@JsonProperty("threshold")
20+
private Integer threshold;
21+
22+
@JsonProperty("queryParameters")
23+
private MainInjectionQueryParameters queryParameters;
24+
25+
@JsonProperty("fallbackParameters")
26+
private MainInjectionQueryParameters fallbackParameters;
27+
28+
public MainRecommend setIndexName(String indexName) {
29+
this.indexName = indexName;
30+
return this;
31+
}
32+
33+
/** Index to retrieve recommendations from. */
34+
@javax.annotation.Nonnull
35+
public String getIndexName() {
36+
return indexName;
37+
}
38+
39+
public MainRecommend setModel(Model model) {
40+
this.model = model;
41+
return this;
42+
}
43+
44+
/** Get model */
45+
@javax.annotation.Nonnull
46+
public Model getModel() {
47+
return model;
48+
}
49+
50+
public MainRecommend setThreshold(Integer threshold) {
51+
this.threshold = threshold;
1852
return this;
1953
}
2054

21-
/** Targeted index name. */
55+
/** Minimum score a recommendation must have to be included. minimum: 0 maximum: 100 */
2256
@javax.annotation.Nonnull
23-
public String getIndex() {
24-
return index;
57+
public Integer getThreshold() {
58+
return threshold;
59+
}
60+
61+
public MainRecommend setQueryParameters(MainInjectionQueryParameters queryParameters) {
62+
this.queryParameters = queryParameters;
63+
return this;
64+
}
65+
66+
/** Get queryParameters */
67+
@javax.annotation.Nullable
68+
public MainInjectionQueryParameters getQueryParameters() {
69+
return queryParameters;
70+
}
71+
72+
public MainRecommend setFallbackParameters(MainInjectionQueryParameters fallbackParameters) {
73+
this.fallbackParameters = fallbackParameters;
74+
return this;
75+
}
76+
77+
/** Get fallbackParameters */
78+
@javax.annotation.Nullable
79+
public MainInjectionQueryParameters getFallbackParameters() {
80+
return fallbackParameters;
2581
}
2682

2783
@Override
@@ -33,19 +89,29 @@ public boolean equals(Object o) {
3389
return false;
3490
}
3591
MainRecommend mainRecommend = (MainRecommend) o;
36-
return Objects.equals(this.index, mainRecommend.index);
92+
return (
93+
Objects.equals(this.indexName, mainRecommend.indexName) &&
94+
Objects.equals(this.model, mainRecommend.model) &&
95+
Objects.equals(this.threshold, mainRecommend.threshold) &&
96+
Objects.equals(this.queryParameters, mainRecommend.queryParameters) &&
97+
Objects.equals(this.fallbackParameters, mainRecommend.fallbackParameters)
98+
);
3799
}
38100

39101
@Override
40102
public int hashCode() {
41-
return Objects.hash(index);
103+
return Objects.hash(indexName, model, threshold, queryParameters, fallbackParameters);
42104
}
43105

44106
@Override
45107
public String toString() {
46108
StringBuilder sb = new StringBuilder();
47109
sb.append("class MainRecommend {\n");
48-
sb.append(" index: ").append(toIndentedString(index)).append("\n");
110+
sb.append(" indexName: ").append(toIndentedString(indexName)).append("\n");
111+
sb.append(" model: ").append(toIndentedString(model)).append("\n");
112+
sb.append(" threshold: ").append(toIndentedString(threshold)).append("\n");
113+
sb.append(" queryParameters: ").append(toIndentedString(queryParameters)).append("\n");
114+
sb.append(" fallbackParameters: ").append(toIndentedString(fallbackParameters)).append("\n");
49115
sb.append("}");
50116
return sb.toString();
51117
}

algoliasearch/src/main/java/com/algolia/model/composition/MainSearch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public MainSearch setIndex(String index) {
2121
return this;
2222
}
2323

24-
/** Targeted index name. */
24+
/** Index to retrieve search results from. */
2525
@javax.annotation.Nonnull
2626
public String getIndex() {
2727
return index;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost
2+
// - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
package com.algolia.model.composition;
5+
6+
import com.fasterxml.jackson.annotation.*;
7+
import com.fasterxml.jackson.databind.annotation.*;
8+
9+
/** Recommendation model to use for retrieving recommendations. */
10+
public enum Model {
11+
TRENDING_ITEMS("trending-items");
12+
13+
private final String value;
14+
15+
Model(String value) {
16+
this.value = value;
17+
}
18+
19+
@JsonValue
20+
public String getValue() {
21+
return value;
22+
}
23+
24+
@Override
25+
public String toString() {
26+
return String.valueOf(value);
27+
}
28+
29+
@JsonCreator
30+
public static Model fromValue(String value) {
31+
for (Model b : Model.values()) {
32+
if (b.value.equals(value)) {
33+
return b;
34+
}
35+
}
36+
throw new IllegalArgumentException("Unexpected value '" + value + "'");
37+
}
38+
}
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost
2+
// - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
package com.algolia.model.composition;
5+
6+
import com.fasterxml.jackson.annotation.*;
7+
import com.fasterxml.jackson.databind.annotation.*;
8+
import java.util.Objects;
9+
10+
/** Recommend */
11+
public class Recommend {
12+
13+
@JsonProperty("indexName")
14+
private String indexName;
15+
16+
@JsonProperty("model")
17+
private Model model;
18+
19+
@JsonProperty("threshold")
20+
private Integer threshold;
21+
22+
@JsonProperty("queryParameters")
23+
private BaseInjectionQueryParameters queryParameters;
24+
25+
@JsonProperty("fallbackParameters")
26+
private BaseInjectionQueryParameters fallbackParameters;
27+
28+
public Recommend setIndexName(String indexName) {
29+
this.indexName = indexName;
30+
return this;
31+
}
32+
33+
/** Index to retrieve recommendations from. */
34+
@javax.annotation.Nonnull
35+
public String getIndexName() {
36+
return indexName;
37+
}
38+
39+
public Recommend setModel(Model model) {
40+
this.model = model;
41+
return this;
42+
}
43+
44+
/** Get model */
45+
@javax.annotation.Nonnull
46+
public Model getModel() {
47+
return model;
48+
}
49+
50+
public Recommend setThreshold(Integer threshold) {
51+
this.threshold = threshold;
52+
return this;
53+
}
54+
55+
/** Minimum score a recommendation must have to be included. minimum: 0 maximum: 100 */
56+
@javax.annotation.Nonnull
57+
public Integer getThreshold() {
58+
return threshold;
59+
}
60+
61+
public Recommend setQueryParameters(BaseInjectionQueryParameters queryParameters) {
62+
this.queryParameters = queryParameters;
63+
return this;
64+
}
65+
66+
/** Get queryParameters */
67+
@javax.annotation.Nullable
68+
public BaseInjectionQueryParameters getQueryParameters() {
69+
return queryParameters;
70+
}
71+
72+
public Recommend setFallbackParameters(BaseInjectionQueryParameters fallbackParameters) {
73+
this.fallbackParameters = fallbackParameters;
74+
return this;
75+
}
76+
77+
/** Get fallbackParameters */
78+
@javax.annotation.Nullable
79+
public BaseInjectionQueryParameters getFallbackParameters() {
80+
return fallbackParameters;
81+
}
82+
83+
@Override
84+
public boolean equals(Object o) {
85+
if (this == o) {
86+
return true;
87+
}
88+
if (o == null || getClass() != o.getClass()) {
89+
return false;
90+
}
91+
Recommend recommend = (Recommend) o;
92+
return (
93+
Objects.equals(this.indexName, recommend.indexName) &&
94+
Objects.equals(this.model, recommend.model) &&
95+
Objects.equals(this.threshold, recommend.threshold) &&
96+
Objects.equals(this.queryParameters, recommend.queryParameters) &&
97+
Objects.equals(this.fallbackParameters, recommend.fallbackParameters)
98+
);
99+
}
100+
101+
@Override
102+
public int hashCode() {
103+
return Objects.hash(indexName, model, threshold, queryParameters, fallbackParameters);
104+
}
105+
106+
@Override
107+
public String toString() {
108+
StringBuilder sb = new StringBuilder();
109+
sb.append("class Recommend {\n");
110+
sb.append(" indexName: ").append(toIndentedString(indexName)).append("\n");
111+
sb.append(" model: ").append(toIndentedString(model)).append("\n");
112+
sb.append(" threshold: ").append(toIndentedString(threshold)).append("\n");
113+
sb.append(" queryParameters: ").append(toIndentedString(queryParameters)).append("\n");
114+
sb.append(" fallbackParameters: ").append(toIndentedString(fallbackParameters)).append("\n");
115+
sb.append("}");
116+
return sb.toString();
117+
}
118+
119+
/**
120+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
121+
*/
122+
private String toIndentedString(Object o) {
123+
if (o == null) {
124+
return "null";
125+
}
126+
return o.toString().replace("\n", "\n ");
127+
}
128+
}

0 commit comments

Comments
 (0)