Skip to content

Commit

Permalink
Support Item Segmentations
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraFiedler committed Jan 10, 2023
1 parent ef84cf3 commit d062549
Show file tree
Hide file tree
Showing 119 changed files with 3,287 additions and 191 deletions.
2 changes: 1 addition & 1 deletion lib/api-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ApiClient {
url: url,
headers: {'Accept': 'application/json',
'Content-Type': 'application/json',
'User-Agent': 'recombee-node-api-client/4.0.0'},
'User-Agent': 'recombee-node-api-client/4.1.0'},
timeout: request.timeout,
agent: this.options.agent
};
Expand Down
2 changes: 1 addition & 1 deletion lib/requests/add-bookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const rqs = require("./request");

/**
* Adds a bookmark of a given item made by a given user.
* Adds a bookmark of the given item made by the given user.
*/
class AddBookmark extends rqs.Request {

Expand Down
6 changes: 3 additions & 3 deletions lib/requests/add-cart-addition.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const rqs = require("./request");

/**
* Adds a cart addition of a given item made by a given user.
* Adds a cart addition of the given item made by the given user.
*/
class AddCartAddition extends rqs.Request {

Expand All @@ -24,10 +24,10 @@ class AddCartAddition extends rqs.Request {
* - Description: Sets whether the given user/item should be created if not present in the database.
* - *amount*
* - Type: number
* - 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.
* - 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.
* - *price*
* - Type: number
* - Description: Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
* - Description: Price of the added item. If `amount` is greater than 1, the sum of prices of all the items should be given.
* - *recommId*
* - Type: string
* - Description: If this cart addition is based on a recommendation request, `recommId` is the id of the clicked recommendation.
Expand Down
2 changes: 1 addition & 1 deletion lib/requests/add-detail-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const rqs = require("./request");

/**
* Adds a detail view of a given item made by a given user.
* Adds a detail view of the given item made by the given user.
*/
class AddDetailView extends rqs.Request {

Expand Down
2 changes: 1 addition & 1 deletion lib/requests/add-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const rqs = require("./request");

/**
* Creates new group in the database.
* Creates a new group in the database.
*/
class AddGroup extends rqs.Request {

Expand Down
2 changes: 1 addition & 1 deletion lib/requests/add-item-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AddItemProperty extends rqs.Request {

/**
* Construct the request
* @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.
* @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.
* @param {string} type - Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.
* * `int`- Signed integer number.
* * `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
Expand Down
4 changes: 2 additions & 2 deletions lib/requests/add-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
const rqs = require("./request");

/**
* Adds new item of given `itemId` to the items catalog.
* All the item properties for the newly created items are set null.
* Adds new item of the given `itemId` to the items catalog.
* All the item properties for the newly created items are set to null.
*/
class AddItem extends rqs.Request {

Expand Down
58 changes: 58 additions & 0 deletions lib/requests/add-manual-reql-segment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
This file is auto-generated, do not edit
*/

'use strict';
const rqs = require("./request");

/**
* Adds a new Segment into a Manual ReQL Segmentation.
* 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.
*/
class AddManualReqlSegment extends rqs.Request {

/**
* Construct the request
* @param {string} segmentationId - ID of the Segmentation to which the new Segment should be added
* @param {string} segmentId - ID of the newly created Segment
* @param {string} filter - ReQL filter that returns `true` for items that belong to this Segment. Otherwise returns `false`.
* @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value
* - Allowed parameters:
* - *title*
* - Type: string
* - Description: Human-readable name of the Segment that is shown in the Recombee Admin UI.
*/
constructor(segmentationId, segmentId, filter, optional) {
super('PUT', `/segmentations/manual-reql/${segmentationId}/segments/${segmentId}`, 10000, false);
this.segmentationId = segmentationId;
this.segmentId = segmentId;
this.filter = filter;
optional = optional || {};
this.title = optional.title;
}

/**
* Get body parameters
* @return {Object} The values of body parameters (name of parameter: value of the parameter)
*/
bodyParameters() {
let params = {};
params.filter = this.filter;

if(this.title !== undefined)
params.title = this.title;

return params;
}

/**
* Get query parameters
* @return {Object} The values of query parameters (name of parameter: value of the parameter)
*/
queryParameters() {
let params = {};
return params;
}
}

exports.AddManualReqlSegment = AddManualReqlSegment
8 changes: 4 additions & 4 deletions lib/requests/add-purchase.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const rqs = require("./request");

/**
* Adds a purchase of a given item made by a given user.
* Adds a purchase of the given item made by the given user.
*/
class AddPurchase extends rqs.Request {

Expand All @@ -24,13 +24,13 @@ class AddPurchase extends rqs.Request {
* - Description: Sets whether the given user/item should be created if not present in the database.
* - *amount*
* - Type: number
* - 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.
* - 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.
* - *price*
* - Type: number
* - 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.
* - 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.
* - *profit*
* - Type: number
* - 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.
* - 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.
* - *recommId*
* - Type: string
* - Description: If this purchase is based on a recommendation request, `recommId` is the id of the clicked recommendation.
Expand Down
2 changes: 1 addition & 1 deletion lib/requests/add-rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const rqs = require("./request");

/**
* Adds a rating of given item made by a given user.
* Adds a rating of the given item made by the given user.
*/
class AddRating extends rqs.Request {

Expand Down
2 changes: 1 addition & 1 deletion lib/requests/add-series.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const rqs = require("./request");

/**
* Creates new series in the database.
* Creates a new series in the database.
*/
class AddSeries extends rqs.Request {

Expand Down
4 changes: 2 additions & 2 deletions lib/requests/add-user-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
const rqs = require("./request");

/**
* 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.
* 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.
*/
class AddUserProperty extends rqs.Request {

/**
* Construct the request
* @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.
* @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.
* @param {string} type - Value type of the user property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`.
* * `int` - Signed integer number.
* * `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
Expand Down
66 changes: 66 additions & 0 deletions lib/requests/create-auto-reql-segmentation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
This file is auto-generated, do not edit
*/

'use strict';
const rqs = require("./request");

/**
* Segment the items using a [ReQL](https://docs.recombee.com/reql.html) expression.
* For each item, the expression should return a set that contains IDs of segments to which the item belongs to.
*/
class CreateAutoReqlSegmentation extends rqs.Request {

/**
* Construct the request
* @param {string} segmentationId - ID of the newly created Segmentation
* @param {string} sourceType - What type of data should be segmented. Currently only `items` are supported.
* @param {string} expression - ReQL expression that returns for each item a set with IDs of segments to which the item belongs
* @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value
* - Allowed parameters:
* - *title*
* - Type: string
* - Description: Human-readable name that is shown in the Recombee Admin UI.
* - *description*
* - Type: string
* - Description: Description that is shown in the Recombee Admin UI.
*/
constructor(segmentationId, sourceType, expression, optional) {
super('PUT', `/segmentations/auto-reql/${segmentationId}`, 10000, false);
this.segmentationId = segmentationId;
this.sourceType = sourceType;
this.expression = expression;
optional = optional || {};
this.title = optional.title;
this.description = optional.description;
}

/**
* Get body parameters
* @return {Object} The values of body parameters (name of parameter: value of the parameter)
*/
bodyParameters() {
let params = {};
params.sourceType = this.sourceType;
params.expression = this.expression;

if(this.title !== undefined)
params.title = this.title;

if(this.description !== undefined)
params.description = this.description;

return params;
}

/**
* Get query parameters
* @return {Object} The values of query parameters (name of parameter: value of the parameter)
*/
queryParameters() {
let params = {};
return params;
}
}

exports.CreateAutoReqlSegmentation = CreateAutoReqlSegmentation
63 changes: 63 additions & 0 deletions lib/requests/create-manual-reql-segmentation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
This file is auto-generated, do not edit
*/

'use strict';
const rqs = require("./request");

/**
* Segment the items using multiple [ReQL](https://docs.recombee.com/reql.html) filters.
* Use the Add Manual ReQL Items Segment endpoint to create the individual segments.
*/
class CreateManualReqlSegmentation extends rqs.Request {

/**
* Construct the request
* @param {string} segmentationId - ID of the newly created Segmentation
* @param {string} sourceType - What type of data should be segmented. Currently only `items` are supported.
* @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value
* - Allowed parameters:
* - *title*
* - Type: string
* - Description: Human-readable name that is shown in the Recombee Admin UI.
* - *description*
* - Type: string
* - Description: Description that is shown in the Recombee Admin UI.
*/
constructor(segmentationId, sourceType, optional) {
super('PUT', `/segmentations/manual-reql/${segmentationId}`, 10000, false);
this.segmentationId = segmentationId;
this.sourceType = sourceType;
optional = optional || {};
this.title = optional.title;
this.description = optional.description;
}

/**
* Get body parameters
* @return {Object} The values of body parameters (name of parameter: value of the parameter)
*/
bodyParameters() {
let params = {};
params.sourceType = this.sourceType;

if(this.title !== undefined)
params.title = this.title;

if(this.description !== undefined)
params.description = this.description;

return params;
}

/**
* Get query parameters
* @return {Object} The values of query parameters (name of parameter: value of the parameter)
*/
queryParameters() {
let params = {};
return params;
}
}

exports.CreateManualReqlSegmentation = CreateManualReqlSegmentation
67 changes: 67 additions & 0 deletions lib/requests/create-property-based-segmentation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
This file is auto-generated, do not edit
*/

'use strict';
const rqs = require("./request");

/**
* Creates a Segmentation that splits the items into segments based on values of a particular item property.
* A segment is created for each unique value of the property.
* In case of `set` properties, a segment is created for each value in the set. Item belongs to all these segments.
*/
class CreatePropertyBasedSegmentation extends rqs.Request {

/**
* Construct the request
* @param {string} segmentationId - ID of the newly created Segmentation
* @param {string} sourceType - What type of data should be segmented. Currently only `items` are supported.
* @param {string} propertyName - Name of the property on which the Segmentation should be based
* @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value
* - Allowed parameters:
* - *title*
* - Type: string
* - Description: Human-readable name that is shown in the Recombee Admin UI.
* - *description*
* - Type: string
* - Description: Description that is shown in the Recombee Admin UI.
*/
constructor(segmentationId, sourceType, propertyName, optional) {
super('PUT', `/segmentations/property-based/${segmentationId}`, 10000, false);
this.segmentationId = segmentationId;
this.sourceType = sourceType;
this.propertyName = propertyName;
optional = optional || {};
this.title = optional.title;
this.description = optional.description;
}

/**
* Get body parameters
* @return {Object} The values of body parameters (name of parameter: value of the parameter)
*/
bodyParameters() {
let params = {};
params.sourceType = this.sourceType;
params.propertyName = this.propertyName;

if(this.title !== undefined)
params.title = this.title;

if(this.description !== undefined)
params.description = this.description;

return params;
}

/**
* Get query parameters
* @return {Object} The values of query parameters (name of parameter: value of the parameter)
*/
queryParameters() {
let params = {};
return params;
}
}

exports.CreatePropertyBasedSegmentation = CreatePropertyBasedSegmentation
Loading

0 comments on commit d062549

Please sign in to comment.