Skip to content

Commit b934ae6

Browse files
committed
Release: v6.0.0
- Added support for the new Composite Recommendation endpoint - Added new parameter `autoPresented` for Detail View and View Portion interactions - Added new parameter `timeSpent` for View Portion interactions - Added support for `reqlExpressions` on recommended items
1 parent 3e58c09 commit b934ae6

21 files changed

+665
-80
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
Add the dependency into your `build.gradle.kts`:
3535

3636
```kotlin
37-
implementation("com.recombee:apiclientkotlin:5.0.0")
37+
implementation("com.recombee:apiclientkotlin:6.0.0")
3838
```
3939

4040
### 📚 Version Catalogs
@@ -43,7 +43,7 @@ If you're using [version catalogs](https://developer.android.com/build/migrate-t
4343

4444
```toml
4545
[versions]
46-
recombee = "5.0.0"
46+
recombee = "6.0.0"
4747

4848
[libraries]
4949
recombee = { group = "com.recombee", name = "apiclientkotlin", version.ref = "recombee" }

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ plugins {
1818
}
1919

2020
group = "com.recombee"
21-
version = "5.0.0"
21+
version = "6.0.0"
2222

2323
repositories {
2424
mavenCentral()

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
kotlin.code.style=official
2+
ossrhUsername=
3+
ossrhPassword=

src/main/kotlin/com/recombee/apiclientkotlin/RecombeeClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public class RecombeeClient(
165165
return OkHttp3Request.Builder()
166166
.url(processRequestUri(request))
167167
.post(createJsonRequestBody(request.bodyParameters))
168-
.header("User-Agent", "recombee-kotlin-api-client/5.0.0")
168+
.header("User-Agent", "recombee-kotlin-api-client/6.0.0")
169169
.build()
170170
}
171171

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
This file is auto-generated, do not edit
3+
*/
4+
5+
package com.recombee.apiclientkotlin.bindings
6+
/**
7+
* CompositeRecommendationResponse
8+
* @param recommId Id of the composite recommendation request
9+
* @param source Parameters of the source stage
10+
* @param recomms Obtained recommendations
11+
* @param numberNextRecommsCalls How many times *Recommend Next Items* have been called for this `recommId`
12+
*/
13+
public data class CompositeRecommendationResponse(
14+
public val recommId: String,
15+
public val source: Recommendation,
16+
public val recomms: List<Recommendation>,
17+
public val numberNextRecommsCalls: Long? = null): RecombeeBinding() {
18+
}
19+
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
/*
2+
This file is auto-generated, do not edit
3+
*/
4+
5+
package com.recombee.apiclientkotlin.bindings
6+
/**
7+
* CompositeRecommendationStageParameters
8+
* @param returnProperties With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended items to the user.
9+
10+
Example response with `returnProperties` set in the `resultSettings`:
11+
```json
12+
{
13+
"recommId": "ee94fa8b-efe7-4b35-abc6-2bc3456d66ed",
14+
"source": {
15+
"id": "category-sport"
16+
},
17+
"recomms": [
18+
{
19+
"id": "article-1024",
20+
"values": {
21+
"title": "Champions League: Stunning Comeback Secures Final Spot",
22+
"categories": ["Sport", "Football"],
23+
"author": "Jane Smith",
24+
"url": "newsportal.com/articles/champions-league-comeback"
25+
}
26+
},
27+
{
28+
"id": "article-2031",
29+
"values": {
30+
"title": "Top 10 Moments from the Summer Olympics",
31+
"categories": ["Sport", "Olympics"],
32+
"author": "Mark Johnson",
33+
"url": "newsportal.com/articles/olympic-top-moments"
34+
}
35+
},
36+
{
37+
"id": "article-3042",
38+
"values": {
39+
"title": "Rising Stars in Women's Tennis to Watch This Season",
40+
"categories": ["Sport", "Tennis"],
41+
"author": "Laura Chen",
42+
"url": "newsportal.com/articles/womens-tennis-stars"
43+
}
44+
}
45+
],
46+
"numberNextRecommsCalls": 0
47+
}
48+
49+
```
50+
51+
* @param includedProperties Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
52+
53+
Example response for `returnProperties=true` and `includedProperties=title,url` set in `resultSettings`:
54+
```json
55+
{
56+
"recommId": "ee94fa8b-efe7-4b35-abc6-2bc3456d66ed",
57+
"source": {
58+
"id": "category-sport"
59+
},
60+
"recomms": [
61+
{
62+
"id": "article-1024",
63+
"values": {
64+
"title": "Champions League: Stunning Comeback Secures Final Spot",
65+
"url": "newsportal.com/articles/champions-league-comeback"
66+
}
67+
},
68+
{
69+
"id": "article-2031",
70+
"values": {
71+
"title": "Top 10 Moments from the Summer Olympics",
72+
"url": "newsportal.com/articles/olympic-top-moments"
73+
}
74+
},
75+
{
76+
"id": "article-3042",
77+
"values": {
78+
"title": "Rising Stars in Women's Tennis to Watch This Season",
79+
"url": "newsportal.com/articles/womens-tennis-stars"
80+
}
81+
}
82+
],
83+
"numberNextRecommsCalls": 0
84+
}
85+
86+
```
87+
88+
* @param filter Boolean-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to filter recommended entities based on the values of their attributes.
89+
90+
Filters can also be assigned to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
91+
92+
* @param booster Number-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to boost the recommendation rate of some entities based on the values of their attributes.
93+
94+
Boosters can also be assigned to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
95+
96+
* @param logic Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
97+
See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
98+
99+
The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
100+
101+
Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
102+
103+
* @param reqlExpressions Only usable if the stage corresponds to the one of these recommendation endpoints:
104+
105+
- [Recommend Items To User](https://docs.recombee.com/api#recommend-items-to-user)
106+
- [Recommend Items To Item](https://docs.recombee.com/api#recommend-items-to-item)
107+
- [Recommend Items to Item Segment](https://docs.recombee.com/api#recommend-items-to-item-segment)
108+
- [Recommend Users to Item](https://docs.recombee.com/api#recommend-users-to-item)
109+
- [Recommend Users To User](https://docs.recombee.com/api#recommend-users-to-user)
110+
111+
A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended item.
112+
This can be used to compute additional properties of the recommended items that are not stored in the database.
113+
114+
The keys are the names of the expressions, and the values are the actual ReQL expressions.
115+
116+
Example request:
117+
```json
118+
{
119+
"reqlExpressions": {
120+
"isInUsersCity": "context_user[\"city\"] in 'cities'",
121+
"distanceToUser": "earth_distance('location', context_user[\"location\"])"
122+
}
123+
}
124+
```
125+
126+
Example response:
127+
```json
128+
{
129+
"recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
130+
"source": {
131+
"id": "restaurant-123",
132+
"reqlEvaluations": {
133+
"isInUsersCity": true,
134+
"distanceToUser": 3450.5
135+
}
136+
},
137+
"recomms":
138+
[
139+
{
140+
"id": "restaurant-178",
141+
"reqlEvaluations": {
142+
"isInUsersCity": true,
143+
"distanceToUser": 5200.2
144+
}
145+
},
146+
{
147+
"id": "bar-42",
148+
"reqlEvaluations": {
149+
"isInUsersCity": false,
150+
"distanceToUser": 2516.0
151+
}
152+
}
153+
],
154+
"numberNextRecommsCalls": 0
155+
}
156+
```
157+
158+
* @param minRelevance **Expert option:** Only usable if the stage corresponds to the one of these recommendation endpoints:
159+
160+
- [Recommend Items To User](https://docs.recombee.com/api#recommend-items-to-user)
161+
- [Recommend Items To Item](https://docs.recombee.com/api#recommend-items-to-item)
162+
- [Recommend Items to Item Segment](https://docs.recombee.com/api#recommend-items-to-item-segment)
163+
164+
If the *userId* is provided: Specifies the threshold of how relevant must the recommended items be to the user.
165+
166+
Possible values one of: `"low"`, `"medium"`, `"high"`.
167+
168+
The default value is `"low"`, meaning that the system attempts to recommend a number of items equal to *count* at any cost. If there is not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations being appended to reach the full *count*.
169+
This behavior may be suppressed by using `"medium"` or `"high"` values. In such case, the system only recommends items of at least the requested relevance and may return less than *count* items when there is not enough data to fulfill it.
170+
171+
* @param rotationRate **Expert option:** Only usable if the stage corresponds to the one of these recommendation endpoints:
172+
- [Recommend Items To User](https://docs.recombee.com/api#recommend-items-to-user)
173+
- [Recommend Items To Item](https://docs.recombee.com/api#recommend-items-to-item)
174+
- [Recommend Items to Item Segment](https://docs.recombee.com/api#recommend-items-to-item-segment)
175+
- [Recommend Users To User](https://docs.recombee.com/api#recommend-users-to-user)
176+
177+
If the *userId* is provided: If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per request in a backward fashion.
178+
179+
You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example, `rotationRate=0.2` for only slight rotation of recommended items.
180+
181+
* @param rotationTime **Expert option:** Only usable if the stage corresponds to the one of these recommendation endpoints:
182+
- [Recommend Items To User](https://docs.recombee.com/api#recommend-items-to-user)
183+
- [Recommend Items To Item](https://docs.recombee.com/api#recommend-items-to-item)
184+
- [Recommend Items to Item Segment](https://docs.recombee.com/api#recommend-items-to-item-segment)
185+
- [Recommend Users To User](https://docs.recombee.com/api#recommend-users-to-user)
186+
187+
If the *userId* is provided: Taking *rotationRate* into account, specifies how long it takes for an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized.
188+
189+
*/
190+
public class CompositeRecommendationStageParameters(
191+
public val returnProperties: Boolean? = null,
192+
public val includedProperties: List<String>? = null,
193+
public val filter: String? = null,
194+
public val booster: String? = null,
195+
public val logic: Logic? = null,
196+
public val reqlExpressions: Map<String, String>? = null,
197+
public val minRelevance: String? = null,
198+
public val rotationRate: Double? = null,
199+
public val rotationTime: Double? = null): RecombeeBinding() {
200+
}
201+

src/main/kotlin/com/recombee/apiclientkotlin/bindings/Logic.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package com.recombee.apiclientkotlin.bindings
99
* @param settings Parameters passed to the logic
1010
*/
1111
public class Logic(
12-
public val name: String,
12+
public val name: String? = null,
1313
public val settings: Map<String, Any>? = null): RecombeeBinding() {
1414
}
1515

src/main/kotlin/com/recombee/apiclientkotlin/bindings/Recommendation.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ package com.recombee.apiclientkotlin.bindings
44
* Represents a recommended Item / User / Item Segment
55
*
66
* @property id The identifier of the recommended entity.
7+
* @property reqlEvaluations The results of ReQL expressions provided in the request.
78
*/
89
public data class Recommendation(
910
public val id: String,
10-
private val values: Map<String, Any>? = null
11+
private val values: Map<String, Any>? = null,
12+
private val reqlEvaluations: Map<String, Any>? = null,
1113
) : RecombeeBinding() {
1214

1315
/**
@@ -20,4 +22,15 @@ public data class Recommendation(
2022
public fun getValues(): Map<String, Any> {
2123
return values ?: throw IllegalStateException("The request was not meant to return values (use returnProperties parameter)")
2224
}
25+
26+
/**
27+
* Retrieves the evaluations of reqlExpressions for the recommended entity.
28+
*
29+
* @return A map of expression names and their evaluations.
30+
* @throws IllegalStateException if the recommendation contains no reqlEvaluations
31+
* (this means none were sent in the `reqlExpressions` parameter of the request).
32+
*/
33+
public fun getReqlEvaluations(): Map<String, Any> {
34+
return reqlEvaluations ?: throw IllegalStateException("The recommendation contains no ReQL evaluations (reqlExpressions must be provided in the request)")
35+
}
2336
}

src/main/kotlin/com/recombee/apiclientkotlin/requests/AddDetailView.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import com.recombee.apiclientkotlin.bindings.*
1616
* @param cascadeCreate Sets whether the given user/item should be created if not present in the database.
1717
* @param recommId If this detail view is based on a recommendation request, `recommId` is the id of the clicked recommendation.
1818
* @param additionalData A dictionary of additional data for the interaction.
19+
* @param autoPresented Indicates whether the item was automatically presented to the user (e.g., in a swiping feed) or explicitly requested by the user (e.g., by clicking on a link). Defaults to `false`.
1920
*/
2021
public class AddDetailView (
2122
public val userId: String,
@@ -24,7 +25,8 @@ public class AddDetailView (
2425
public val duration: Long? = null,
2526
public val cascadeCreate: Boolean? = true,
2627
public val recommId: String? = null,
27-
public val additionalData: Map<String, Any>? = null
28+
public val additionalData: Map<String, Any>? = null,
29+
public val autoPresented: Boolean? = null
2830
): Request<String>(3000) {
2931

3032
/**
@@ -57,6 +59,7 @@ public class AddDetailView (
5759
cascadeCreate?.let { parameters["cascadeCreate"] = it}
5860
recommId?.let { parameters["recommId"] = it}
5961
additionalData?.let { parameters["additionalData"] = it}
62+
autoPresented?.let { parameters["autoPresented"] = it}
6063
return parameters
6164
}
6265

0 commit comments

Comments
 (0)