Skip to content

Commit 90ef037

Browse files
committed
Support Item Segmentations
1 parent 918ba46 commit 90ef037

File tree

110 files changed

+3950
-324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+3950
-324
lines changed

README.md

+1-1
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>4.0.0</version>
16+
<version>4.1.0</version>
1717
</dependency>
1818
```
1919

pom.xml

+1-1
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>4.0.0</version>
9+
<version>4.1.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

+82-2
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,15 @@
7272
import com.recombee.api_client.api_requests.RecommendNextItems;
7373
import com.recombee.api_client.api_requests.RecommendUsersToUser;
7474
import com.recombee.api_client.api_requests.RecommendUsersToItem;
75+
import com.recombee.api_client.api_requests.RecommendItemSegmentsToUser;
76+
import com.recombee.api_client.api_requests.RecommendItemSegmentsToItem;
77+
import com.recombee.api_client.api_requests.RecommendItemSegmentsToItemSegment;
7578
import com.recombee.api_client.api_requests.SearchItems;
79+
import com.recombee.api_client.api_requests.SearchItemSegments;
7680
import com.recombee.api_client.api_requests.AddSearchSynonym;
7781
import com.recombee.api_client.api_requests.ListSearchSynonyms;
82+
import com.recombee.api_client.api_requests.ListSegmentations;
83+
import com.recombee.api_client.api_requests.GetSegmentation;
7884

7985
/* End of the generated code */
8086
/**
@@ -91,7 +97,7 @@ public class RecombeeClient {
9197

9298
final int BATCH_MAX_SIZE = 10000; //Maximal number of requests within one batch request
9399

94-
final String USER_AGENT = "recombee-java-api-client/4.0.0";
100+
final String USER_AGENT = "recombee-java-api-client/4.1.0";
95101

96102
private final OkHttpClient httpClient = new OkHttpClient();
97103

@@ -417,6 +423,36 @@ public RecommendationResponse send(RecommendUsersToItem request) throws ApiExcep
417423
return null;
418424
}
419425

426+
public RecommendationResponse send(RecommendItemSegmentsToUser request) throws ApiException {
427+
String responseStr = sendRequest(request);
428+
try {
429+
return this.mapper.readValue(responseStr, RecommendationResponse.class);
430+
} catch (IOException e) {
431+
e.printStackTrace();
432+
}
433+
return null;
434+
}
435+
436+
public RecommendationResponse send(RecommendItemSegmentsToItem request) throws ApiException {
437+
String responseStr = sendRequest(request);
438+
try {
439+
return this.mapper.readValue(responseStr, RecommendationResponse.class);
440+
} catch (IOException e) {
441+
e.printStackTrace();
442+
}
443+
return null;
444+
}
445+
446+
public RecommendationResponse send(RecommendItemSegmentsToItemSegment request) throws ApiException {
447+
String responseStr = sendRequest(request);
448+
try {
449+
return this.mapper.readValue(responseStr, RecommendationResponse.class);
450+
} catch (IOException e) {
451+
e.printStackTrace();
452+
}
453+
return null;
454+
}
455+
420456
public SearchResponse send(SearchItems request) throws ApiException {
421457
String responseStr = sendRequest(request);
422458
try {
@@ -427,6 +463,16 @@ public SearchResponse send(SearchItems request) throws ApiException {
427463
return null;
428464
}
429465

466+
public SearchResponse send(SearchItemSegments request) throws ApiException {
467+
String responseStr = sendRequest(request);
468+
try {
469+
return this.mapper.readValue(responseStr, SearchResponse.class);
470+
} catch (IOException e) {
471+
e.printStackTrace();
472+
}
473+
return null;
474+
}
475+
430476
public SearchSynonym send(AddSearchSynonym request) throws ApiException {
431477
String responseStr = sendRequest(request);
432478
try {
@@ -447,6 +493,26 @@ public ListSearchSynonymsResponse send(ListSearchSynonyms request) throws ApiExc
447493
return null;
448494
}
449495

496+
public ListSegmentationsResponse send(ListSegmentations request) throws ApiException {
497+
String responseStr = sendRequest(request);
498+
try {
499+
return this.mapper.readValue(responseStr, ListSegmentationsResponse.class);
500+
} catch (IOException e) {
501+
e.printStackTrace();
502+
}
503+
return null;
504+
}
505+
506+
public Segmentation send(GetSegmentation request) throws ApiException {
507+
String responseStr = sendRequest(request);
508+
try {
509+
return this.mapper.readValue(responseStr, Segmentation.class);
510+
} catch (IOException e) {
511+
e.printStackTrace();
512+
}
513+
return null;
514+
}
515+
450516
/* End of the generated code */
451517

452518
public BatchResponse[] send(Batch batchRequest) throws ApiException {
@@ -522,7 +588,11 @@ else if ((request instanceof RecommendItemsToUser) ||
522588
(request instanceof RecommendUsersToUser) ||
523589
(request instanceof RecommendItemsToItem) ||
524590
(request instanceof RecommendUsersToItem) ||
525-
(request instanceof RecommendNextItems))
591+
(request instanceof RecommendNextItems) ||
592+
(request instanceof RecommendItemSegmentsToUser) ||
593+
(request instanceof RecommendItemSegmentsToItem) ||
594+
(request instanceof RecommendItemSegmentsToItemSegment) ||
595+
(request instanceof SearchItemSegments))
526596
{
527597
parsedResponse = mapper.convertValue(parsedResponse, RecommendationResponse.class);
528598
}
@@ -538,6 +608,10 @@ else if (request instanceof DeleteMoreItems)
538608
{
539609
parsedResponse = mapper.convertValue(parsedResponse, DeleteMoreItemsResponse.class);
540610
}
611+
else if (request instanceof ListSegmentations)
612+
{
613+
parsedResponse = mapper.convertValue(parsedResponse, ListSegmentations.class);
614+
}
541615
/* Start of the generated code */
542616
else if (request instanceof GetItemPropertyInfo)
543617
{
@@ -694,6 +768,12 @@ else if (request instanceof ListUserViewPortions)
694768
for(int j=0;j<ar.length;j++) ar[j] = new ViewPortion(array.get(j));
695769
parsedResponse = ar;
696770
}
771+
772+
else if (request instanceof GetSegmentation)
773+
{
774+
Map<String, Object> obj = (Map<String, Object>) parsedResponse;
775+
parsedResponse = new Segmentation(obj);
776+
}
697777
/* End of the generated code */
698778
}
699779

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import com.recombee.api_client.util.HTTPMethod;
1313

1414
/**
15-
* Adds a bookmark of a given item made by a given user.
15+
* Adds a bookmark of the given item made by the given user.
1616
*/
1717
public class AddBookmark extends Request {
1818

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import com.recombee.api_client.util.HTTPMethod;
1313

1414
/**
15-
* Adds a cart addition of a given item made by a given user.
15+
* Adds a cart addition of the given item made by the given user.
1616
*/
1717
public class AddCartAddition extends Request {
1818

@@ -33,11 +33,11 @@ public class AddCartAddition extends Request {
3333
*/
3434
protected Boolean cascadeCreate;
3535
/**
36-
* Amount (number) added to cart. The default is 1. For example if `user-x` adds two `item-y` during a single order (session...), the `amount` should equal to 2.
36+
* Amount (number) added to cart. The default is 1. For example, if `user-x` adds two `item-y` during a single order (session...), the `amount` should equal 2.
3737
*/
3838
protected Double amount;
3939
/**
40-
* Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
40+
* Price of the added item. If `amount` is greater than 1, the sum of prices of all the items should be given.
4141
*/
4242
protected Double price;
4343
/**
@@ -77,15 +77,15 @@ public AddCartAddition setCascadeCreate(boolean cascadeCreate) {
7777
}
7878

7979
/**
80-
* @param amount Amount (number) added to cart. The default is 1. For example if `user-x` adds two `item-y` during a single order (session...), the `amount` should equal to 2.
80+
* @param amount Amount (number) added to cart. The default is 1. For example, if `user-x` adds two `item-y` during a single order (session...), the `amount` should equal 2.
8181
*/
8282
public AddCartAddition setAmount(double amount) {
8383
this.amount = amount;
8484
return this;
8585
}
8686

8787
/**
88-
* @param price Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
88+
* @param price Price of the added item. If `amount` is greater than 1, the sum of prices of all the items should be given.
8989
*/
9090
public AddCartAddition setPrice(double price) {
9191
this.price = price;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import com.recombee.api_client.util.HTTPMethod;
1313

1414
/**
15-
* Adds a detail view of a given item made by a given user.
15+
* Adds a detail view of the given item made by the given user.
1616
*/
1717
public class AddDetailView extends Request {
1818

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import com.recombee.api_client.util.HTTPMethod;
1313

1414
/**
15-
* Creates new group in the database.
15+
* Creates a new group in the database.
1616
*/
1717
public class AddGroup extends Request {
1818

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
import com.recombee.api_client.util.HTTPMethod;
1313

1414
/**
15-
* Adds new item of given `itemId` to the items catalog.
16-
* All the item properties for the newly created items are set null.
15+
* Adds new item of the given `itemId` to the items catalog.
16+
* All the item properties for the newly created items are set to null.
1717
*/
1818
public class AddItem extends Request {
1919

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
public class AddItemProperty extends Request {
1818

1919
/**
20-
* Name of the item property to be created. Currently, the following names are reserved:`id`, `itemid`, case insensitively. Also, the length of the property name must not exceed 63 characters.
20+
* Name of the item property to be created. Currently, the following names are reserved: `id`, `itemid`, case-insensitively. Also, the length of the property name must not exceed 63 characters.
2121
*/
2222
protected String propertyName;
2323
/**
@@ -35,7 +35,7 @@ public class AddItemProperty extends Request {
3535

3636
/**
3737
* Construct the request
38-
* @param propertyName Name of the item property to be created. Currently, the following names are reserved:`id`, `itemid`, case insensitively. Also, the length of the property name must not exceed 63 characters.
38+
* @param propertyName Name of the item property to be created. Currently, the following names are reserved: `id`, `itemid`, case-insensitively. Also, the length of the property name must not exceed 63 characters.
3939
* @param type Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.
4040
* * `int`- Signed integer number.
4141
* * `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
package com.recombee.api_client.api_requests;
2+
3+
/*
4+
This file is auto-generated, do not edit
5+
*/
6+
7+
import java.util.Date;
8+
import java.util.Map;
9+
import java.util.HashMap;
10+
11+
import com.recombee.api_client.bindings.Logic;
12+
import com.recombee.api_client.util.HTTPMethod;
13+
14+
/**
15+
* Adds a new Segment into a Manual ReQL Segmentation.
16+
* The new Segment is defined by a [ReQL](https://docs.recombee.com/reql.html) filter that returns `true` for an item in case that this item belongs to the segment.
17+
*/
18+
public class AddManualReqlSegment extends Request {
19+
20+
/**
21+
* ID of the Segmentation to which the new Segment should be added
22+
*/
23+
protected String segmentationId;
24+
/**
25+
* ID of the newly created Segment
26+
*/
27+
protected String segmentId;
28+
/**
29+
* ReQL filter that returns `true` for items that belong to this Segment. Otherwise returns `false`.
30+
*/
31+
protected String filter;
32+
/**
33+
* Human-readable name of the Segment that is shown in the Recombee Admin UI.
34+
*/
35+
protected String title;
36+
37+
/**
38+
* Construct the request
39+
* @param segmentationId ID of the Segmentation to which the new Segment should be added
40+
* @param segmentId ID of the newly created Segment
41+
* @param filter ReQL filter that returns `true` for items that belong to this Segment. Otherwise returns `false`.
42+
*/
43+
public AddManualReqlSegment (String segmentationId,String segmentId,String filter) {
44+
this.segmentationId = segmentationId;
45+
this.segmentId = segmentId;
46+
this.filter = filter;
47+
this.timeout = 10000;
48+
}
49+
50+
/**
51+
* @param title Human-readable name of the Segment that is shown in the Recombee Admin UI.
52+
*/
53+
public AddManualReqlSegment setTitle(String title) {
54+
this.title = title;
55+
return this;
56+
}
57+
58+
public String getSegmentationId() {
59+
return this.segmentationId;
60+
}
61+
62+
public String getSegmentId() {
63+
return this.segmentId;
64+
}
65+
66+
public String getFilter() {
67+
return this.filter;
68+
}
69+
70+
public String getTitle() {
71+
return this.title;
72+
}
73+
74+
/**
75+
* @return Used HTTP method
76+
*/
77+
@Override
78+
public HTTPMethod getHTTPMethod() {
79+
return HTTPMethod.PUT;
80+
}
81+
82+
/**
83+
* @return URI to the endpoint including path parameters
84+
*/
85+
@Override
86+
public String getPath() {
87+
return String.format("/segmentations/manual-reql/%s/segments/%s", this.segmentationId,this.segmentId);
88+
}
89+
90+
/**
91+
* Get query parameters
92+
* @return Values of query parameters (name of parameter: value of the parameter)
93+
*/
94+
@Override
95+
public Map<String, Object> getQueryParameters() {
96+
HashMap<String, Object> params = new HashMap<String, Object>();
97+
return params;
98+
}
99+
100+
/**
101+
* Get body parameters
102+
* @return Values of body parameters (name of parameter: value of the parameter)
103+
*/
104+
@Override
105+
public Map<String, Object> getBodyParameters() {
106+
HashMap<String, Object> params = new HashMap<String, Object>();
107+
params.put("filter", this.filter);
108+
if (this.title!=null) {
109+
params.put("title", this.title);
110+
}
111+
return params;
112+
}
113+
114+
}

0 commit comments

Comments
 (0)