Skip to content

Commit 4c8adf8

Browse files
committed
Add recommId parameter to add interaction requests
1 parent 48242ce commit 4c8adf8

File tree

15 files changed

+195
-9
lines changed

15 files changed

+195
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The client is available in the [Maven Central Repository](https://mvnrepository.
1313
<dependency>
1414
<groupId>com.recombee</groupId>
1515
<artifactId>api-client</artifactId>
16-
<version>2.1.1</version>
16+
<version>2.2.0</version>
1717
</dependency>
1818
```
1919

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.recombee</groupId>
88
<artifactId>api-client</artifactId>
9-
<version>2.1.1</version>
9+
<version>2.2.0</version>
1010
<name>Recombee API Client</name>
1111
<description>A client library for easy use of the Recombee recommendation API</description>
1212
<url>http://recombee.com</url>

src/main/java/com/recombee/api_client/RecombeeClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public class RecombeeClient {
8585

8686
final int BATCH_MAX_SIZE = 10000; //Maximal number of requests within one batch request
8787

88-
final String USER_AGENT = "recombee-java-api-client/2.1.1";
88+
final String USER_AGENT = "recombee-java-api-client/2.2.0";
8989

9090
private final OkHttpClient httpClient = new OkHttpClient();
9191

src/main/java/com/recombee/api_client/api_requests/AddBookmark.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public class AddBookmark extends Request {
3131
* Sets whether the given user/item should be created if not present in the database.
3232
*/
3333
protected Boolean cascadeCreate;
34+
/**
35+
* If this bookmark is based on a recommendation request, `recommId` is the id of the clicked recommendation.
36+
*/
37+
protected String recommId;
3438

3539
/**
3640
* Construct the request
@@ -59,6 +63,14 @@ public AddBookmark setCascadeCreate(boolean cascadeCreate) {
5963
return this;
6064
}
6165

66+
/**
67+
* @param recommId If this bookmark is based on a recommendation request, `recommId` is the id of the clicked recommendation.
68+
*/
69+
public AddBookmark setRecommId(String recommId) {
70+
this.recommId = recommId;
71+
return this;
72+
}
73+
6274
public String getUserId() {
6375
return this.userId;
6476
}
@@ -76,6 +88,10 @@ public boolean getCascadeCreate() {
7688
return this.cascadeCreate;
7789
}
7890

91+
public String getRecommId() {
92+
return this.recommId;
93+
}
94+
7995
/**
8096
* @return Used HTTP method
8197
*/
@@ -117,6 +133,9 @@ public Map<String, Object> getBodyParameters() {
117133
if (this.cascadeCreate!=null) {
118134
params.put("cascadeCreate", this.cascadeCreate);
119135
}
136+
if (this.recommId!=null) {
137+
params.put("recommId", this.recommId);
138+
}
120139
return params;
121140
}
122141

src/main/java/com/recombee/api_client/api_requests/AddCartAddition.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public class AddCartAddition extends Request {
3939
* Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
4040
*/
4141
protected Double price;
42+
/**
43+
* If this cart addition is based on a recommendation request, `recommId` is the id of the clicked recommendation.
44+
*/
45+
protected String recommId;
4246

4347
/**
4448
* Construct the request
@@ -83,6 +87,14 @@ public AddCartAddition setPrice(double price) {
8387
return this;
8488
}
8589

90+
/**
91+
* @param recommId If this cart addition is based on a recommendation request, `recommId` is the id of the clicked recommendation.
92+
*/
93+
public AddCartAddition setRecommId(String recommId) {
94+
this.recommId = recommId;
95+
return this;
96+
}
97+
8698
public String getUserId() {
8799
return this.userId;
88100
}
@@ -108,6 +120,10 @@ public double getPrice() {
108120
return this.price;
109121
}
110122

123+
public String getRecommId() {
124+
return this.recommId;
125+
}
126+
111127
/**
112128
* @return Used HTTP method
113129
*/
@@ -155,6 +171,9 @@ public Map<String, Object> getBodyParameters() {
155171
if (this.price!=null) {
156172
params.put("price", this.price);
157173
}
174+
if (this.recommId!=null) {
175+
params.put("recommId", this.recommId);
176+
}
158177
return params;
159178
}
160179

src/main/java/com/recombee/api_client/api_requests/AddDetailView.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public class AddDetailView extends Request {
3535
* Sets whether the given user/item should be created if not present in the database.
3636
*/
3737
protected Boolean cascadeCreate;
38+
/**
39+
* If this detail view is based on a recommendation request, `recommId` is the id of the clicked recommendation.
40+
*/
41+
protected String recommId;
3842

3943
/**
4044
* Construct the request
@@ -71,6 +75,14 @@ public AddDetailView setCascadeCreate(boolean cascadeCreate) {
7175
return this;
7276
}
7377

78+
/**
79+
* @param recommId If this detail view is based on a recommendation request, `recommId` is the id of the clicked recommendation.
80+
*/
81+
public AddDetailView setRecommId(String recommId) {
82+
this.recommId = recommId;
83+
return this;
84+
}
85+
7486
public String getUserId() {
7587
return this.userId;
7688
}
@@ -92,6 +104,10 @@ public boolean getCascadeCreate() {
92104
return this.cascadeCreate;
93105
}
94106

107+
public String getRecommId() {
108+
return this.recommId;
109+
}
110+
95111
/**
96112
* @return Used HTTP method
97113
*/
@@ -136,6 +152,9 @@ public Map<String, Object> getBodyParameters() {
136152
if (this.cascadeCreate!=null) {
137153
params.put("cascadeCreate", this.cascadeCreate);
138154
}
155+
if (this.recommId!=null) {
156+
params.put("recommId", this.recommId);
157+
}
139158
return params;
140159
}
141160

src/main/java/com/recombee/api_client/api_requests/AddPurchase.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public class AddPurchase extends Request {
4343
* Your profit from the purchased item. The profit is natural in e-commerce domain (for example if `user-x` purchases `item-y` for $100 and the gross margin is 30 %, then the profit is $30), but is applicable also in other domains (for example at a news company it may be income from displayed advertisement on article page). If `amount` is greater than 1, sum of profit of all the items should be given.
4444
*/
4545
protected Double profit;
46+
/**
47+
* If this purchase is based on a recommendation request, `recommId` is the id of the clicked recommendation.
48+
*/
49+
protected String recommId;
4650

4751
/**
4852
* Construct the request
@@ -95,6 +99,14 @@ public AddPurchase setProfit(double profit) {
9599
return this;
96100
}
97101

102+
/**
103+
* @param recommId If this purchase is based on a recommendation request, `recommId` is the id of the clicked recommendation.
104+
*/
105+
public AddPurchase setRecommId(String recommId) {
106+
this.recommId = recommId;
107+
return this;
108+
}
109+
98110
public String getUserId() {
99111
return this.userId;
100112
}
@@ -124,6 +136,10 @@ public double getProfit() {
124136
return this.profit;
125137
}
126138

139+
public String getRecommId() {
140+
return this.recommId;
141+
}
142+
127143
/**
128144
* @return Used HTTP method
129145
*/
@@ -174,6 +190,9 @@ public Map<String, Object> getBodyParameters() {
174190
if (this.profit!=null) {
175191
params.put("profit", this.profit);
176192
}
193+
if (this.recommId!=null) {
194+
params.put("recommId", this.recommId);
195+
}
177196
return params;
178197
}
179198

src/main/java/com/recombee/api_client/api_requests/AddRating.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public class AddRating extends Request {
3535
* Sets whether the given user/item should be created if not present in the database.
3636
*/
3737
protected Boolean cascadeCreate;
38+
/**
39+
* If this rating is based on a recommendation request, `recommId` is the id of the clicked recommendation.
40+
*/
41+
protected String recommId;
3842

3943
/**
4044
* Construct the request
@@ -65,6 +69,14 @@ public AddRating setCascadeCreate(boolean cascadeCreate) {
6569
return this;
6670
}
6771

72+
/**
73+
* @param recommId If this rating is based on a recommendation request, `recommId` is the id of the clicked recommendation.
74+
*/
75+
public AddRating setRecommId(String recommId) {
76+
this.recommId = recommId;
77+
return this;
78+
}
79+
6880
public String getUserId() {
6981
return this.userId;
7082
}
@@ -86,6 +98,10 @@ public boolean getCascadeCreate() {
8698
return this.cascadeCreate;
8799
}
88100

101+
public String getRecommId() {
102+
return this.recommId;
103+
}
104+
89105
/**
90106
* @return Used HTTP method
91107
*/
@@ -128,6 +144,9 @@ public Map<String, Object> getBodyParameters() {
128144
if (this.cascadeCreate!=null) {
129145
params.put("cascadeCreate", this.cascadeCreate);
130146
}
147+
if (this.recommId!=null) {
148+
params.put("recommId", this.recommId);
149+
}
131150
return params;
132151
}
133152

src/main/java/com/recombee/api_client/api_requests/SetViewPortion.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public class SetViewPortion extends Request {
4040
* Sets whether the given user/item should be created if not present in the database.
4141
*/
4242
protected Boolean cascadeCreate;
43+
/**
44+
* If this view portion is based on a recommendation request, `recommId` is the id of the clicked recommendation.
45+
*/
46+
protected String recommId;
4347

4448
/**
4549
* Construct the request
@@ -78,6 +82,14 @@ public SetViewPortion setCascadeCreate(boolean cascadeCreate) {
7882
return this;
7983
}
8084

85+
/**
86+
* @param recommId If this view portion is based on a recommendation request, `recommId` is the id of the clicked recommendation.
87+
*/
88+
public SetViewPortion setRecommId(String recommId) {
89+
this.recommId = recommId;
90+
return this;
91+
}
92+
8193
public String getUserId() {
8294
return this.userId;
8395
}
@@ -103,6 +115,10 @@ public boolean getCascadeCreate() {
103115
return this.cascadeCreate;
104116
}
105117

118+
public String getRecommId() {
119+
return this.recommId;
120+
}
121+
106122
/**
107123
* @return Used HTTP method
108124
*/
@@ -148,6 +164,9 @@ public Map<String, Object> getBodyParameters() {
148164
if (this.cascadeCreate!=null) {
149165
params.put("cascadeCreate", this.cascadeCreate);
150166
}
167+
if (this.recommId!=null) {
168+
params.put("recommId", this.recommId);
169+
}
151170
return params;
152171
}
153172

src/main/java/com/recombee/api_client/bindings/Bookmark.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,24 @@ public class Bookmark extends RecombeeBinding {
2222
* UTC timestamp of the bookmark as ISO8601-1 pattern or UTC epoch time. The default value is the current time.
2323
*/
2424
protected Date timestamp;
25+
/**
26+
* If this bookmark is based on a recommendation request, `recommId` is the id of the clicked recommendation.
27+
*/
28+
protected String recommId;
2529

2630
public Bookmark () {}
2731

28-
public Bookmark (String userId,String itemId,Date timestamp) {
32+
public Bookmark (String userId,String itemId,Date timestamp,String recommId) {
2933
this.userId = userId;
3034
this.itemId = itemId;
3135
this.timestamp = timestamp;
36+
this.recommId = recommId;
3237
}
3338

3439
public Bookmark (Map<String, Object> jsonObject) {
3540
this.userId = (String) jsonObject.get("userId");
3641
this.itemId = (String) jsonObject.get("itemId");
42+
this.recommId = (String) jsonObject.get("recommId");
3743
Double epoch = 1000*(Double)jsonObject.get("timestamp");
3844
this.timestamp = new Date(epoch.longValue());
3945
}
@@ -55,12 +61,17 @@ public Date getTimestamp() {
5561
return this.timestamp;
5662
}
5763

64+
public String getRecommId() {
65+
return this.recommId;
66+
}
67+
5868
@Override
5969
public int hashCode() {
6070
return new HashCodeBuilder(17, 31).
6171
append(this.userId).
6272
append(this.itemId).
6373
append(this.timestamp).
74+
append(this.recommId).
6475
toHashCode();
6576
}
6677

@@ -76,6 +87,7 @@ public boolean equals(Object obj) {
7687
append(this.userId, rhs.userId).
7788
append(this.itemId, rhs.itemId).
7889
append(this.timestamp, rhs.timestamp).
90+
append(this.recommId, rhs.recommId).
7991
isEquals();
8092
}
8193
}

0 commit comments

Comments
 (0)