Skip to content

Commit 26e5434

Browse files
committed
Update README: Library is now available in the Maven Central Repository
1 parent fa5a410 commit 26e5434

File tree

2 files changed

+33
-24
lines changed

2 files changed

+33
-24
lines changed

README.md

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ Documentation of the API can be found at [docs.recombee.com](https://docs.recomb
88

99
## Installation
1010

11-
The client will available in the Maven Central Repository in the upcoming days.
11+
The client is available in the [Maven Central Repository](https://mvnrepository.com/artifact/com.recombee/apiclientkotlin/), so you just need to add the following entry to your gradle.build file:
12+
13+
```gradle
14+
repositories {
15+
mavenCentral()
16+
}
17+
18+
dependencies {
19+
implementation "com.recombee.apiclientkotlin:4.1.0"
20+
}
21+
```
1222

1323
## How to use
1424

@@ -24,6 +34,7 @@ It is intentionally not possible to change the item catalog (properties of items
2434
```kotlin
2535
import com.recombee.apiclientkotlin.RecombeeClient
2636
import com.recombee.apiclientkotlin.util.Region
37+
import com.recombee.apiclientkotlin.exceptions.ApiException
2738
import com.recombee.apiclientkotlin.requests.*
2839

2940

@@ -35,12 +46,12 @@ val client = RecombeeClient(
3546
)
3647

3748
// Interactions take the ID of the user and the ID of the item
38-
client.send(AddBookmark("user-13434", "item-256"))
39-
client.send(AddCartAddition("user-4395", "item-129"))
40-
client.send(AddDetailView("user-9318", "item-108"))
41-
client.send(AddPurchase("user-7499", "item-750"))
42-
client.send(AddRating("user-3967", "item-365", 0.5))
43-
client.send(SetViewPortion("user-4289", "item-487", 0.3))
49+
client.send(AddBookmark(userId = "user-13434", itemId = "item-256"))
50+
client.send(AddCartAddition(userId = "user-4395", itemId = "item-129"))
51+
client.send(AddDetailView(userId = "user-9318", itemId = "item-108"))
52+
client.send(AddPurchase(userId = "user-7499", itemId = "item-750"))
53+
client.send(AddRating(userId = "user-3967", itemId = "item-365", rating = 0.5))
54+
client.send(SetViewPortion(userId = "user-4289", itemId = "item-487", portion = 0.3))
4455
```
4556

4657
### Requesting recommendations
@@ -60,17 +71,16 @@ There are two callbacks (both are optional):
6071
val request = RecommendItemsToUser(
6172
userId = "user-x",
6273
count = 10,
63-
scenario = "homepage-for-you",
64-
returnProperties = true
74+
scenario = "homepage-for-you"
6575
)
6676

6777
client.send(request,
68-
{ recommendationResponse -> // response of type RecommendationResponse
78+
{ recommendationResponse: RecommendationResponse ->
6979
for (recommendedItem in recommendationResponse.recomms) {
70-
println("ID: ${recommendedItem.id} Values: ${recommendedItem.getValues()}")
80+
println("ID: ${recommendedItem.id}")
7181
}
7282
},
73-
{ exception ->
83+
{ exception: ApiException ->
7484
println("Exception: $exception")
7585
// use fallback ...
7686
}
@@ -86,17 +96,16 @@ client.send(request,
8696
val request = RecommendItemsToUser(
8797
userId = "user-x",
8898
count = 10,
89-
scenario = "homepage-for-you",
90-
returnProperties = true
99+
scenario = "homepage-for-you"
91100
)
92101

93102
val result = client.sendAsync(request)
94103

95-
result.onSuccess { recommendationResponse ->
104+
result.onSuccess { recommendationResponse: RecommendationResponse ->
96105
for (recommendedItem in recommendationResponse.recomms) {
97-
println("ID: ${recommendedItem.id} Values: ${recommendedItem.getValues()}")
106+
println("ID: ${recommendedItem.id}")
98107
}
99-
}.onFailure { exception ->
108+
}.onFailure { exception -> // ApiException
100109
println("Exception: $exception")
101110
// use fallback ...
102111
}
@@ -119,12 +128,12 @@ val request = SearchItems(
119128
)
120129

121130
client.send(request,
122-
{ searchResponse -> // response of type SearchResponse
131+
{ searchResponse: SearchResponse ->
123132
for (recommendedItem in searchResponse.recomms) {
124133
println("ID: ${recommendedItem.id} Values: ${recommendedItem.getValues()}")
125134
}
126135
},
127-
{ exception ->
136+
{ exception: ApiException ->
128137
println("Exception: $exception")
129138
// use fallback ...
130139
}
@@ -147,11 +156,11 @@ val request = SearchItems(
147156

148157
val result = client.sendAsync(request)
149158

150-
result.onSuccess { searchResponse ->
159+
result.onSuccess { searchResponse: SearchResponse ->
151160
for (recommendedItem in searchResponse.recomms) {
152161
println("ID: ${recommendedItem.id} Values: ${recommendedItem.getValues()}")
153162
}
154-
}.onFailure { exception ->
163+
}.onFailure { exception -> // ApiException
155164
println("Exception: $exception")
156165
// use fallback ...
157166
}
@@ -163,10 +172,10 @@ Recombee can return items that shall be shown to a user as next recommendations
163172

164173
```kotlin
165174
client.sendAsync(RecommendItemsToUser("user-1", 5))
166-
.onSuccess { firstResponse ->
175+
.onSuccess { firstResponse: RecommendationResponse ->
167176

168177
client.sendAsync(RecommendNextItems(firstResponse.recommId, 5))
169-
.onSuccess { secondResponse ->
178+
.onSuccess { secondResponse: RecommendationResponse ->
170179
// Show next recommendations
171180
}
172181
}

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,4 @@ signing {
132132
} else {
133133
println("Signing properties not found, skipping signing configuration.")
134134
}
135-
}
135+
}

0 commit comments

Comments
 (0)