Skip to content

Commit d062549

Browse files
committed
Support Item Segmentations
1 parent ef84cf3 commit d062549

File tree

119 files changed

+3287
-191
lines changed

Some content is hidden

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

119 files changed

+3287
-191
lines changed

Diff for: lib/api-client.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ApiClient {
4545
url: url,
4646
headers: {'Accept': 'application/json',
4747
'Content-Type': 'application/json',
48-
'User-Agent': 'recombee-node-api-client/4.0.0'},
48+
'User-Agent': 'recombee-node-api-client/4.1.0'},
4949
timeout: request.timeout,
5050
agent: this.options.agent
5151
};

Diff for: lib/requests/add-bookmark.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
const rqs = require("./request");
77

88
/**
9-
* Adds a bookmark of a given item made by a given user.
9+
* Adds a bookmark of the given item made by the given user.
1010
*/
1111
class AddBookmark extends rqs.Request {
1212

Diff for: lib/requests/add-cart-addition.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
const rqs = require("./request");
77

88
/**
9-
* Adds a cart addition of a given item made by a given user.
9+
* Adds a cart addition of the given item made by the given user.
1010
*/
1111
class AddCartAddition extends rqs.Request {
1212

@@ -24,10 +24,10 @@ class AddCartAddition extends rqs.Request {
2424
* - Description: Sets whether the given user/item should be created if not present in the database.
2525
* - *amount*
2626
* - Type: number
27-
* - Description: 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.
27+
* - Description: 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.
2828
* - *price*
2929
* - Type: number
30-
* - Description: Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
30+
* - Description: Price of the added item. If `amount` is greater than 1, the sum of prices of all the items should be given.
3131
* - *recommId*
3232
* - Type: string
3333
* - Description: If this cart addition is based on a recommendation request, `recommId` is the id of the clicked recommendation.

Diff for: lib/requests/add-detail-view.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
const rqs = require("./request");
77

88
/**
9-
* Adds a detail view of a given item made by a given user.
9+
* Adds a detail view of the given item made by the given user.
1010
*/
1111
class AddDetailView extends rqs.Request {
1212

Diff for: lib/requests/add-group.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
const rqs = require("./request");
77

88
/**
9-
* Creates new group in the database.
9+
* Creates a new group in the database.
1010
*/
1111
class AddGroup extends rqs.Request {
1212

Diff for: lib/requests/add-item-property.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class AddItemProperty extends rqs.Request {
1212

1313
/**
1414
* Construct the request
15-
* @param {string} 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.
15+
* @param {string} 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.
1616
* @param {string} type - Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.
1717
* * `int`- Signed integer number.
1818
* * `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).

Diff for: lib/requests/add-item.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
const rqs = require("./request");
77

88
/**
9-
* Adds new item of given `itemId` to the items catalog.
10-
* All the item properties for the newly created items are set null.
9+
* Adds new item of the given `itemId` to the items catalog.
10+
* All the item properties for the newly created items are set to null.
1111
*/
1212
class AddItem extends rqs.Request {
1313

Diff for: lib/requests/add-manual-reql-segment.js

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
This file is auto-generated, do not edit
3+
*/
4+
5+
'use strict';
6+
const rqs = require("./request");
7+
8+
/**
9+
* Adds a new Segment into a Manual ReQL Segmentation.
10+
* 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.
11+
*/
12+
class AddManualReqlSegment extends rqs.Request {
13+
14+
/**
15+
* Construct the request
16+
* @param {string} segmentationId - ID of the Segmentation to which the new Segment should be added
17+
* @param {string} segmentId - ID of the newly created Segment
18+
* @param {string} filter - ReQL filter that returns `true` for items that belong to this Segment. Otherwise returns `false`.
19+
* @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value
20+
* - Allowed parameters:
21+
* - *title*
22+
* - Type: string
23+
* - Description: Human-readable name of the Segment that is shown in the Recombee Admin UI.
24+
*/
25+
constructor(segmentationId, segmentId, filter, optional) {
26+
super('PUT', `/segmentations/manual-reql/${segmentationId}/segments/${segmentId}`, 10000, false);
27+
this.segmentationId = segmentationId;
28+
this.segmentId = segmentId;
29+
this.filter = filter;
30+
optional = optional || {};
31+
this.title = optional.title;
32+
}
33+
34+
/**
35+
* Get body parameters
36+
* @return {Object} The values of body parameters (name of parameter: value of the parameter)
37+
*/
38+
bodyParameters() {
39+
let params = {};
40+
params.filter = this.filter;
41+
42+
if(this.title !== undefined)
43+
params.title = this.title;
44+
45+
return params;
46+
}
47+
48+
/**
49+
* Get query parameters
50+
* @return {Object} The values of query parameters (name of parameter: value of the parameter)
51+
*/
52+
queryParameters() {
53+
let params = {};
54+
return params;
55+
}
56+
}
57+
58+
exports.AddManualReqlSegment = AddManualReqlSegment

Diff for: lib/requests/add-purchase.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
const rqs = require("./request");
77

88
/**
9-
* Adds a purchase of a given item made by a given user.
9+
* Adds a purchase of the given item made by the given user.
1010
*/
1111
class AddPurchase extends rqs.Request {
1212

@@ -24,13 +24,13 @@ class AddPurchase extends rqs.Request {
2424
* - Description: Sets whether the given user/item should be created if not present in the database.
2525
* - *amount*
2626
* - Type: number
27-
* - Description: Amount (number) of purchased items. The default is 1. For example if `user-x` purchases two `item-y` during a single order (session...), the `amount` should equal to 2.
27+
* - Description: Amount (number) of purchased items. The default is 1. For example, if `user-x` purchases two `item-y` during a single order (session...), the `amount` should equal 2.
2828
* - *price*
2929
* - Type: number
30-
* - Description: Price paid by the user for the item. If `amount` is greater than 1, sum of prices of all the items should be given.
30+
* - Description: Price paid by the user for the item. If `amount` is greater than 1, the sum of prices of all the items should be given.
3131
* - *profit*
3232
* - Type: number
33-
* - Description: 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.
33+
* - Description: Your profit from the purchased item. The profit is natural in the 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 also applicable in other domains (for example, at a news company it may be income from a displayed advertisement on article page). If `amount` is greater than 1, the sum of profit of all the items should be given.
3434
* - *recommId*
3535
* - Type: string
3636
* - Description: If this purchase is based on a recommendation request, `recommId` is the id of the clicked recommendation.

Diff for: lib/requests/add-rating.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
const rqs = require("./request");
77

88
/**
9-
* Adds a rating of given item made by a given user.
9+
* Adds a rating of the given item made by the given user.
1010
*/
1111
class AddRating extends rqs.Request {
1212

Diff for: lib/requests/add-series.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
const rqs = require("./request");
77

88
/**
9-
* Creates new series in the database.
9+
* Creates a new series in the database.
1010
*/
1111
class AddSeries extends rqs.Request {
1212

Diff for: lib/requests/add-user-property.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
const rqs = require("./request");
77

88
/**
9-
* Adding an user property is somehow equivalent to adding a column to the table of users. The users may be characterized by various properties of different types.
9+
* Adding a user property is somehow equivalent to adding a column to the table of users. The users may be characterized by various properties of different types.
1010
*/
1111
class AddUserProperty extends rqs.Request {
1212

1313
/**
1414
* Construct the request
15-
* @param {string} propertyName - Name of the user property to be created. Currently, the following names are reserved:`id`, `userid`, case insensitively. Also, the length of the property name must not exceed 63 characters.
15+
* @param {string} propertyName - Name of the user property to be created. Currently, the following names are reserved: `id`, `userid`, case-insensitively. Also, the length of the property name must not exceed 63 characters.
1616
* @param {string} type - Value type of the user property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`.
1717
* * `int` - Signed integer number.
1818
* * `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).

Diff for: lib/requests/create-auto-reql-segmentation.js

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
This file is auto-generated, do not edit
3+
*/
4+
5+
'use strict';
6+
const rqs = require("./request");
7+
8+
/**
9+
* Segment the items using a [ReQL](https://docs.recombee.com/reql.html) expression.
10+
* For each item, the expression should return a set that contains IDs of segments to which the item belongs to.
11+
*/
12+
class CreateAutoReqlSegmentation extends rqs.Request {
13+
14+
/**
15+
* Construct the request
16+
* @param {string} segmentationId - ID of the newly created Segmentation
17+
* @param {string} sourceType - What type of data should be segmented. Currently only `items` are supported.
18+
* @param {string} expression - ReQL expression that returns for each item a set with IDs of segments to which the item belongs
19+
* @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value
20+
* - Allowed parameters:
21+
* - *title*
22+
* - Type: string
23+
* - Description: Human-readable name that is shown in the Recombee Admin UI.
24+
* - *description*
25+
* - Type: string
26+
* - Description: Description that is shown in the Recombee Admin UI.
27+
*/
28+
constructor(segmentationId, sourceType, expression, optional) {
29+
super('PUT', `/segmentations/auto-reql/${segmentationId}`, 10000, false);
30+
this.segmentationId = segmentationId;
31+
this.sourceType = sourceType;
32+
this.expression = expression;
33+
optional = optional || {};
34+
this.title = optional.title;
35+
this.description = optional.description;
36+
}
37+
38+
/**
39+
* Get body parameters
40+
* @return {Object} The values of body parameters (name of parameter: value of the parameter)
41+
*/
42+
bodyParameters() {
43+
let params = {};
44+
params.sourceType = this.sourceType;
45+
params.expression = this.expression;
46+
47+
if(this.title !== undefined)
48+
params.title = this.title;
49+
50+
if(this.description !== undefined)
51+
params.description = this.description;
52+
53+
return params;
54+
}
55+
56+
/**
57+
* Get query parameters
58+
* @return {Object} The values of query parameters (name of parameter: value of the parameter)
59+
*/
60+
queryParameters() {
61+
let params = {};
62+
return params;
63+
}
64+
}
65+
66+
exports.CreateAutoReqlSegmentation = CreateAutoReqlSegmentation

Diff for: lib/requests/create-manual-reql-segmentation.js

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
This file is auto-generated, do not edit
3+
*/
4+
5+
'use strict';
6+
const rqs = require("./request");
7+
8+
/**
9+
* Segment the items using multiple [ReQL](https://docs.recombee.com/reql.html) filters.
10+
* Use the Add Manual ReQL Items Segment endpoint to create the individual segments.
11+
*/
12+
class CreateManualReqlSegmentation extends rqs.Request {
13+
14+
/**
15+
* Construct the request
16+
* @param {string} segmentationId - ID of the newly created Segmentation
17+
* @param {string} sourceType - What type of data should be segmented. Currently only `items` are supported.
18+
* @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value
19+
* - Allowed parameters:
20+
* - *title*
21+
* - Type: string
22+
* - Description: Human-readable name that is shown in the Recombee Admin UI.
23+
* - *description*
24+
* - Type: string
25+
* - Description: Description that is shown in the Recombee Admin UI.
26+
*/
27+
constructor(segmentationId, sourceType, optional) {
28+
super('PUT', `/segmentations/manual-reql/${segmentationId}`, 10000, false);
29+
this.segmentationId = segmentationId;
30+
this.sourceType = sourceType;
31+
optional = optional || {};
32+
this.title = optional.title;
33+
this.description = optional.description;
34+
}
35+
36+
/**
37+
* Get body parameters
38+
* @return {Object} The values of body parameters (name of parameter: value of the parameter)
39+
*/
40+
bodyParameters() {
41+
let params = {};
42+
params.sourceType = this.sourceType;
43+
44+
if(this.title !== undefined)
45+
params.title = this.title;
46+
47+
if(this.description !== undefined)
48+
params.description = this.description;
49+
50+
return params;
51+
}
52+
53+
/**
54+
* Get query parameters
55+
* @return {Object} The values of query parameters (name of parameter: value of the parameter)
56+
*/
57+
queryParameters() {
58+
let params = {};
59+
return params;
60+
}
61+
}
62+
63+
exports.CreateManualReqlSegmentation = CreateManualReqlSegmentation

Diff for: lib/requests/create-property-based-segmentation.js

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
This file is auto-generated, do not edit
3+
*/
4+
5+
'use strict';
6+
const rqs = require("./request");
7+
8+
/**
9+
* Creates a Segmentation that splits the items into segments based on values of a particular item property.
10+
* A segment is created for each unique value of the property.
11+
* In case of `set` properties, a segment is created for each value in the set. Item belongs to all these segments.
12+
*/
13+
class CreatePropertyBasedSegmentation extends rqs.Request {
14+
15+
/**
16+
* Construct the request
17+
* @param {string} segmentationId - ID of the newly created Segmentation
18+
* @param {string} sourceType - What type of data should be segmented. Currently only `items` are supported.
19+
* @param {string} propertyName - Name of the property on which the Segmentation should be based
20+
* @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value
21+
* - Allowed parameters:
22+
* - *title*
23+
* - Type: string
24+
* - Description: Human-readable name that is shown in the Recombee Admin UI.
25+
* - *description*
26+
* - Type: string
27+
* - Description: Description that is shown in the Recombee Admin UI.
28+
*/
29+
constructor(segmentationId, sourceType, propertyName, optional) {
30+
super('PUT', `/segmentations/property-based/${segmentationId}`, 10000, false);
31+
this.segmentationId = segmentationId;
32+
this.sourceType = sourceType;
33+
this.propertyName = propertyName;
34+
optional = optional || {};
35+
this.title = optional.title;
36+
this.description = optional.description;
37+
}
38+
39+
/**
40+
* Get body parameters
41+
* @return {Object} The values of body parameters (name of parameter: value of the parameter)
42+
*/
43+
bodyParameters() {
44+
let params = {};
45+
params.sourceType = this.sourceType;
46+
params.propertyName = this.propertyName;
47+
48+
if(this.title !== undefined)
49+
params.title = this.title;
50+
51+
if(this.description !== undefined)
52+
params.description = this.description;
53+
54+
return params;
55+
}
56+
57+
/**
58+
* Get query parameters
59+
* @return {Object} The values of query parameters (name of parameter: value of the parameter)
60+
*/
61+
queryParameters() {
62+
let params = {};
63+
return params;
64+
}
65+
}
66+
67+
exports.CreatePropertyBasedSegmentation = CreatePropertyBasedSegmentation

0 commit comments

Comments
 (0)