From d062549a148ccf7a1caaf90bf95da34f7cac0a0f Mon Sep 17 00:00:00 2001 From: Ondrej Fiedler Date: Fri, 6 Jan 2023 17:10:41 +0100 Subject: [PATCH] Support Item Segmentations --- lib/api-client.js | 2 +- lib/requests/add-bookmark.js | 2 +- lib/requests/add-cart-addition.js | 6 +- lib/requests/add-detail-view.js | 2 +- lib/requests/add-group.js | 2 +- lib/requests/add-item-property.js | 2 +- lib/requests/add-item.js | 4 +- lib/requests/add-manual-reql-segment.js | 58 ++++++++ lib/requests/add-purchase.js | 8 +- lib/requests/add-rating.js | 2 +- lib/requests/add-series.js | 2 +- lib/requests/add-user-property.js | 4 +- lib/requests/create-auto-reql-segmentation.js | 66 +++++++++ .../create-manual-reql-segmentation.js | 63 +++++++++ .../create-property-based-segmentation.js | 67 ++++++++++ lib/requests/delete-bookmark.js | 6 +- lib/requests/delete-cart-addition.js | 6 +- lib/requests/delete-detail-view.js | 6 +- lib/requests/delete-group.js | 4 +- lib/requests/delete-item.js | 4 +- lib/requests/delete-manual-reql-segment.js | 44 ++++++ lib/requests/delete-more-items.js | 6 +- lib/requests/delete-purchase.js | 6 +- lib/requests/delete-rating.js | 4 +- lib/requests/delete-search-synonym.js | 2 +- lib/requests/delete-segmentation.js | 42 ++++++ lib/requests/delete-series.js | 2 +- lib/requests/delete-user-property.js | 2 +- lib/requests/delete-user.js | 2 +- lib/requests/get-item-values.js | 4 +- lib/requests/get-segmentation.js | 42 ++++++ lib/requests/get-user-values.js | 4 +- lib/requests/index.js | 16 +++ lib/requests/insert-to-group.js | 4 +- lib/requests/insert-to-series.js | 4 +- lib/requests/list-group-items.js | 2 +- lib/requests/list-item-bookmarks.js | 4 +- lib/requests/list-item-cart-additions.js | 4 +- lib/requests/list-item-detail-views.js | 4 +- lib/requests/list-item-purchases.js | 4 +- lib/requests/list-item-ratings.js | 4 +- lib/requests/list-item-view-portions.js | 4 +- lib/requests/list-items.js | 2 +- lib/requests/list-segmentations.js | 43 ++++++ lib/requests/list-series-items.js | 4 +- lib/requests/list-user-bookmarks.js | 2 +- lib/requests/list-user-cart-additions.js | 2 +- lib/requests/list-user-detail-views.js | 2 +- lib/requests/list-user-purchases.js | 2 +- lib/requests/list-user-ratings.js | 2 +- lib/requests/list-user-view-portions.js | 2 +- lib/requests/list-users.js | 2 +- lib/requests/merge-users.js | 4 +- ...recommend-item-segments-to-item-segment.js | 125 ++++++++++++++++++ .../recommend-item-segments-to-item.js | 125 ++++++++++++++++++ .../recommend-item-segments-to-user.js | 110 +++++++++++++++ lib/requests/recommend-items-to-item.js | 52 ++++---- lib/requests/recommend-items-to-user.js | 46 +++---- lib/requests/recommend-next-items.js | 4 +- lib/requests/recommend-users-to-item.js | 36 ++--- lib/requests/recommend-users-to-user.js | 42 +++--- lib/requests/reset-database.js | 2 +- lib/requests/search-item-segments.js | 112 ++++++++++++++++ lib/requests/search-items.js | 34 ++--- lib/requests/set-view-portion.js | 6 +- lib/requests/update-auto-reql-segmentation.js | 66 +++++++++ lib/requests/update-manual-reql-segment.js | 57 ++++++++ .../update-manual-reql-segmentation.js | 59 +++++++++ lib/requests/update-more-items.js | 6 +- .../update-property-based-segmentation.js | 66 +++++++++ package.json | 2 +- test/add-manual-reql-segment-batch_test.js | 40 ++++++ test/add-manual-reql-segment-callback_test.js | 43 ++++++ test/add-manual-reql-segment-test.js | 35 +++++ ...reate-auto-reql-segmentation-batch_test.js | 35 +++++ ...te-auto-reql-segmentation-callback_test.js | 45 +++++++ test/create-auto-reql-segmentation-test.js | 43 ++++++ ...ate-manual-reql-segmentation-batch_test.js | 35 +++++ ...-manual-reql-segmentation-callback_test.js | 45 +++++++ test/create-manual-reql-segmentation-test.js | 43 ++++++ ...-property-based-segmentation-batch_test.js | 35 +++++ ...operty-based-segmentation-callback_test.js | 45 +++++++ ...create-property-based-segmentation-test.js | 43 ++++++ test/delete-manual-reql-segment-batch_test.js | 47 +++++++ ...elete-manual-reql-segment-callback_test.js | 51 +++++++ test/delete-manual-reql-segment-test.js | 39 ++++++ test/delete-segmentation-batch_test.js | 42 ++++++ test/delete-segmentation-callback_test.js | 53 ++++++++ test/delete-segmentation-test.js | 47 +++++++ test/get-segmentation-batch_test.js | 41 ++++++ test/get-segmentation-callback_test.js | 44 ++++++ test/get-segmentation-test.js | 36 +++++ test/list-segmentations-batch_test.js | 41 ++++++ test/list-segmentations-callback_test.js | 44 ++++++ test/list-segmentations-test.js | 36 +++++ ...ommend-item-segments-to-item-batch_test.js | 33 +++++ ...end-item-segments-to-item-callback_test.js | 37 ++++++ ...tem-segments-to-item-segment-batch_test.js | 33 +++++ ...-segments-to-item-segment-callback_test.js | 37 ++++++ ...mend-item-segments-to-item-segment-test.js | 39 ++++++ test/recommend-item-segments-to-item-test.js | 39 ++++++ ...ommend-item-segments-to-user-batch_test.js | 33 +++++ ...end-item-segments-to-user-callback_test.js | 37 ++++++ test/recommend-item-segments-to-user-test.js | 39 ++++++ test/search-item-segments-batch_test.js | 33 +++++ test/search-item-segments-callback_test.js | 37 ++++++ test/search-item-segments-test.js | 39 ++++++ ...pdate-auto-reql-segmentation-batch_test.js | 40 ++++++ ...te-auto-reql-segmentation-callback_test.js | 43 ++++++ test/update-auto-reql-segmentation-test.js | 35 +++++ test/update-manual-reql-segment-batch_test.js | 47 +++++++ ...pdate-manual-reql-segment-callback_test.js | 51 +++++++ test/update-manual-reql-segment-test.js | 39 ++++++ ...ate-manual-reql-segmentation-batch_test.js | 40 ++++++ ...-manual-reql-segmentation-callback_test.js | 43 ++++++ test/update-manual-reql-segmentation-test.js | 35 +++++ ...-property-based-segmentation-batch_test.js | 40 ++++++ ...operty-based-segmentation-callback_test.js | 43 ++++++ ...update-property-based-segmentation-test.js | 35 +++++ 119 files changed, 3287 insertions(+), 191 deletions(-) create mode 100644 lib/requests/add-manual-reql-segment.js create mode 100644 lib/requests/create-auto-reql-segmentation.js create mode 100644 lib/requests/create-manual-reql-segmentation.js create mode 100644 lib/requests/create-property-based-segmentation.js create mode 100644 lib/requests/delete-manual-reql-segment.js create mode 100644 lib/requests/delete-segmentation.js create mode 100644 lib/requests/get-segmentation.js create mode 100644 lib/requests/list-segmentations.js create mode 100644 lib/requests/recommend-item-segments-to-item-segment.js create mode 100644 lib/requests/recommend-item-segments-to-item.js create mode 100644 lib/requests/recommend-item-segments-to-user.js create mode 100644 lib/requests/search-item-segments.js create mode 100644 lib/requests/update-auto-reql-segmentation.js create mode 100644 lib/requests/update-manual-reql-segment.js create mode 100644 lib/requests/update-manual-reql-segmentation.js create mode 100644 lib/requests/update-property-based-segmentation.js create mode 100644 test/add-manual-reql-segment-batch_test.js create mode 100644 test/add-manual-reql-segment-callback_test.js create mode 100644 test/add-manual-reql-segment-test.js create mode 100644 test/create-auto-reql-segmentation-batch_test.js create mode 100644 test/create-auto-reql-segmentation-callback_test.js create mode 100644 test/create-auto-reql-segmentation-test.js create mode 100644 test/create-manual-reql-segmentation-batch_test.js create mode 100644 test/create-manual-reql-segmentation-callback_test.js create mode 100644 test/create-manual-reql-segmentation-test.js create mode 100644 test/create-property-based-segmentation-batch_test.js create mode 100644 test/create-property-based-segmentation-callback_test.js create mode 100644 test/create-property-based-segmentation-test.js create mode 100644 test/delete-manual-reql-segment-batch_test.js create mode 100644 test/delete-manual-reql-segment-callback_test.js create mode 100644 test/delete-manual-reql-segment-test.js create mode 100644 test/delete-segmentation-batch_test.js create mode 100644 test/delete-segmentation-callback_test.js create mode 100644 test/delete-segmentation-test.js create mode 100644 test/get-segmentation-batch_test.js create mode 100644 test/get-segmentation-callback_test.js create mode 100644 test/get-segmentation-test.js create mode 100644 test/list-segmentations-batch_test.js create mode 100644 test/list-segmentations-callback_test.js create mode 100644 test/list-segmentations-test.js create mode 100644 test/recommend-item-segments-to-item-batch_test.js create mode 100644 test/recommend-item-segments-to-item-callback_test.js create mode 100644 test/recommend-item-segments-to-item-segment-batch_test.js create mode 100644 test/recommend-item-segments-to-item-segment-callback_test.js create mode 100644 test/recommend-item-segments-to-item-segment-test.js create mode 100644 test/recommend-item-segments-to-item-test.js create mode 100644 test/recommend-item-segments-to-user-batch_test.js create mode 100644 test/recommend-item-segments-to-user-callback_test.js create mode 100644 test/recommend-item-segments-to-user-test.js create mode 100644 test/search-item-segments-batch_test.js create mode 100644 test/search-item-segments-callback_test.js create mode 100644 test/search-item-segments-test.js create mode 100644 test/update-auto-reql-segmentation-batch_test.js create mode 100644 test/update-auto-reql-segmentation-callback_test.js create mode 100644 test/update-auto-reql-segmentation-test.js create mode 100644 test/update-manual-reql-segment-batch_test.js create mode 100644 test/update-manual-reql-segment-callback_test.js create mode 100644 test/update-manual-reql-segment-test.js create mode 100644 test/update-manual-reql-segmentation-batch_test.js create mode 100644 test/update-manual-reql-segmentation-callback_test.js create mode 100644 test/update-manual-reql-segmentation-test.js create mode 100644 test/update-property-based-segmentation-batch_test.js create mode 100644 test/update-property-based-segmentation-callback_test.js create mode 100644 test/update-property-based-segmentation-test.js diff --git a/lib/api-client.js b/lib/api-client.js index f738d84..7410330 100644 --- a/lib/api-client.js +++ b/lib/api-client.js @@ -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 }; diff --git a/lib/requests/add-bookmark.js b/lib/requests/add-bookmark.js index f147d77..69670b0 100644 --- a/lib/requests/add-bookmark.js +++ b/lib/requests/add-bookmark.js @@ -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 { diff --git a/lib/requests/add-cart-addition.js b/lib/requests/add-cart-addition.js index dee686a..55f5567 100644 --- a/lib/requests/add-cart-addition.js +++ b/lib/requests/add-cart-addition.js @@ -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 { @@ -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. diff --git a/lib/requests/add-detail-view.js b/lib/requests/add-detail-view.js index 15790a9..b5802cc 100644 --- a/lib/requests/add-detail-view.js +++ b/lib/requests/add-detail-view.js @@ -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 { diff --git a/lib/requests/add-group.js b/lib/requests/add-group.js index f334124..ed1ec75 100644 --- a/lib/requests/add-group.js +++ b/lib/requests/add-group.js @@ -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 { diff --git a/lib/requests/add-item-property.js b/lib/requests/add-item-property.js index 2eab976..c8443cd 100644 --- a/lib/requests/add-item-property.js +++ b/lib/requests/add-item-property.js @@ -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). diff --git a/lib/requests/add-item.js b/lib/requests/add-item.js index a5d6f78..5784383 100644 --- a/lib/requests/add-item.js +++ b/lib/requests/add-item.js @@ -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 { diff --git a/lib/requests/add-manual-reql-segment.js b/lib/requests/add-manual-reql-segment.js new file mode 100644 index 0000000..0be350e --- /dev/null +++ b/lib/requests/add-manual-reql-segment.js @@ -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 diff --git a/lib/requests/add-purchase.js b/lib/requests/add-purchase.js index 92ac194..e1c0e6d 100644 --- a/lib/requests/add-purchase.js +++ b/lib/requests/add-purchase.js @@ -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 { @@ -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. diff --git a/lib/requests/add-rating.js b/lib/requests/add-rating.js index 31a16c4..7fb3a25 100644 --- a/lib/requests/add-rating.js +++ b/lib/requests/add-rating.js @@ -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 { diff --git a/lib/requests/add-series.js b/lib/requests/add-series.js index dbcfeb0..9822fd1 100644 --- a/lib/requests/add-series.js +++ b/lib/requests/add-series.js @@ -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 { diff --git a/lib/requests/add-user-property.js b/lib/requests/add-user-property.js index 1e43e7e..06eaa54 100644 --- a/lib/requests/add-user-property.js +++ b/lib/requests/add-user-property.js @@ -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). diff --git a/lib/requests/create-auto-reql-segmentation.js b/lib/requests/create-auto-reql-segmentation.js new file mode 100644 index 0000000..de0aa97 --- /dev/null +++ b/lib/requests/create-auto-reql-segmentation.js @@ -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 diff --git a/lib/requests/create-manual-reql-segmentation.js b/lib/requests/create-manual-reql-segmentation.js new file mode 100644 index 0000000..7f17b83 --- /dev/null +++ b/lib/requests/create-manual-reql-segmentation.js @@ -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 diff --git a/lib/requests/create-property-based-segmentation.js b/lib/requests/create-property-based-segmentation.js new file mode 100644 index 0000000..6f4abc4 --- /dev/null +++ b/lib/requests/create-property-based-segmentation.js @@ -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 diff --git a/lib/requests/delete-bookmark.js b/lib/requests/delete-bookmark.js index 893a099..ee3db90 100644 --- a/lib/requests/delete-bookmark.js +++ b/lib/requests/delete-bookmark.js @@ -6,19 +6,19 @@ const rqs = require("./request"); /** - * Deletes a bookmark uniquely specified by `userId`, `itemId`, and `timestamp` or all the bookmarks with given `userId` and `itemId` if `timestamp` is omitted. + * Deletes a bookmark uniquely specified by `userId`, `itemId`, and `timestamp` or all the bookmarks with the given `userId` and `itemId` if `timestamp` is omitted. */ class DeleteBookmark extends rqs.Request { /** * Construct the request * @param {string} userId - ID of the user who made the bookmark. - * @param {string} itemId - ID of the item of which was bookmarked. + * @param {string} itemId - ID of the item which was bookmarked. * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value * - Allowed parameters: * - *timestamp* * - Type: number - * - Description: Unix timestamp of the bookmark. If the `timestamp` is omitted, then all the bookmarks with given `userId` and `itemId` are deleted. + * - Description: Unix timestamp of the bookmark. If the `timestamp` is omitted, then all the bookmarks with the given `userId` and `itemId` are deleted. */ constructor(userId, itemId, optional) { super('DELETE', '/bookmarks/', 1000, false); diff --git a/lib/requests/delete-cart-addition.js b/lib/requests/delete-cart-addition.js index bb85187..3354b53 100644 --- a/lib/requests/delete-cart-addition.js +++ b/lib/requests/delete-cart-addition.js @@ -6,19 +6,19 @@ const rqs = require("./request"); /** - * Deletes an existing cart addition uniquely specified by `userId`, `itemId`, and `timestamp` or all the cart additions with given `userId` and `itemId` if `timestamp` is omitted. + * Deletes an existing cart addition uniquely specified by `userId`, `itemId`, and `timestamp` or all the cart additions with the given `userId` and `itemId` if `timestamp` is omitted. */ class DeleteCartAddition extends rqs.Request { /** * Construct the request * @param {string} userId - ID of the user who made the cart addition. - * @param {string} itemId - ID of the item of which was added to cart. + * @param {string} itemId - ID of the item which was added to the cart. * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value * - Allowed parameters: * - *timestamp* * - Type: number - * - Description: Unix timestamp of the cart addition. If the `timestamp` is omitted, then all the cart additions with given `userId` and `itemId` are deleted. + * - Description: Unix timestamp of the cart addition. If the `timestamp` is omitted, then all the cart additions with the given `userId` and `itemId` are deleted. */ constructor(userId, itemId, optional) { super('DELETE', '/cartadditions/', 1000, false); diff --git a/lib/requests/delete-detail-view.js b/lib/requests/delete-detail-view.js index e415162..bd8395e 100644 --- a/lib/requests/delete-detail-view.js +++ b/lib/requests/delete-detail-view.js @@ -6,19 +6,19 @@ const rqs = require("./request"); /** - * Deletes an existing detail view uniquely specified by (`userId`, `itemId`, and `timestamp`) or all the detail views with given `userId` and `itemId` if `timestamp` is omitted. + * Deletes an existing detail view uniquely specified by (`userId`, `itemId`, and `timestamp`) or all the detail views with the given `userId` and `itemId` if `timestamp` is omitted. */ class DeleteDetailView extends rqs.Request { /** * Construct the request * @param {string} userId - ID of the user who made the detail view. - * @param {string} itemId - ID of the item of which the details were viewed. + * @param {string} itemId - ID of the item whose details were viewed. * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value * - Allowed parameters: * - *timestamp* * - Type: number - * - Description: Unix timestamp of the detail view. If the `timestamp` is omitted, then all the detail views with given `userId` and `itemId` are deleted. + * - Description: Unix timestamp of the detail view. If the `timestamp` is omitted, then all the detail views with the given `userId` and `itemId` are deleted. */ constructor(userId, itemId, optional) { super('DELETE', '/detailviews/', 1000, false); diff --git a/lib/requests/delete-group.js b/lib/requests/delete-group.js index 75de1a7..741fbb4 100644 --- a/lib/requests/delete-group.js +++ b/lib/requests/delete-group.js @@ -6,8 +6,8 @@ const rqs = require("./request"); /** - * Deletes the group of given `groupId` from the database. - * Deleting a group will only delete assignment of items to it, not the items themselves! + * Deletes the group of the given `groupId` from the database. + * Deleting a group will only delete the assignment of items to it, not the items themselves! */ class DeleteGroup extends rqs.Request { diff --git a/lib/requests/delete-item.js b/lib/requests/delete-item.js index d203c11..b9316ac 100644 --- a/lib/requests/delete-item.js +++ b/lib/requests/delete-item.js @@ -6,8 +6,8 @@ const rqs = require("./request"); /** - * Deletes an item of given `itemId` from the catalog. - * If there are any *purchases*, *ratings*, *bookmarks*, *cart additions* or *detail views* of the item present in the database, they will be deleted in cascade as well. Also, if the item is present in some *series*, it will be removed from all the *series* where present. + * Deletes an item of the given `itemId` from the catalog. + * If there are any *purchases*, *ratings*, *bookmarks*, *cart additions*, or *detail views* of the item present in the database, they will be deleted in cascade as well. Also, if the item is present in some *series*, it will be removed from all the *series* where present. * If an item becomes obsolete/no longer available, it is meaningful to keep it in the catalog (along with all the interaction data, which are very useful), and **only exclude the item from recommendations**. In such a case, use [ReQL filter](https://docs.recombee.com/reql.html) instead of deleting the item completely. */ class DeleteItem extends rqs.Request { diff --git a/lib/requests/delete-manual-reql-segment.js b/lib/requests/delete-manual-reql-segment.js new file mode 100644 index 0000000..b2f220f --- /dev/null +++ b/lib/requests/delete-manual-reql-segment.js @@ -0,0 +1,44 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict'; +const rqs = require("./request"); + +/** + * Delete a Segment from a Manual ReQL Segmentation. + */ +class DeleteManualReqlSegment extends rqs.Request { + + /** + * Construct the request + * @param {string} segmentationId - ID of the Segmentation from which the Segment should be deleted + * @param {string} segmentId - ID of the Segment that should be deleted + */ + constructor(segmentationId, segmentId) { + super('DELETE', `/segmentations/manual-reql/${segmentationId}/segments/${segmentId}`, 10000, false); + this.segmentationId = segmentationId; + this.segmentId = segmentId; + } + + /** + * Get body parameters + * @return {Object} The values of body parameters (name of parameter: value of the parameter) + */ + bodyParameters() { + let params = {}; + + 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.DeleteManualReqlSegment = DeleteManualReqlSegment diff --git a/lib/requests/delete-more-items.js b/lib/requests/delete-more-items.js index 65b399c..2317208 100644 --- a/lib/requests/delete-more-items.js +++ b/lib/requests/delete-more-items.js @@ -6,14 +6,14 @@ const rqs = require("./request"); /** - * Delete all the items that pass the filter. - * If an item becomes obsolete/no longer available, it is meaningful to **keep it in the catalog** (along with all the interaction data, which are very useful), and **only exclude the item from recommendations**. In such a case, use [ReQL filter](https://docs.recombee.com/reql.html) instead of deleting the item completely. + * Deletes all the items that pass the filter. + * If an item becomes obsolete/no longer available, it is meaningful to **keep it in the catalog** (along with all the interaction data, which are very useful) and **only exclude the item from recommendations**. In such a case, use [ReQL filter](https://docs.recombee.com/reql.html) instead of deleting the item completely. */ class DeleteMoreItems extends rqs.Request { /** * Construct the request - * @param {string} filter - A [ReQL](https://docs.recombee.com/reql.html) expression, which return `true` for the items that shall be updated. + * @param {string} filter - A [ReQL](https://docs.recombee.com/reql.html) expression, which returns `true` for the items that shall be updated. */ constructor(filter) { super('DELETE', '/more-items/', 1000, false); diff --git a/lib/requests/delete-purchase.js b/lib/requests/delete-purchase.js index 7535ddf..d9e902b 100644 --- a/lib/requests/delete-purchase.js +++ b/lib/requests/delete-purchase.js @@ -6,19 +6,19 @@ const rqs = require("./request"); /** - * Deletes an existing purchase uniquely specified by `userId`, `itemId`, and `timestamp` or all the purchases with given `userId` and `itemId` if `timestamp` is omitted. + * Deletes an existing purchase uniquely specified by `userId`, `itemId`, and `timestamp` or all the purchases with the given `userId` and `itemId` if `timestamp` is omitted. */ class DeletePurchase extends rqs.Request { /** * Construct the request * @param {string} userId - ID of the user who made the purchase. - * @param {string} itemId - ID of the item of which was purchased. + * @param {string} itemId - ID of the item which was purchased. * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value * - Allowed parameters: * - *timestamp* * - Type: number - * - Description: Unix timestamp of the purchase. If the `timestamp` is omitted, then all the purchases with given `userId` and `itemId` are deleted. + * - Description: Unix timestamp of the purchase. If the `timestamp` is omitted, then all the purchases with the given `userId` and `itemId` are deleted. */ constructor(userId, itemId, optional) { super('DELETE', '/purchases/', 1000, false); diff --git a/lib/requests/delete-rating.js b/lib/requests/delete-rating.js index 2b5da17..18f7a1c 100644 --- a/lib/requests/delete-rating.js +++ b/lib/requests/delete-rating.js @@ -6,7 +6,7 @@ const rqs = require("./request"); /** - * Deletes an existing rating specified by (`userId`, `itemId`, `timestamp`) from the database or all the ratings with given `userId` and `itemId` if `timestamp` is omitted. + * Deletes an existing rating specified by (`userId`, `itemId`, `timestamp`) from the database or all the ratings with the given `userId` and `itemId` if `timestamp` is omitted. */ class DeleteRating extends rqs.Request { @@ -18,7 +18,7 @@ class DeleteRating extends rqs.Request { * - Allowed parameters: * - *timestamp* * - Type: number - * - Description: Unix timestamp of the rating. If the `timestamp` is omitted, then all the ratings with given `userId` and `itemId` are deleted. + * - Description: Unix timestamp of the rating. If the `timestamp` is omitted, then all the ratings with the given `userId` and `itemId` are deleted. */ constructor(userId, itemId, optional) { super('DELETE', '/ratings/', 1000, false); diff --git a/lib/requests/delete-search-synonym.js b/lib/requests/delete-search-synonym.js index e8d21da..5b01a7b 100644 --- a/lib/requests/delete-search-synonym.js +++ b/lib/requests/delete-search-synonym.js @@ -6,7 +6,7 @@ const rqs = require("./request"); /** - * Deletes synonym of given `id` and this synonym is no longer taken into account in the [Search items](https://docs.recombee.com/api.html#search-items). + * Deletes synonym of the given `id`. This synonym is no longer taken into account in the [Search items](https://docs.recombee.com/api.html#search-items). */ class DeleteSearchSynonym extends rqs.Request { diff --git a/lib/requests/delete-segmentation.js b/lib/requests/delete-segmentation.js new file mode 100644 index 0000000..f66e389 --- /dev/null +++ b/lib/requests/delete-segmentation.js @@ -0,0 +1,42 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict'; +const rqs = require("./request"); + +/** + * Delete existing Segmentation. + */ +class DeleteSegmentation extends rqs.Request { + + /** + * Construct the request + * @param {string} segmentationId - ID of the Segmentation that should be deleted + */ + constructor(segmentationId) { + super('DELETE', `/segmentations/${segmentationId}`, 10000, false); + this.segmentationId = segmentationId; + } + + /** + * Get body parameters + * @return {Object} The values of body parameters (name of parameter: value of the parameter) + */ + bodyParameters() { + let params = {}; + + 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.DeleteSegmentation = DeleteSegmentation diff --git a/lib/requests/delete-series.js b/lib/requests/delete-series.js index 1cf4561..113fa20 100644 --- a/lib/requests/delete-series.js +++ b/lib/requests/delete-series.js @@ -6,7 +6,7 @@ const rqs = require("./request"); /** - * Deletes the series of given `seriesId` from the database. + * Deletes the series of the given `seriesId` from the database. * Deleting a series will only delete assignment of items to it, not the items themselves! */ class DeleteSeries extends rqs.Request { diff --git a/lib/requests/delete-user-property.js b/lib/requests/delete-user-property.js index 2f82cb0..afe3be8 100644 --- a/lib/requests/delete-user-property.js +++ b/lib/requests/delete-user-property.js @@ -6,7 +6,7 @@ const rqs = require("./request"); /** - * Deleting an user property is roughly equivalent to removing a column from the table of users. + * Deleting a user property is roughly equivalent to removing a column from the table of users. */ class DeleteUserProperty extends rqs.Request { diff --git a/lib/requests/delete-user.js b/lib/requests/delete-user.js index 7da7075..ec8eded 100644 --- a/lib/requests/delete-user.js +++ b/lib/requests/delete-user.js @@ -6,7 +6,7 @@ const rqs = require("./request"); /** - * Deletes a user of given *userId* from the database. + * Deletes a user of the given *userId* from the database. * If there are any purchases, ratings, bookmarks, cart additions or detail views made by the user present in the database, they will be deleted in cascade as well. */ class DeleteUser extends rqs.Request { diff --git a/lib/requests/get-item-values.js b/lib/requests/get-item-values.js index e304cae..38a5c7e 100644 --- a/lib/requests/get-item-values.js +++ b/lib/requests/get-item-values.js @@ -6,13 +6,13 @@ const rqs = require("./request"); /** - * Get all the current property values of a given item. + * Gets all the current property values of the given item. */ class GetItemValues extends rqs.Request { /** * Construct the request - * @param {string} itemId - ID of the item properties of which are to be obtained. + * @param {string} itemId - ID of the item whose properties are to be obtained. */ constructor(itemId) { super('GET', `/items/${itemId}`, 1000, false); diff --git a/lib/requests/get-segmentation.js b/lib/requests/get-segmentation.js new file mode 100644 index 0000000..490c924 --- /dev/null +++ b/lib/requests/get-segmentation.js @@ -0,0 +1,42 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict'; +const rqs = require("./request"); + +/** + * Get existing Segmentation. + */ +class GetSegmentation extends rqs.Request { + + /** + * Construct the request + * @param {string} segmentationId - ID of the Segmentation that should be returned + */ + constructor(segmentationId) { + super('GET', `/segmentations/list/${segmentationId}`, 10000, false); + this.segmentationId = segmentationId; + } + + /** + * Get body parameters + * @return {Object} The values of body parameters (name of parameter: value of the parameter) + */ + bodyParameters() { + let params = {}; + + 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.GetSegmentation = GetSegmentation diff --git a/lib/requests/get-user-values.js b/lib/requests/get-user-values.js index 7c40713..9d1321c 100644 --- a/lib/requests/get-user-values.js +++ b/lib/requests/get-user-values.js @@ -6,13 +6,13 @@ const rqs = require("./request"); /** - * Get all the current property values of a given user. + * Gets all the current property values of the given user. */ class GetUserValues extends rqs.Request { /** * Construct the request - * @param {string} userId - ID of the user properties of which are to be obtained. + * @param {string} userId - ID of the user whose properties are to be obtained. */ constructor(userId) { super('GET', `/users/${userId}`, 1000, false); diff --git a/lib/requests/index.js b/lib/requests/index.js index 7b7574a..c652dcc 100644 --- a/lib/requests/index.js +++ b/lib/requests/index.js @@ -65,10 +65,26 @@ exports.RecommendItemsToItem = require("./recommend-items-to-item").RecommendIte exports.RecommendNextItems = require("./recommend-next-items").RecommendNextItems; exports.RecommendUsersToUser = require("./recommend-users-to-user").RecommendUsersToUser; exports.RecommendUsersToItem = require("./recommend-users-to-item").RecommendUsersToItem; +exports.RecommendItemSegmentsToUser = require("./recommend-item-segments-to-user").RecommendItemSegmentsToUser; +exports.RecommendItemSegmentsToItem = require("./recommend-item-segments-to-item").RecommendItemSegmentsToItem; +exports.RecommendItemSegmentsToItemSegment = require("./recommend-item-segments-to-item-segment").RecommendItemSegmentsToItemSegment; exports.SearchItems = require("./search-items").SearchItems; +exports.SearchItemSegments = require("./search-item-segments").SearchItemSegments; exports.AddSearchSynonym = require("./add-search-synonym").AddSearchSynonym; exports.ListSearchSynonyms = require("./list-search-synonyms").ListSearchSynonyms; exports.DeleteAllSearchSynonyms = require("./delete-all-search-synonyms").DeleteAllSearchSynonyms; exports.DeleteSearchSynonym = require("./delete-search-synonym").DeleteSearchSynonym; +exports.CreatePropertyBasedSegmentation = require("./create-property-based-segmentation").CreatePropertyBasedSegmentation; +exports.UpdatePropertyBasedSegmentation = require("./update-property-based-segmentation").UpdatePropertyBasedSegmentation; +exports.CreateAutoReqlSegmentation = require("./create-auto-reql-segmentation").CreateAutoReqlSegmentation; +exports.UpdateAutoReqlSegmentation = require("./update-auto-reql-segmentation").UpdateAutoReqlSegmentation; +exports.CreateManualReqlSegmentation = require("./create-manual-reql-segmentation").CreateManualReqlSegmentation; +exports.UpdateManualReqlSegmentation = require("./update-manual-reql-segmentation").UpdateManualReqlSegmentation; +exports.AddManualReqlSegment = require("./add-manual-reql-segment").AddManualReqlSegment; +exports.UpdateManualReqlSegment = require("./update-manual-reql-segment").UpdateManualReqlSegment; +exports.DeleteManualReqlSegment = require("./delete-manual-reql-segment").DeleteManualReqlSegment; +exports.ListSegmentations = require("./list-segmentations").ListSegmentations; +exports.GetSegmentation = require("./get-segmentation").GetSegmentation; +exports.DeleteSegmentation = require("./delete-segmentation").DeleteSegmentation; exports.ResetDatabase = require("./reset-database").ResetDatabase; exports.Batch = require("./batch").Batch; diff --git a/lib/requests/insert-to-group.js b/lib/requests/insert-to-group.js index 7556490..37b3f93 100644 --- a/lib/requests/insert-to-group.js +++ b/lib/requests/insert-to-group.js @@ -6,7 +6,7 @@ const rqs = require("./request"); /** - * Inserts an existing item/group into group of given `groupId`. + * Inserts an existing item/group into a group of the given `groupId`. */ class InsertToGroup extends rqs.Request { @@ -19,7 +19,7 @@ class InsertToGroup extends rqs.Request { * - Allowed parameters: * - *cascadeCreate* * - Type: boolean - * - Description: Indicates that any non-existing entity specified within the request should be created (as is corresponding PUT requests were invoked). This concerns both the `groupId` and the `groupId`. If `cascadeCreate` is set true, the behavior also depends on the `itemType`. Either items or group may be created if not present in the database. + * - Description: Indicates that any non-existing entity specified within the request should be created (as if corresponding PUT requests were invoked). This concerns both the `groupId` and the `groupId`. If `cascadeCreate` is set to true, the behavior also depends on the `itemType`. Either items or group may be created if not present in the database. */ constructor(groupId, itemType, itemId, optional) { super('POST', `/groups/${groupId}/items/`, 1000, false); diff --git a/lib/requests/insert-to-series.js b/lib/requests/insert-to-series.js index 8ca4168..c0bb592 100644 --- a/lib/requests/insert-to-series.js +++ b/lib/requests/insert-to-series.js @@ -6,7 +6,7 @@ const rqs = require("./request"); /** - * Inserts an existing item/series into series of given seriesId at position determined by time. + * Inserts an existing item/series into a series of the given seriesId at a position determined by time. */ class InsertToSeries extends rqs.Request { @@ -20,7 +20,7 @@ class InsertToSeries extends rqs.Request { * - Allowed parameters: * - *cascadeCreate* * - Type: boolean - * - Description: Indicates that any non-existing entity specified within the request should be created (as is corresponding PUT requests were invoked). This concerns both the `seriesId` and the `itemId`. If `cascadeCreate` is set true, the behavior also depends on the `itemType`. Either item or series may be created if not present in the database. + * - Description: Indicates that any non-existing entity specified within the request should be created (as if corresponding PUT requests were invoked). This concerns both the `seriesId` and the `itemId`. If `cascadeCreate` is set to true, the behavior also depends on the `itemType`. Either item or series may be created if not present in the database. */ constructor(seriesId, itemType, itemId, time, optional) { super('POST', `/series/${seriesId}/items/`, 1000, false); diff --git a/lib/requests/list-group-items.js b/lib/requests/list-group-items.js index 750e600..526da8a 100644 --- a/lib/requests/list-group-items.js +++ b/lib/requests/list-group-items.js @@ -12,7 +12,7 @@ class ListGroupItems extends rqs.Request { /** * Construct the request - * @param {string} groupId - ID of the group items of which are to be listed. + * @param {string} groupId - ID of the group whose items are to be listed. */ constructor(groupId) { super('GET', `/groups/${groupId}/items/`, 100000, false); diff --git a/lib/requests/list-item-bookmarks.js b/lib/requests/list-item-bookmarks.js index 30ce274..452becb 100644 --- a/lib/requests/list-item-bookmarks.js +++ b/lib/requests/list-item-bookmarks.js @@ -6,13 +6,13 @@ const rqs = require("./request"); /** - * List all the ever-made bookmarks of a given item. + * Lists all the ever-made bookmarks of the given item. */ class ListItemBookmarks extends rqs.Request { /** * Construct the request - * @param {string} itemId - ID of the item of which the bookmarks are to be listed. + * @param {string} itemId - ID of the item whose bookmarks are to be listed. */ constructor(itemId) { super('GET', `/items/${itemId}/bookmarks/`, 100000, false); diff --git a/lib/requests/list-item-cart-additions.js b/lib/requests/list-item-cart-additions.js index fb3caeb..1345ca0 100644 --- a/lib/requests/list-item-cart-additions.js +++ b/lib/requests/list-item-cart-additions.js @@ -6,13 +6,13 @@ const rqs = require("./request"); /** - * List all the ever-made cart addition of a given item. + * Lists all the ever-made cart additions of the given item. */ class ListItemCartAdditions extends rqs.Request { /** * Construct the request - * @param {string} itemId - ID of the item of which the cart addition are to be listed. + * @param {string} itemId - ID of the item whose cart additions are to be listed. */ constructor(itemId) { super('GET', `/items/${itemId}/cartadditions/`, 100000, false); diff --git a/lib/requests/list-item-detail-views.js b/lib/requests/list-item-detail-views.js index a9da35c..cbbdfd4 100644 --- a/lib/requests/list-item-detail-views.js +++ b/lib/requests/list-item-detail-views.js @@ -6,13 +6,13 @@ const rqs = require("./request"); /** - * List all the detail views of a given item ever made by different users. + * Lists all the detail views of the given item ever made by different users. */ class ListItemDetailViews extends rqs.Request { /** * Construct the request - * @param {string} itemId - ID of the item of which the detail views are to be listed. + * @param {string} itemId - ID of the item whose detail views are to be listed. */ constructor(itemId) { super('GET', `/items/${itemId}/detailviews/`, 100000, false); diff --git a/lib/requests/list-item-purchases.js b/lib/requests/list-item-purchases.js index a5494f1..b37c7bc 100644 --- a/lib/requests/list-item-purchases.js +++ b/lib/requests/list-item-purchases.js @@ -6,13 +6,13 @@ const rqs = require("./request"); /** - * List all the ever-made purchases of a given item. + * Lists all the ever-made purchases of the given item. */ class ListItemPurchases extends rqs.Request { /** * Construct the request - * @param {string} itemId - ID of the item of which the pucrhases are to be listed. + * @param {string} itemId - ID of the item whose purchases are to be listed. */ constructor(itemId) { super('GET', `/items/${itemId}/purchases/`, 100000, false); diff --git a/lib/requests/list-item-ratings.js b/lib/requests/list-item-ratings.js index cc74340..eb64938 100644 --- a/lib/requests/list-item-ratings.js +++ b/lib/requests/list-item-ratings.js @@ -6,13 +6,13 @@ const rqs = require("./request"); /** - * List all the ratings of an item ever submitted by different users. + * Lists all the ratings of an item ever submitted by different users. */ class ListItemRatings extends rqs.Request { /** * Construct the request - * @param {string} itemId - ID of the item of which the ratings are to be listed. + * @param {string} itemId - ID of the item whose ratings are to be listed. */ constructor(itemId) { super('GET', `/items/${itemId}/ratings/`, 100000, false); diff --git a/lib/requests/list-item-view-portions.js b/lib/requests/list-item-view-portions.js index 8034808..b9c12ca 100644 --- a/lib/requests/list-item-view-portions.js +++ b/lib/requests/list-item-view-portions.js @@ -6,13 +6,13 @@ const rqs = require("./request"); /** - * List all the view portions of an item ever submitted by different users. + * Lists all the view portions of an item ever submitted by different users. */ class ListItemViewPortions extends rqs.Request { /** * Construct the request - * @param {string} itemId - ID of the item of which the view portions are to be listed. + * @param {string} itemId - ID of the item whose view portions are to be listed. */ constructor(itemId) { super('GET', `/items/${itemId}/viewportions/`, 100000, false); diff --git a/lib/requests/list-items.js b/lib/requests/list-items.js index a577c6a..c39f308 100644 --- a/lib/requests/list-items.js +++ b/lib/requests/list-items.js @@ -47,7 +47,7 @@ class ListItems extends rqs.Request { * ``` * - *includedProperties* * - Type: string[] - * - Description: Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. + * - Description: Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. * Example response for `includedProperties=description,price`: * ``` * [ diff --git a/lib/requests/list-segmentations.js b/lib/requests/list-segmentations.js new file mode 100644 index 0000000..8e118a3 --- /dev/null +++ b/lib/requests/list-segmentations.js @@ -0,0 +1,43 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict'; +const rqs = require("./request"); + +/** + * Return all existing items Segmentations. + */ +class ListSegmentations extends rqs.Request { + + /** + * Construct the request + * @param {string} sourceType - List Segmentations based on a particular type of data. Currently only `items` are supported. + */ + constructor(sourceType) { + super('GET', '/segmentations/list/', 10000, false); + this.sourceType = sourceType; + } + + /** + * Get body parameters + * @return {Object} The values of body parameters (name of parameter: value of the parameter) + */ + bodyParameters() { + let params = {}; + + return params; + } + + /** + * Get query parameters + * @return {Object} The values of query parameters (name of parameter: value of the parameter) + */ + queryParameters() { + let params = {}; + params.sourceType = this.sourceType; + return params; + } +} + +exports.ListSegmentations = ListSegmentations diff --git a/lib/requests/list-series-items.js b/lib/requests/list-series-items.js index 6e71be9..e9ac728 100644 --- a/lib/requests/list-series-items.js +++ b/lib/requests/list-series-items.js @@ -6,13 +6,13 @@ const rqs = require("./request"); /** - * List all the items present in the given series, sorted according to their time index values. + * Lists all the items present in the given series, sorted according to their time index values. */ class ListSeriesItems extends rqs.Request { /** * Construct the request - * @param {string} seriesId - ID of the series items of which are to be listed. + * @param {string} seriesId - ID of the series whose items are to be listed. */ constructor(seriesId) { super('GET', `/series/${seriesId}/items/`, 100000, false); diff --git a/lib/requests/list-user-bookmarks.js b/lib/requests/list-user-bookmarks.js index a4a6dba..96cdf6c 100644 --- a/lib/requests/list-user-bookmarks.js +++ b/lib/requests/list-user-bookmarks.js @@ -6,7 +6,7 @@ const rqs = require("./request"); /** - * List all the bookmarks ever made by a given user. + * Lists all the bookmarks ever made by the given user. */ class ListUserBookmarks extends rqs.Request { diff --git a/lib/requests/list-user-cart-additions.js b/lib/requests/list-user-cart-additions.js index d98881d..94da6a3 100644 --- a/lib/requests/list-user-cart-additions.js +++ b/lib/requests/list-user-cart-additions.js @@ -6,7 +6,7 @@ const rqs = require("./request"); /** - * List all the cart additions ever made by a given user. + * Lists all the cart additions ever made by the given user. */ class ListUserCartAdditions extends rqs.Request { diff --git a/lib/requests/list-user-detail-views.js b/lib/requests/list-user-detail-views.js index 392ceff..fafe508 100644 --- a/lib/requests/list-user-detail-views.js +++ b/lib/requests/list-user-detail-views.js @@ -6,7 +6,7 @@ const rqs = require("./request"); /** - * Lists all the detail views of different items ever made by a given user. + * Lists all the detail views of different items ever made by the given user. */ class ListUserDetailViews extends rqs.Request { diff --git a/lib/requests/list-user-purchases.js b/lib/requests/list-user-purchases.js index 92f56cf..99d1036 100644 --- a/lib/requests/list-user-purchases.js +++ b/lib/requests/list-user-purchases.js @@ -6,7 +6,7 @@ const rqs = require("./request"); /** - * List all the purchases ever made by a given user. + * Lists all the purchases ever made by the given user. */ class ListUserPurchases extends rqs.Request { diff --git a/lib/requests/list-user-ratings.js b/lib/requests/list-user-ratings.js index c68c836..f074a84 100644 --- a/lib/requests/list-user-ratings.js +++ b/lib/requests/list-user-ratings.js @@ -6,7 +6,7 @@ const rqs = require("./request"); /** - * List all the ratings ever submitted by a given user. + * Lists all the ratings ever submitted by the given user. */ class ListUserRatings extends rqs.Request { diff --git a/lib/requests/list-user-view-portions.js b/lib/requests/list-user-view-portions.js index 3f9941b..4f08e0e 100644 --- a/lib/requests/list-user-view-portions.js +++ b/lib/requests/list-user-view-portions.js @@ -6,7 +6,7 @@ const rqs = require("./request"); /** - * List all the view portions ever submitted by a given user. + * Lists all the view portions ever submitted by the given user. */ class ListUserViewPortions extends rqs.Request { diff --git a/lib/requests/list-users.js b/lib/requests/list-users.js index 8a4eda4..e4f7936 100644 --- a/lib/requests/list-users.js +++ b/lib/requests/list-users.js @@ -43,7 +43,7 @@ class ListUsers extends rqs.Request { * ``` * - *includedProperties* * - Type: string[] - * - Description: Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. + * - Description: Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. * Example response for `includedProperties=country`: * ``` * [ diff --git a/lib/requests/merge-users.js b/lib/requests/merge-users.js index 7e493c8..212b2c9 100644 --- a/lib/requests/merge-users.js +++ b/lib/requests/merge-users.js @@ -6,14 +6,14 @@ const rqs = require("./request"); /** - * Merges interactions (purchases, ratings, bookmarks, detail views ...) of two different users under a single user ID. This is especially useful for online e-commerce applications working with anonymous users identified by unique tokens such as the session ID. In such applications, it may often happen that a user owns a persistent account, yet accesses the system anonymously while, e.g., putting items into a shopping cart. At some point in time, such as when the user wishes to confirm the purchase, (s)he logs into the system using his/her username and password. The interactions made under anonymous session ID then become connected with the persistent account, and merging these two together becomes desirable. + * Merges interactions (purchases, ratings, bookmarks, detail views ...) of two different users under a single user ID. This is especially useful for online e-commerce applications working with anonymous users identified by unique tokens such as the session ID. In such applications, it may often happen that a user owns a persistent account, yet accesses the system anonymously while, e.g., putting items into a shopping cart. At some point in time, such as when the user wishes to confirm the purchase, (s)he logs into the system using his/her username and password. The interactions made under anonymous session ID then become connected with the persistent account, and merging these two becomes desirable. * Merging happens between two users referred to as the *target* and the *source*. After the merge, all the interactions of the source user are attributed to the target user, and the source user is **deleted**. */ class MergeUsers extends rqs.Request { /** * Construct the request - * @param {string} targetUserId - ID of the targer user. + * @param {string} targetUserId - ID of the target user. * @param {string} sourceUserId - ID of the source user. * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value * - Allowed parameters: diff --git a/lib/requests/recommend-item-segments-to-item-segment.js b/lib/requests/recommend-item-segments-to-item-segment.js new file mode 100644 index 0000000..b1d3333 --- /dev/null +++ b/lib/requests/recommend-item-segments-to-item-segment.js @@ -0,0 +1,125 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict'; +const rqs = require("./request"); + +/** + * Recommends Segments from a result Segmentation that are the most relevant to a particular Segment from a context Segmentation. + * Based on the used Segmentations, this endpoint can be used for example for: + * - Recommending the related brands to particular brand + * - Recommending the related brands to particular category + * - Recommending the related artists to a particular genre (assuming songs are the Items) + * You need to set the used context and result Segmentation the Admin UI in the Scenario settings prior to using this endpoint. + * The returned segments are sorted by relevance (first segment being the most relevant). + * It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters. + */ +class RecommendItemSegmentsToItemSegment extends rqs.Request { + + /** + * Construct the request + * @param {string} contextSegmentId - ID of the segment from `contextSegmentationId` for which the recommendations are to be generated. + * @param {string} targetUserId - ID of the user who will see the recommendations. + * Specifying the *targetUserId* is beneficial because: + * * It makes the recommendations personalized + * * Allows the calculation of Actions and Conversions + * in the graphical user interface, + * as Recombee can pair the user who got recommendations + * and who afterward viewed/purchased an item. + * If you insist on not specifying the user, pass `null` + * (`None`, `nil`, `NULL` etc., depending on the language) to *targetUserId*. + * Do not create some special dummy user for getting recommendations, + * as it could mislead the recommendation models, + * and result in wrong recommendations. + * For anonymous/unregistered users, it is possible to use, for example, their session ID. + * @param {number} count - Number of item segments to be recommended (N for the top-N recommendation). + * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value + * - Allowed parameters: + * - *scenario* + * - Type: string + * - Description: Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing". + * You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs. + * The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios. + * - *cascadeCreate* + * - Type: boolean + * - Description: If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows, for example, rotations in the following recommendations for that user, as the user will be already known to the system. + * - *filter* + * - Type: string + * - Description: Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended segments based on the `segmentationId`. + * - *booster* + * - Type: string + * - Description: Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some segments based on the `segmentationId`. + * - *logic* + * - Type: string| + * - Description: Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. + * See [this section](https://docs.recombee.com/recommendation_logics.html) for a list of available logics and other details. + * The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users. + * Logic can also be set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * - *expertSettings* + * - Type: + * - Description: Dictionary of custom options. + * - *returnAbGroup* + * - Type: boolean + * - Description: If there is a custom AB-testing running, return the name of the group to which the request belongs. + */ + constructor(contextSegmentId, targetUserId, count, optional) { + super('POST', '/recomms/item-segments/item-segments/', 3000, false); + this.contextSegmentId = contextSegmentId; + this.targetUserId = targetUserId; + this.count = count; + optional = optional || {}; + this.scenario = optional.scenario; + this.cascadeCreate = optional.cascadeCreate; + this.filter = optional.filter; + this.booster = optional.booster; + this.logic = optional.logic; + this.expertSettings = optional.expertSettings; + this.returnAbGroup = optional.returnAbGroup; + } + + /** + * Get body parameters + * @return {Object} The values of body parameters (name of parameter: value of the parameter) + */ + bodyParameters() { + let params = {}; + params.contextSegmentId = this.contextSegmentId; + params.targetUserId = this.targetUserId; + params.count = this.count; + + if(this.scenario !== undefined) + params.scenario = this.scenario; + + if(this.cascadeCreate !== undefined) + params.cascadeCreate = this.cascadeCreate; + + if(this.filter !== undefined) + params.filter = this.filter; + + if(this.booster !== undefined) + params.booster = this.booster; + + if(this.logic !== undefined) + params.logic = this.logic; + + if(this.expertSettings !== undefined) + params.expertSettings = this.expertSettings; + + if(this.returnAbGroup !== undefined) + params.returnAbGroup = this.returnAbGroup; + + 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.RecommendItemSegmentsToItemSegment = RecommendItemSegmentsToItemSegment diff --git a/lib/requests/recommend-item-segments-to-item.js b/lib/requests/recommend-item-segments-to-item.js new file mode 100644 index 0000000..7341f55 --- /dev/null +++ b/lib/requests/recommend-item-segments-to-item.js @@ -0,0 +1,125 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict'; +const rqs = require("./request"); + +/** + * Recommends Segments from a Segmentation that are the most relevant to a particular item. + * Based on the used Segmentation, this endpoint can be used for example for: + * - Recommending the related categories + * - Recommending the related genres + * - Recommending the related brands + * - Recommending the related artists + * You need to set the used Segmentation the Admin UI in the Scenario settings prior to using this endpoint. + * The returned segments are sorted by relevance (first segment being the most relevant). + * It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters. + */ +class RecommendItemSegmentsToItem extends rqs.Request { + + /** + * Construct the request + * @param {string} itemId - ID of the item for which the recommendations are to be generated. + * @param {string} targetUserId - ID of the user who will see the recommendations. + * Specifying the *targetUserId* is beneficial because: + * * It makes the recommendations personalized + * * Allows the calculation of Actions and Conversions + * in the graphical user interface, + * as Recombee can pair the user who got recommendations + * and who afterward viewed/purchased an item. + * If you insist on not specifying the user, pass `null` + * (`None`, `nil`, `NULL` etc., depending on the language) to *targetUserId*. + * Do not create some special dummy user for getting recommendations, + * as it could mislead the recommendation models, + * and result in wrong recommendations. + * For anonymous/unregistered users, it is possible to use, for example, their session ID. + * @param {number} count - Number of item segments to be recommended (N for the top-N recommendation). + * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value + * - Allowed parameters: + * - *scenario* + * - Type: string + * - Description: Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing". + * You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs. + * The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios. + * - *cascadeCreate* + * - Type: boolean + * - Description: If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows, for example, rotations in the following recommendations for that user, as the user will be already known to the system. + * - *filter* + * - Type: string + * - Description: Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended segments based on the `segmentationId`. + * - *booster* + * - Type: string + * - Description: Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some segments based on the `segmentationId`. + * - *logic* + * - Type: string| + * - Description: Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. + * See [this section](https://docs.recombee.com/recommendation_logics.html) for a list of available logics and other details. + * The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users. + * Logic can also be set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * - *expertSettings* + * - Type: + * - Description: Dictionary of custom options. + * - *returnAbGroup* + * - Type: boolean + * - Description: If there is a custom AB-testing running, return the name of the group to which the request belongs. + */ + constructor(itemId, targetUserId, count, optional) { + super('POST', `/recomms/items/${itemId}/item-segments/`, 3000, false); + this.itemId = itemId; + this.targetUserId = targetUserId; + this.count = count; + optional = optional || {}; + this.scenario = optional.scenario; + this.cascadeCreate = optional.cascadeCreate; + this.filter = optional.filter; + this.booster = optional.booster; + this.logic = optional.logic; + this.expertSettings = optional.expertSettings; + this.returnAbGroup = optional.returnAbGroup; + } + + /** + * Get body parameters + * @return {Object} The values of body parameters (name of parameter: value of the parameter) + */ + bodyParameters() { + let params = {}; + params.targetUserId = this.targetUserId; + params.count = this.count; + + if(this.scenario !== undefined) + params.scenario = this.scenario; + + if(this.cascadeCreate !== undefined) + params.cascadeCreate = this.cascadeCreate; + + if(this.filter !== undefined) + params.filter = this.filter; + + if(this.booster !== undefined) + params.booster = this.booster; + + if(this.logic !== undefined) + params.logic = this.logic; + + if(this.expertSettings !== undefined) + params.expertSettings = this.expertSettings; + + if(this.returnAbGroup !== undefined) + params.returnAbGroup = this.returnAbGroup; + + 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.RecommendItemSegmentsToItem = RecommendItemSegmentsToItem diff --git a/lib/requests/recommend-item-segments-to-user.js b/lib/requests/recommend-item-segments-to-user.js new file mode 100644 index 0000000..6a12e8b --- /dev/null +++ b/lib/requests/recommend-item-segments-to-user.js @@ -0,0 +1,110 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict'; +const rqs = require("./request"); + +/** + * Recommends the top Segments from a Segmentation for a particular user, based on the user's past interactions. + * Based on the used Segmentation, this endpoint can be used for example for: + * - Recommending the top categories for the user + * - Recommending the top genres for the user + * - Recommending the top brands for the user + * - Recommending the top artists for the user + * You need to set the used Segmentation the Admin UI in the Scenario settings prior to using this endpoint. + * The returned segments are sorted by relevance (first segment being the most relevant). + * It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters. + */ +class RecommendItemSegmentsToUser extends rqs.Request { + + /** + * Construct the request + * @param {string} userId - ID of the user for whom personalized recommendations are to be generated. + * @param {number} count - Number of item segments to be recommended (N for the top-N recommendation). + * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value + * - Allowed parameters: + * - *scenario* + * - Type: string + * - Description: Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing". + * You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs. + * The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios. + * - *cascadeCreate* + * - Type: boolean + * - Description: If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows, for example, rotations in the following recommendations for that user, as the user will be already known to the system. + * - *filter* + * - Type: string + * - Description: Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended segments based on the `segmentationId`. + * - *booster* + * - Type: string + * - Description: Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some segments based on the `segmentationId`. + * - *logic* + * - Type: string| + * - Description: Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. + * See [this section](https://docs.recombee.com/recommendation_logics.html) for a list of available logics and other details. + * The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users. + * Logic can also be set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * - *expertSettings* + * - Type: + * - Description: Dictionary of custom options. + * - *returnAbGroup* + * - Type: boolean + * - Description: If there is a custom AB-testing running, return the name of the group to which the request belongs. + */ + constructor(userId, count, optional) { + super('POST', `/recomms/users/${userId}/item-segments/`, 3000, false); + this.userId = userId; + this.count = count; + optional = optional || {}; + this.scenario = optional.scenario; + this.cascadeCreate = optional.cascadeCreate; + this.filter = optional.filter; + this.booster = optional.booster; + this.logic = optional.logic; + this.expertSettings = optional.expertSettings; + this.returnAbGroup = optional.returnAbGroup; + } + + /** + * Get body parameters + * @return {Object} The values of body parameters (name of parameter: value of the parameter) + */ + bodyParameters() { + let params = {}; + params.count = this.count; + + if(this.scenario !== undefined) + params.scenario = this.scenario; + + if(this.cascadeCreate !== undefined) + params.cascadeCreate = this.cascadeCreate; + + if(this.filter !== undefined) + params.filter = this.filter; + + if(this.booster !== undefined) + params.booster = this.booster; + + if(this.logic !== undefined) + params.logic = this.logic; + + if(this.expertSettings !== undefined) + params.expertSettings = this.expertSettings; + + if(this.returnAbGroup !== undefined) + params.returnAbGroup = this.returnAbGroup; + + 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.RecommendItemSegmentsToUser = RecommendItemSegmentsToUser diff --git a/lib/requests/recommend-items-to-item.js b/lib/requests/recommend-items-to-item.js index a87d836..5e22c20 100644 --- a/lib/requests/recommend-items-to-item.js +++ b/lib/requests/recommend-items-to-item.js @@ -6,12 +6,12 @@ const rqs = require("./request"); /** - * Recommends set of items that are somehow related to one given item, *X*. Typical scenario is when user *A* is viewing *X*. Then you may display items to the user that he might be also interested in. Recommend items to item request gives you Top-N such items, optionally taking the target user *A* into account. - * The returned items are sorted by relevance (first item being the most relevant). + * Recommends a set of items that are somehow related to one given item, *X*. A typical scenario is when the user *A* is viewing *X*. Then you may display items to the user that he might also be interested in. Recommend items to item request gives you Top-N such items, optionally taking the target user *A* into account. + * The returned items are sorted by relevance (the first item being the most relevant). * Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to: - * - Let Recombee know that this recommendation was successful (e.g. user clicked one of the recommended items). See [Reported metrics](https://docs.recombee.com/admin_ui.html#reported-metrics). + * - Let Recombee know that this recommendation was successful (e.g., user clicked one of the recommended items). See [Reported metrics](https://docs.recombee.com/admin_ui.html#reported-metrics). * - Get subsequent recommended items when the user scrolls down (*infinite scroll*) or goes to the next page. See [Recommend Next Items](https://docs.recombee.com/api.html#recommend-next-items). - * It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters. + * It is also possible to use POST HTTP method (for example in the case of a very long ReQL filter) - query parameters then become body parameters. */ class RecommendItemsToItem extends rqs.Request { @@ -24,27 +24,27 @@ class RecommendItemsToItem extends rqs.Request { * * Allows the calculation of Actions and Conversions * in the graphical user interface, * as Recombee can pair the user who got recommendations - * and who afterwards viewed/purchased an item. + * and who afterward viewed/purchased an item. * If you insist on not specifying the user, pass `null` - * (`None`, `nil`, `NULL` etc. depending on language) to *targetUserId*. + * (`None`, `nil`, `NULL` etc., depending on the language) to *targetUserId*. * Do not create some special dummy user for getting recommendations, * as it could mislead the recommendation models, * and result in wrong recommendations. - * For anonymous/unregistered users it is possible to use for example their session ID. + * For anonymous/unregistered users, it is possible to use, for example, their session ID. * @param {number} count - Number of items to be recommended (N for the top-N recommendation). * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value * - Allowed parameters: * - *scenario* * - Type: string - * - Description: Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". - * You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see performance of each scenario in the Admin UI separately, so you can check how well each application performs. - * The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios. + * - Description: Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing". + * You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs. + * The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios. * - *cascadeCreate* * - Type: boolean - * - Description: If item of given *itemId* or user of given *targetUserId* doesn't exist in the database, it creates the missing entity/entities and returns some (non-personalized) recommendations. This allows for example rotations in the following recommendations for the user of given *targetUserId*, as the user will be already known to the system. + * - Description: If an item of the given *itemId* or user of the given *targetUserId* doesn't exist in the database, it creates the missing entity/entities and returns some (non-personalized) recommendations. This allows, for example, rotations in the following recommendations for the user of the given *targetUserId*, as the user will be already known to the system. * - *returnProperties* * - Type: boolean - * - Description: With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying of the recommended items to the user. + * - Description: With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended items to the user. * Example response: * ``` * { @@ -75,7 +75,7 @@ class RecommendItemsToItem extends rqs.Request { * ``` * - *includedProperties* * - Type: string[] - * - Description: Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. + * - Description: Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. * Example response for `includedProperties=description,price`: * ``` * { @@ -102,39 +102,39 @@ class RecommendItemsToItem extends rqs.Request { * ``` * - *filter* * - Type: string - * - Description: Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes. - * Filters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * - Description: Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression, which allows you to filter recommended items based on the values of their attributes. + * Filters can also be assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). * - *booster* * - Type: string - * - Description: Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes. - * Boosters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * - Description: Number-returning [ReQL](https://docs.recombee.com/reql.html) expression, which allows you to boost the recommendation rate of some items based on the values of their attributes. + * Boosters can also be assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). * - *logic* * - Type: string| - * - Description: Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. - * See [this section](https://docs.recombee.com/recommendation_logics.html) for list of available logics and other details. + * - Description: Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. + * See [this section](https://docs.recombee.com/recommendation_logics.html) for a list of available logics and other details. * The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users. - * Logic can be also set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * Logic can also be set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). * - *userImpact* * - Type: number - * - Description: **Expert option** If *targetUserId* parameter is present, the recommendations are biased towards the given user. Using *userImpact*, you may control this bias. For an extreme case of `userImpact=0.0`, the interactions made by the user are not taken into account at all (with the exception of history-based blacklisting), for `userImpact=1.0`, you'll get user-based recommendation. The default value is `0`. + * - Description: **Expert option** If *targetUserId* parameter is present, the recommendations are biased towards the given user. Using *userImpact*, you may control this bias. For an extreme case of `userImpact=0.0`, the interactions made by the user are not taken into account at all (with the exception of history-based blacklisting), for `userImpact=1.0`, you'll get a user-based recommendation. The default value is `0`. * - *diversity* * - Type: number - * - Description: **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended items be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification. + * - Description: **Expert option** Real number from [0.0, 1.0], which determines how mutually dissimilar the recommended items should be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification. * - *minRelevance* * - Type: string - * - Description: **Expert option** If the *targetUserId* is provided: Specifies the threshold of how much relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend number of items equal to *count* at any cost. If there are not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested relevance, and may return less than *count* items when there is not enough data to fulfill it. + * - Description: **Expert option** If the *targetUserId* is provided: Specifies the threshold of how relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend a number of items equal to *count* at any cost. If there is not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations being appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested relevance and may return less than *count* items when there is not enough data to fulfill it. * - *rotationRate* * - Type: number - * - Description: **Expert option** If the *targetUserId* is provided: If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended items. + * - Description: **Expert option** If the *targetUserId* is provided: If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per request in a backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example, `rotationRate=0.2` for only slight rotation of recommended items. * - *rotationTime* * - Type: number - * - Description: **Expert option** If the *targetUserId* is provided: Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized. + * - Description: **Expert option** If the *targetUserId* is provided: Taking *rotationRate* into account, specifies how long it takes for an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized. * - *expertSettings* * - Type: * - Description: Dictionary of custom options. * - *returnAbGroup* * - Type: boolean - * - Description: If there is a custom AB-testing running, return name of group to which the request belongs. + * - Description: If there is a custom AB-testing running, return the name of the group to which the request belongs. */ constructor(itemId, targetUserId, count, optional) { super('POST', `/recomms/items/${itemId}/items/`, 3000, false); diff --git a/lib/requests/recommend-items-to-user.js b/lib/requests/recommend-items-to-user.js index f6c84e5..67ce5d2 100644 --- a/lib/requests/recommend-items-to-user.js +++ b/lib/requests/recommend-items-to-user.js @@ -6,13 +6,13 @@ const rqs = require("./request"); /** - * Based on user's past interactions (purchases, ratings, etc.) with the items, recommends top-N items that are most likely to be of high value for a given user. - * The most typical use cases are recommendations at homepage, in some "Picked just for you" section or in email. - * The returned items are sorted by relevance (first item being the most relevant). + * Based on the user's past interactions (purchases, ratings, etc.) with the items, recommends top-N items that are most likely to be of high value for the given user. + * The most typical use cases are recommendations on the homepage, in some "Picked just for you" section, or in email. + * The returned items are sorted by relevance (the first item being the most relevant). * Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to: - * - Let Recombee know that this recommendation was successful (e.g. user clicked one of the recommended items). See [Reported metrics](https://docs.recombee.com/admin_ui.html#reported-metrics). + * - Let Recombee know that this recommendation was successful (e.g., user clicked one of the recommended items). See [Reported metrics](https://docs.recombee.com/admin_ui.html#reported-metrics). * - Get subsequent recommended items when the user scrolls down (*infinite scroll*) or goes to the next page. See [Recommend Next Items](https://docs.recombee.com/api.html#recommend-next-items). - * It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters. + * It is also possible to use POST HTTP method (for example in the case of a very long ReQL filter) - query parameters then become body parameters. */ class RecommendItemsToUser extends rqs.Request { @@ -24,15 +24,15 @@ class RecommendItemsToUser extends rqs.Request { * - Allowed parameters: * - *scenario* * - Type: string - * - Description: Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". - * You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see performance of each scenario in the Admin UI separately, so you can check how well each application performs. - * The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios. + * - Description: Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing". + * You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs. + * The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios. * - *cascadeCreate* * - Type: boolean - * - Description: If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows for example rotations in the following recommendations for that user, as the user will be already known to the system. + * - Description: If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows, for example, rotations in the following recommendations for that user, as the user will be already known to the system. * - *returnProperties* * - Type: boolean - * - Description: With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying of the recommended items to the user. + * - Description: With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended items to the user. * Example response: * ``` * { @@ -63,7 +63,7 @@ class RecommendItemsToUser extends rqs.Request { * ``` * - *includedProperties* * - Type: string[] - * - Description: Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. + * - Description: Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. * Example response for `includedProperties=description,price`: * ``` * { @@ -90,36 +90,36 @@ class RecommendItemsToUser extends rqs.Request { * ``` * - *filter* * - Type: string - * - Description: Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes. - * Filters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * - Description: Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression, which allows you to filter recommended items based on the values of their attributes. + * Filters can also be assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). * - *booster* * - Type: string - * - Description: Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes. - * Boosters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * - Description: Number-returning [ReQL](https://docs.recombee.com/reql.html) expression, which allows you to boost the recommendation rate of some items based on the values of their attributes. + * Boosters can also be assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). * - *logic* * - Type: string| - * - Description: Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. - * See [this section](https://docs.recombee.com/recommendation_logics.html) for list of available logics and other details. + * - Description: Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. + * See [this section](https://docs.recombee.com/recommendation_logics.html) for a list of available logics and other details. * The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users. - * Logic can be also set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * Logic can also be set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). * - *diversity* * - Type: number - * - Description: **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended items be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification. + * - Description: **Expert option** Real number from [0.0, 1.0], which determines how mutually dissimilar the recommended items should be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification. * - *minRelevance* * - Type: string - * - Description: **Expert option** Specifies the threshold of how much relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend number of items equal to *count* at any cost. If there are not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested relevance, and may return less than *count* items when there is not enough data to fulfill it. + * - Description: **Expert option** Specifies the threshold of how relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend a number of items equal to *count* at any cost. If there is not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such a case, the system only recommends items of at least the requested relevance and may return less than *count* items when there is not enough data to fulfill it. * - *rotationRate* * - Type: number - * - Description: **Expert option** If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended items. Default: `0`. + * - Description: **Expert option** If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per request in a backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example, `rotationRate=0.2` for only slight rotation of recommended items. Default: `0`. * - *rotationTime* * - Type: number - * - Description: **Expert option** Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized. Default: `7200.0`. + * - Description: **Expert option** Taking *rotationRate* into account, specifies how long it takes for an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized. Default: `7200.0`. * - *expertSettings* * - Type: * - Description: Dictionary of custom options. * - *returnAbGroup* * - Type: boolean - * - Description: If there is a custom AB-testing running, return name of group to which the request belongs. + * - Description: If there is a custom AB-testing running, return the name of the group to which the request belongs. */ constructor(userId, count, optional) { super('POST', `/recomms/users/${userId}/items/`, 3000, false); diff --git a/lib/requests/recommend-next-items.js b/lib/requests/recommend-next-items.js index 29f1c1e..58f1b8f 100644 --- a/lib/requests/recommend-next-items.js +++ b/lib/requests/recommend-next-items.js @@ -6,8 +6,8 @@ const rqs = require("./request"); /** - * Returns items that shall be shown to a user as next recommendations when the user e.g. scrolls the page down (*infinite scroll*) or goes to a next page. - * It accepts `recommId` of a base recommendation request (e.g. request from the first page) and number of items that shall be returned (`count`). + * Returns items that shall be shown to a user as next recommendations when the user e.g. scrolls the page down (*infinite scroll*) or goes to the next page. + * It accepts `recommId` of a base recommendation request (e.g., request from the first page) and the number of items that shall be returned (`count`). * The base request can be one of: * - [Recommend items to item](https://docs.recombee.com/api.html#recommend-items-to-item) * - [Recommend items to user](https://docs.recombee.com/api.html#recommend-items-to-user) diff --git a/lib/requests/recommend-users-to-item.js b/lib/requests/recommend-users-to-item.js index 5e77fbe..1c65bf6 100644 --- a/lib/requests/recommend-users-to-item.js +++ b/lib/requests/recommend-users-to-item.js @@ -6,9 +6,9 @@ const rqs = require("./request"); /** - * Recommend users that are likely to be interested in a given item. - * It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters. - * The returned users are sorted by predicted interest in the item (first user being the most interested). + * Recommends users that are likely to be interested in the given item. + * It is also possible to use POST HTTP method (for example in the case of a very long ReQL filter) - query parameters then become body parameters. + * The returned users are sorted by predicted interest in the item (the first user being the most interested). */ class RecommendUsersToItem extends rqs.Request { @@ -20,15 +20,15 @@ class RecommendUsersToItem extends rqs.Request { * - Allowed parameters: * - *scenario* * - Type: string - * - Description: Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". - * You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see performance of each scenario in the Admin UI separately, so you can check how well each application performs. - * The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios. + * - Description: Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing". + * You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs. + * The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios. * - *cascadeCreate* * - Type: boolean - * - Description: If item of given *itemId* doesn't exist in the database, it creates the missing item. + * - Description: If an item of the given *itemId* doesn't exist in the database, it creates the missing item. * - *returnProperties* * - Type: boolean - * - Description: With `returnProperties=true`, property values of the recommended users are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying the recommended users. + * - Description: With `returnProperties=true`, property values of the recommended users are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended users. * Example response: * ``` * { @@ -55,7 +55,7 @@ class RecommendUsersToItem extends rqs.Request { * ``` * - *includedProperties* * - Type: string[] - * - Description: Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. + * - Description: Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. * Example response for `includedProperties=country`: * ``` * { @@ -80,27 +80,27 @@ class RecommendUsersToItem extends rqs.Request { * ``` * - *filter* * - Type: string - * - Description: Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes. - * Filters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * - Description: Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression, which allows you to filter recommended items based on the values of their attributes. + * Filters can also be assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). * - *booster* * - Type: string - * - Description: Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes. - * Boosters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * - Description: Number-returning [ReQL](https://docs.recombee.com/reql.html) expression, which allows you to boost the recommendation rate of some items based on the values of their attributes. + * Boosters can also be assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). * - *logic* * - Type: string| - * - Description: Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. - * See [this section](https://docs.recombee.com/recommendation_logics.html) for list of available logics and other details. + * - Description: Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. + * See [this section](https://docs.recombee.com/recommendation_logics.html) for a list of available logics and other details. * The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users. - * Logic can be also set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * Logic can also be set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). * - *diversity* * - Type: number - * - Description: **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended items be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification. + * - Description: **Expert option** Real number from [0.0, 1.0], which determines how mutually dissimilar the recommended items should be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification. * - *expertSettings* * - Type: * - Description: Dictionary of custom options. * - *returnAbGroup* * - Type: boolean - * - Description: If there is a custom AB-testing running, return name of group to which the request belongs. + * - Description: If there is a custom AB-testing running, return the name of the group to which the request belongs. */ constructor(itemId, count, optional) { super('POST', `/recomms/items/${itemId}/users/`, 50000, false); diff --git a/lib/requests/recommend-users-to-user.js b/lib/requests/recommend-users-to-user.js index 4b4e716..838d9cb 100644 --- a/lib/requests/recommend-users-to-user.js +++ b/lib/requests/recommend-users-to-user.js @@ -6,9 +6,9 @@ const rqs = require("./request"); /** - * Get similar users as some given user, based on the user's past interactions (purchases, ratings, etc.) and values of properties. - * It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters. - * The returned users are sorted by similarity (first user being the most similar). + * Gets users similar to the given user, based on the user's past interactions (purchases, ratings, etc.) and values of properties. + * It is also possible to use POST HTTP method (for example in the case of a very long ReQL filter) - query parameters then become body parameters. + * The returned users are sorted by similarity (the first user being the most similar). */ class RecommendUsersToUser extends rqs.Request { @@ -20,15 +20,15 @@ class RecommendUsersToUser extends rqs.Request { * - Allowed parameters: * - *scenario* * - Type: string - * - Description: Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". - * You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see performance of each scenario in the Admin UI separately, so you can check how well each application performs. - * The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios. + * - Description: Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing". + * You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs. + * The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios. * - *cascadeCreate* * - Type: boolean - * - Description: If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows for example rotations in the following recommendations for that user, as the user will be already known to the system. + * - Description: If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows, for example, rotations in the following recommendations for that user, as the user will be already known to the system. * - *returnProperties* * - Type: boolean - * - Description: With `returnProperties=true`, property values of the recommended users are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying the recommended users. + * - Description: With `returnProperties=true`, property values of the recommended users are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended users. * Example response: * ``` * { @@ -55,7 +55,7 @@ class RecommendUsersToUser extends rqs.Request { * ``` * - *includedProperties* * - Type: string[] - * - Description: Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. + * - Description: Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. * Example response for `includedProperties=country`: * ``` * { @@ -80,36 +80,36 @@ class RecommendUsersToUser extends rqs.Request { * ``` * - *filter* * - Type: string - * - Description: Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes. - * Filters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * - Description: Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression, which allows you to filter recommended items based on the values of their attributes. + * Filters can also be assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). * - *booster* * - Type: string - * - Description: Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes. - * Boosters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * - Description: Number-returning [ReQL](https://docs.recombee.com/reql.html) expression, which allows you to boost the recommendation rate of some items based on the values of their attributes. + * Boosters can also be assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). * - *logic* * - Type: string| - * - Description: Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. - * See [this section](https://docs.recombee.com/recommendation_logics.html) for list of available logics and other details. + * - Description: Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. + * See [this section](https://docs.recombee.com/recommendation_logics.html) for a list of available logics and other details. * The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users. - * Logic can be also set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * Logic can also be set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). * - *diversity* * - Type: number - * - Description: **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended users be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification. + * - Description: **Expert option** Real number from [0.0, 1.0], which determines how mutually dissimilar the recommended users should be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification. * - *minRelevance* * - Type: string - * - Description: **Expert option** Specifies the threshold of how much relevant must the recommended users be. Possible values one of: "low", "medium", "high". + * - Description: **Expert option** Specifies the threshold of how relevant must the recommended users be. Possible values one of: "low", "medium", "high". * - *rotationRate* * - Type: number - * - Description: **Expert option** If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an user for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended users. + * - Description: **Expert option** If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per request in a backward fashion. You may penalize a user for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example, `rotationRate=0.2` for only slight rotation of recommended users. * - *rotationTime* * - Type: number - * - Description: **Expert option** Taking *rotationRate* into account, specifies how long time it takes to an user to recover from the penalization. For example, `rotationTime=7200.0` means that users recommended less than 2 hours ago are penalized. + * - Description: **Expert option** Taking *rotationRate* into account, specifies how long it takes for a user to recover from the penalization. For example, `rotationTime=7200.0` means that users recommended less than 2 hours ago are penalized. * - *expertSettings* * - Type: * - Description: Dictionary of custom options. * - *returnAbGroup* * - Type: boolean - * - Description: If there is a custom AB-testing running, return name of group to which the request belongs. + * - Description: If there is a custom AB-testing running, return the name of the group to which the request belongs. */ constructor(userId, count, optional) { super('POST', `/recomms/users/${userId}/users/`, 50000, false); diff --git a/lib/requests/reset-database.js b/lib/requests/reset-database.js index e5939c4..e3543e7 100644 --- a/lib/requests/reset-database.js +++ b/lib/requests/reset-database.js @@ -6,7 +6,7 @@ const rqs = require("./request"); /** - * Completely erases all your data, including items, item properties, series, user database, purchases, ratings, detail views, and bookmarks. Make sure the request to be never executed in production environment! Resetting your database is irreversible. + * Completely erases all your data, including items, item properties, series, user database, purchases, ratings, detail views, and bookmarks. Make sure the request is never executed in the production environment! Resetting your database is irreversible. */ class ResetDatabase extends rqs.Request { diff --git a/lib/requests/search-item-segments.js b/lib/requests/search-item-segments.js new file mode 100644 index 0000000..a9e2f33 --- /dev/null +++ b/lib/requests/search-item-segments.js @@ -0,0 +1,112 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict'; +const rqs = require("./request"); + +/** + * Full-text personalized search that returns Segments from a Segmentation. The results are based on the provided `searchQuery` and also on the user's past interactions (purchases, ratings, etc.). + * Based on the used Segmentation, this endpoint can be used for example for: + * - Searching within categories or brands + * - Searching within genres or artists + * For example if the user is searching for "iPhone" this endpoint can return "cell phones" category. + * You need to set the used Segmentation the Admin UI in the Scenario settings prior to using this endpoint. + * The returned segments are sorted by relevance (first segment being the most relevant). + * It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters. + */ +class SearchItemSegments extends rqs.Request { + + /** + * Construct the request + * @param {string} userId - ID of the user for whom personalized search will be performed. + * @param {string} searchQuery - Search query provided by the user. It is used for the full-text search. + * @param {number} count - Number of segments to be returned (N for the top-N results). + * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value + * - Allowed parameters: + * - *scenario* + * - Type: string + * - Description: Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing". + * You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs. + * The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios. + * - *cascadeCreate* + * - Type: boolean + * - Description: If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows, for example, rotations in the following recommendations for that user, as the user will be already known to the system. + * - *filter* + * - Type: string + * - Description: Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended segments based on the `segmentationId`. + * - *booster* + * - Type: string + * - Description: Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some segments based on the `segmentationId`. + * - *logic* + * - Type: string| + * - Description: Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. + * See [this section](https://docs.recombee.com/recommendation_logics.html) for a list of available logics and other details. + * The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users. + * Logic can also be set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * - *expertSettings* + * - Type: + * - Description: Dictionary of custom options. + * - *returnAbGroup* + * - Type: boolean + * - Description: If there is a custom AB-testing running, return the name of the group to which the request belongs. + */ + constructor(userId, searchQuery, count, optional) { + super('POST', `/search/users/${userId}/item-segments/`, 3000, false); + this.userId = userId; + this.searchQuery = searchQuery; + this.count = count; + optional = optional || {}; + this.scenario = optional.scenario; + this.cascadeCreate = optional.cascadeCreate; + this.filter = optional.filter; + this.booster = optional.booster; + this.logic = optional.logic; + this.expertSettings = optional.expertSettings; + this.returnAbGroup = optional.returnAbGroup; + } + + /** + * Get body parameters + * @return {Object} The values of body parameters (name of parameter: value of the parameter) + */ + bodyParameters() { + let params = {}; + params.searchQuery = this.searchQuery; + params.count = this.count; + + if(this.scenario !== undefined) + params.scenario = this.scenario; + + if(this.cascadeCreate !== undefined) + params.cascadeCreate = this.cascadeCreate; + + if(this.filter !== undefined) + params.filter = this.filter; + + if(this.booster !== undefined) + params.booster = this.booster; + + if(this.logic !== undefined) + params.logic = this.logic; + + if(this.expertSettings !== undefined) + params.expertSettings = this.expertSettings; + + if(this.returnAbGroup !== undefined) + params.returnAbGroup = this.returnAbGroup; + + 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.SearchItemSegments = SearchItemSegments diff --git a/lib/requests/search-items.js b/lib/requests/search-items.js index 8f7fffe..b72106c 100644 --- a/lib/requests/search-items.js +++ b/lib/requests/search-items.js @@ -8,12 +8,12 @@ const rqs = require("./request"); /** * Full-text personalized search. The results are based on the provided `searchQuery` and also on the user's past interactions (purchases, ratings, etc.) with the items (items more suitable for the user are preferred in the results). * All the string and set item properties are indexed by the search engine. - * This endpoint should be used in a search box at your website/app. It can be called multiple times as the user is typing the query in order to get the most viable suggestions based on current state of the query, or once after submitting the whole query. - * The returned items are sorted by relevance (first item being the most relevant). + * This endpoint should be used in a search box on your website/app. It can be called multiple times as the user is typing the query in order to get the most viable suggestions based on the current state of the query, or once after submitting the whole query. + * The returned items are sorted by relevance (the first item being the most relevant). * Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to: - * - Let Recombee know that this search was successful (e.g. user clicked one of the recommended items). See [Reported metrics](https://docs.recombee.com/admin_ui.html#reported-metrics). + * - Let Recombee know that this search was successful (e.g., user clicked one of the recommended items). See [Reported metrics](https://docs.recombee.com/admin_ui.html#reported-metrics). * - Get subsequent search results when the user scrolls down or goes to the next page. See [Recommend Next Items](https://docs.recombee.com/api.html#recommend-next-items). - * It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters. + * It is also possible to use POST HTTP method (for example in the case of a very long ReQL filter) - query parameters then become body parameters. */ class SearchItems extends rqs.Request { @@ -27,14 +27,14 @@ class SearchItems extends rqs.Request { * - *scenario* * - Type: string * - Description: Scenario defines a particular search field in your user interface. - * You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see performance of each scenario in the Admin UI separately, so you can check how well each field performs. - * The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios. + * You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each field performs. + * The AI that optimizes models to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios. * - *cascadeCreate* * - Type: boolean - * - Description: If the user does not exist in the database, returns a list of non-personalized search results and creates the user in the database. This allows for example rotations in the following recommendations for that user, as the user will be already known to the system. + * - Description: If the user does not exist in the database, returns a list of non-personalized search results and creates the user in the database. This allows, for example, rotations in the following recommendations for that user, as the user will be already known to the system. * - *returnProperties* * - Type: boolean - * - Description: With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying of the recommended items to the user. + * - Description: With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended items to the user. * Example response: * ``` * { @@ -65,7 +65,7 @@ class SearchItems extends rqs.Request { * ``` * - *includedProperties* * - Type: string[] - * - Description: Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. + * - Description: Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. * Example response for `includedProperties=description,price`: * ``` * { @@ -92,24 +92,24 @@ class SearchItems extends rqs.Request { * ``` * - *filter* * - Type: string - * - Description: Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes. - * Filters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * - Description: Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression, which allows you to filter recommended items based on the values of their attributes. + * Filters can also be assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). * - *booster* * - Type: string - * - Description: Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes. - * Boosters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * - Description: Number-returning [ReQL](https://docs.recombee.com/reql.html) expression, which allows you to boost the recommendation rate of some items based on the values of their attributes. + * Boosters can also be assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). * - *logic* * - Type: string| - * - Description: Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. - * See [this section](https://docs.recombee.com/recommendation_logics.html) for list of available logics and other details. + * - Description: Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. + * See [this section](https://docs.recombee.com/recommendation_logics.html) for a list of available logics and other details. * The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users. - * Logic can be also set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). + * Logic can also be set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). * - *expertSettings* * - Type: * - Description: Dictionary of custom options. * - *returnAbGroup* * - Type: boolean - * - Description: If there is a custom AB-testing running, return name of group to which the request belongs. + * - Description: If there is a custom AB-testing running, return the name of the group to which the request belongs. */ constructor(userId, searchQuery, count, optional) { super('POST', `/search/users/${userId}/items/`, 3000, false); diff --git a/lib/requests/set-view-portion.js b/lib/requests/set-view-portion.js index 336fc03..33cf306 100644 --- a/lib/requests/set-view-portion.js +++ b/lib/requests/set-view-portion.js @@ -7,7 +7,7 @@ const rqs = require("./request"); /** * Sets viewed portion of an item (for example a video or article) by a user (at a session). - * If you send new request with the same (`userId`, `itemId`, `sessionId`), the portion gets updated. + * If you send a new request with the same (`userId`, `itemId`, `sessionId`), the portion gets updated. */ class SetViewPortion extends rqs.Request { @@ -15,12 +15,12 @@ class SetViewPortion extends rqs.Request { * Construct the request * @param {string} userId - User who viewed a portion of the item * @param {string} itemId - Viewed item - * @param {number} portion - Viewed portion of the item (number between 0.0 (viewed nothing) and 1.0 (viewed full item) ). It should be the really viewed part of the item, no matter seeking, so for example if the user seeked immediately to half of the item and then viewed 10% of the item, the `portion` should still be `0.1`. + * @param {number} portion - Viewed portion of the item (number between 0.0 (viewed nothing) and 1.0 (viewed full item) ). It should be the actual viewed part of the item, no matter the seeking. For example, if the user seeked immediately to half of the item and then viewed 10% of the item, the `portion` should still be `0.1`. * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value * - Allowed parameters: * - *sessionId* * - Type: string - * - Description: ID of session in which the user viewed the item. Default is `null` (`None`, `nil`, `NULL` etc. depending on language). + * - Description: ID of the session in which the user viewed the item. Default is `null` (`None`, `nil`, `NULL` etc., depending on the language). * - *timestamp* * - Type: string|number * - Description: UTC timestamp of the rating as ISO8601-1 pattern or UTC epoch time. The default value is the current time. diff --git a/lib/requests/update-auto-reql-segmentation.js b/lib/requests/update-auto-reql-segmentation.js new file mode 100644 index 0000000..4a5b29c --- /dev/null +++ b/lib/requests/update-auto-reql-segmentation.js @@ -0,0 +1,66 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict'; +const rqs = require("./request"); + +/** + * Update an existing Segmentation. + */ +class UpdateAutoReqlSegmentation extends rqs.Request { + + /** + * Construct the request + * @param {string} segmentationId - ID of the updated Segmentation + * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value + * - Allowed parameters: + * - *expression* + * - Type: string + * - Description: ReQL expression that returns for each item a set with IDs of segments to which the item belongs + * - *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, optional) { + super('POST', `/segmentations/auto-reql/${segmentationId}`, 10000, false); + this.segmentationId = segmentationId; + optional = optional || {}; + this.expression = optional.expression; + 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 = {}; + + if(this.expression !== undefined) + 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.UpdateAutoReqlSegmentation = UpdateAutoReqlSegmentation diff --git a/lib/requests/update-manual-reql-segment.js b/lib/requests/update-manual-reql-segment.js new file mode 100644 index 0000000..80ad1f0 --- /dev/null +++ b/lib/requests/update-manual-reql-segment.js @@ -0,0 +1,57 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict'; +const rqs = require("./request"); + +/** + * Update definition of the Segment. + */ +class UpdateManualReqlSegment extends rqs.Request { + + /** + * Construct the request + * @param {string} segmentationId - ID of the Segmentation to which the updated Segment belongs + * @param {string} segmentId - ID of the Segment that will be updated + * @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('POST', `/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.UpdateManualReqlSegment = UpdateManualReqlSegment diff --git a/lib/requests/update-manual-reql-segmentation.js b/lib/requests/update-manual-reql-segmentation.js new file mode 100644 index 0000000..408b310 --- /dev/null +++ b/lib/requests/update-manual-reql-segmentation.js @@ -0,0 +1,59 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict'; +const rqs = require("./request"); + +/** + * Update an existing Segmentation. + */ +class UpdateManualReqlSegmentation extends rqs.Request { + + /** + * Construct the request + * @param {string} segmentationId - ID of the updated Segmentation + * @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, optional) { + super('POST', `/segmentations/manual-reql/${segmentationId}`, 10000, false); + this.segmentationId = segmentationId; + 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 = {}; + + 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.UpdateManualReqlSegmentation = UpdateManualReqlSegmentation diff --git a/lib/requests/update-more-items.js b/lib/requests/update-more-items.js index 732f824..6992845 100644 --- a/lib/requests/update-more-items.js +++ b/lib/requests/update-more-items.js @@ -6,7 +6,7 @@ const rqs = require("./request"); /** - * Update (some) property values of all the items that pass the filter. + * Updates (some) property values of all the items that pass the filter. * Example: *Setting all the items that are older than a week as unavailable* * ``` * { @@ -19,8 +19,8 @@ class UpdateMoreItems extends rqs.Request { /** * Construct the request - * @param {string} filter - A [ReQL](https://docs.recombee.com/reql.html) expression, which return `true` for the items that shall be updated. - * @param {} changes - A dictionary where the keys are properties which shall be updated. + * @param {string} filter - A [ReQL](https://docs.recombee.com/reql.html) expression, which returns `true` for the items that shall be updated. + * @param {} changes - A dictionary where the keys are properties that shall be updated. */ constructor(filter, changes) { super('POST', '/more-items/', 1000, false); diff --git a/lib/requests/update-property-based-segmentation.js b/lib/requests/update-property-based-segmentation.js new file mode 100644 index 0000000..5e58fd4 --- /dev/null +++ b/lib/requests/update-property-based-segmentation.js @@ -0,0 +1,66 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict'; +const rqs = require("./request"); + +/** + * Updates a Property Based Segmentation + */ +class UpdatePropertyBasedSegmentation extends rqs.Request { + + /** + * Construct the request + * @param {string} segmentationId - ID of the updated Segmentation + * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value + * - Allowed parameters: + * - *propertyName* + * - Type: string + * - Description: Name of the property on which the Segmentation should be based + * - *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, optional) { + super('POST', `/segmentations/property-based/${segmentationId}`, 10000, false); + this.segmentationId = segmentationId; + optional = optional || {}; + this.propertyName = optional.propertyName; + 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 = {}; + + if(this.propertyName !== undefined) + 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.UpdatePropertyBasedSegmentation = UpdatePropertyBasedSegmentation diff --git a/package.json b/package.json index 4612573..3ae7f75 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "recombee-api-client", - "version": "4.0.0", + "version": "4.1.0", "description": "Node.js client (SDK) for easy use of the Recombee recommendation API", "main": "index.js", "scripts": { diff --git a/test/add-manual-reql-segment-batch_test.js b/test/add-manual-reql-segment-batch_test.js new file mode 100644 index 0000000..e4450f3 --- /dev/null +++ b/test/add-manual-reql-segment-batch_test.js @@ -0,0 +1,40 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('AddManualReqlSegment', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + it ('works in batch', (done) => { + env.client.send(new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}),((err,res) => { + if(err) { + chai.fail(); + } + else { + let requests = [ + new rqs.AddManualReqlSegment('seg1','first-segment','\'str_property\' != null',{'title': 'First Segment'}) + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 201); + done(); + }); + } + })); + }); +}); diff --git a/test/add-manual-reql-segment-callback_test.js b/test/add-manual-reql-segment-callback_test.js new file mode 100644 index 0000000..c714b27 --- /dev/null +++ b/test/add-manual-reql-segment-callback_test.js @@ -0,0 +1,43 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('AddManualReqlSegment', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('adds manual ReQL segment', (done) => { + let req, req2, resp; + req2 = new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req2,((err,res) => { + if(err) { + chai.fail(); + } + else { + req = new rqs.AddManualReqlSegment('seg1','first-segment','\'str_property\' != null',{'title': 'First Segment'}); + env.client.send(req,((err,res) => { + if(err) { + chai.fail(); + } + else { + done(); + } + })); + } + })); + }); +}); diff --git a/test/add-manual-reql-segment-test.js b/test/add-manual-reql-segment-test.js new file mode 100644 index 0000000..0889284 --- /dev/null +++ b/test/add-manual-reql-segment-test.js @@ -0,0 +1,35 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('AddManualReqlSegment', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('adds manual ReQL segment', (done) => { + let req, req2, resp; + req2 = new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req2) + .then((res) => { + req = new rqs.AddManualReqlSegment('seg1','first-segment','\'str_property\' != null',{'title': 'First Segment'}); + env.client.send(req) + .then((res) => { + done(); + }); + }); + }); +}); diff --git a/test/create-auto-reql-segmentation-batch_test.js b/test/create-auto-reql-segmentation-batch_test.js new file mode 100644 index 0000000..b4ee4f2 --- /dev/null +++ b/test/create-auto-reql-segmentation-batch_test.js @@ -0,0 +1,35 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('CreateAutoReqlSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + it ('works in batch', (done) => { + let requests = [ + new rqs.CreateAutoReqlSegmentation('seg1','items','{\'str_property\'}',{'title': 'Test Segmentation','description': 'For test purposes'}), + new rqs.CreateAutoReqlSegmentation('seg1','items','{\'str_property\'}',{'title': 'Test Segmentation','description': 'For test purposes'}) + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 201); + chai.equal(responses[1].code, 409); + done(); + }); + }); +}); diff --git a/test/create-auto-reql-segmentation-callback_test.js b/test/create-auto-reql-segmentation-callback_test.js new file mode 100644 index 0000000..f119176 --- /dev/null +++ b/test/create-auto-reql-segmentation-callback_test.js @@ -0,0 +1,45 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('CreateAutoReqlSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('creates auto ReQL segmentation', (done) => { + let req, req2, resp; + req = new rqs.CreateAutoReqlSegmentation('seg1','items','{\'str_property\'}',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req,((err,res) => { + if(err) { + chai.fail(); + } + else { + req = new rqs.CreateAutoReqlSegmentation('seg1','items','{\'str_property\'}',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req,((err,res) => { + if(err) { + chai.equal(err.name, 'ResponseError'); + chai.equal(err.statusCode, 409); + done(); + } + else { + chai.fail(); + } + })); + } + })); + }); +}); diff --git a/test/create-auto-reql-segmentation-test.js b/test/create-auto-reql-segmentation-test.js new file mode 100644 index 0000000..afd66ce --- /dev/null +++ b/test/create-auto-reql-segmentation-test.js @@ -0,0 +1,43 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('CreateAutoReqlSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('creates auto ReQL segmentation', (done) => { + let req, req2, resp; + req = new rqs.CreateAutoReqlSegmentation('seg1','items','{\'str_property\'}',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req) + .then((res) => { + req = new rqs.CreateAutoReqlSegmentation('seg1','items','{\'str_property\'}',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req) + .then((res) => { + chai.fail(); + done(); + }) + .catch((err) => { + if (err instanceof recombee.errors.ResponseError) { + chai.equal(err.statusCode, 409); + done(); + } + throw err; + }); + }); + }); +}); diff --git a/test/create-manual-reql-segmentation-batch_test.js b/test/create-manual-reql-segmentation-batch_test.js new file mode 100644 index 0000000..63da584 --- /dev/null +++ b/test/create-manual-reql-segmentation-batch_test.js @@ -0,0 +1,35 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('CreateManualReqlSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + it ('works in batch', (done) => { + let requests = [ + new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}), + new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}) + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 201); + chai.equal(responses[1].code, 409); + done(); + }); + }); +}); diff --git a/test/create-manual-reql-segmentation-callback_test.js b/test/create-manual-reql-segmentation-callback_test.js new file mode 100644 index 0000000..76d397f --- /dev/null +++ b/test/create-manual-reql-segmentation-callback_test.js @@ -0,0 +1,45 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('CreateManualReqlSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('creates manual ReQL segmentation', (done) => { + let req, req2, resp; + req = new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req,((err,res) => { + if(err) { + chai.fail(); + } + else { + req = new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req,((err,res) => { + if(err) { + chai.equal(err.name, 'ResponseError'); + chai.equal(err.statusCode, 409); + done(); + } + else { + chai.fail(); + } + })); + } + })); + }); +}); diff --git a/test/create-manual-reql-segmentation-test.js b/test/create-manual-reql-segmentation-test.js new file mode 100644 index 0000000..505e1ca --- /dev/null +++ b/test/create-manual-reql-segmentation-test.js @@ -0,0 +1,43 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('CreateManualReqlSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('creates manual ReQL segmentation', (done) => { + let req, req2, resp; + req = new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req) + .then((res) => { + req = new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req) + .then((res) => { + chai.fail(); + done(); + }) + .catch((err) => { + if (err instanceof recombee.errors.ResponseError) { + chai.equal(err.statusCode, 409); + done(); + } + throw err; + }); + }); + }); +}); diff --git a/test/create-property-based-segmentation-batch_test.js b/test/create-property-based-segmentation-batch_test.js new file mode 100644 index 0000000..139fe41 --- /dev/null +++ b/test/create-property-based-segmentation-batch_test.js @@ -0,0 +1,35 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('CreatePropertyBasedSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + it ('works in batch', (done) => { + let requests = [ + new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property',{'title': 'Test Segmentation','description': 'For test purposes'}), + new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property',{'title': 'Test Segmentation','description': 'For test purposes'}) + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 201); + chai.equal(responses[1].code, 409); + done(); + }); + }); +}); diff --git a/test/create-property-based-segmentation-callback_test.js b/test/create-property-based-segmentation-callback_test.js new file mode 100644 index 0000000..71f5687 --- /dev/null +++ b/test/create-property-based-segmentation-callback_test.js @@ -0,0 +1,45 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('CreatePropertyBasedSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('creates property based segmentation', (done) => { + let req, req2, resp; + req = new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req,((err,res) => { + if(err) { + chai.fail(); + } + else { + req = new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req,((err,res) => { + if(err) { + chai.equal(err.name, 'ResponseError'); + chai.equal(err.statusCode, 409); + done(); + } + else { + chai.fail(); + } + })); + } + })); + }); +}); diff --git a/test/create-property-based-segmentation-test.js b/test/create-property-based-segmentation-test.js new file mode 100644 index 0000000..dd64703 --- /dev/null +++ b/test/create-property-based-segmentation-test.js @@ -0,0 +1,43 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('CreatePropertyBasedSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('creates property based segmentation', (done) => { + let req, req2, resp; + req = new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req) + .then((res) => { + req = new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req) + .then((res) => { + chai.fail(); + done(); + }) + .catch((err) => { + if (err instanceof recombee.errors.ResponseError) { + chai.equal(err.statusCode, 409); + done(); + } + throw err; + }); + }); + }); +}); diff --git a/test/delete-manual-reql-segment-batch_test.js b/test/delete-manual-reql-segment-batch_test.js new file mode 100644 index 0000000..2b264d7 --- /dev/null +++ b/test/delete-manual-reql-segment-batch_test.js @@ -0,0 +1,47 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('DeleteManualReqlSegment', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + it ('works in batch', (done) => { + env.client.send(new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}),((err,res) => { + if(err) { + chai.fail(); + } + else { + env.client.send(new rqs.AddManualReqlSegment('seg1','first-segment','\'str_property\' != null',{'title': 'First Segment'}),((err,res) => { + if(err) { + chai.fail(); + } + else { + let requests = [ + new rqs.DeleteManualReqlSegment('seg1','first-segment') + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 200); + done(); + }); + } + })); + } + })); + }); +}); diff --git a/test/delete-manual-reql-segment-callback_test.js b/test/delete-manual-reql-segment-callback_test.js new file mode 100644 index 0000000..f8e4134 --- /dev/null +++ b/test/delete-manual-reql-segment-callback_test.js @@ -0,0 +1,51 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('DeleteManualReqlSegment', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('deletes manual ReQL segment', (done) => { + let req, req2, resp; + req2 = new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req2,((err,res) => { + if(err) { + chai.fail(); + } + else { + req2 = new rqs.AddManualReqlSegment('seg1','first-segment','\'str_property\' != null',{'title': 'First Segment'}); + env.client.send(req2,((err,res) => { + if(err) { + chai.fail(); + } + else { + req = new rqs.DeleteManualReqlSegment('seg1','first-segment'); + env.client.send(req,((err,res) => { + if(err) { + chai.fail(); + } + else { + done(); + } + })); + } + })); + } + })); + }); +}); diff --git a/test/delete-manual-reql-segment-test.js b/test/delete-manual-reql-segment-test.js new file mode 100644 index 0000000..5ed987a --- /dev/null +++ b/test/delete-manual-reql-segment-test.js @@ -0,0 +1,39 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('DeleteManualReqlSegment', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('deletes manual ReQL segment', (done) => { + let req, req2, resp; + req2 = new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req2) + .then((res) => { + req2 = new rqs.AddManualReqlSegment('seg1','first-segment','\'str_property\' != null',{'title': 'First Segment'}); + env.client.send(req2) + .then((res) => { + req = new rqs.DeleteManualReqlSegment('seg1','first-segment'); + env.client.send(req) + .then((res) => { + done(); + }); + }); + }); + }); +}); diff --git a/test/delete-segmentation-batch_test.js b/test/delete-segmentation-batch_test.js new file mode 100644 index 0000000..07a0f4a --- /dev/null +++ b/test/delete-segmentation-batch_test.js @@ -0,0 +1,42 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('DeleteSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + it ('works in batch', (done) => { + env.client.send(new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property'),((err,res) => { + if(err) { + chai.fail(); + } + else { + let requests = [ + new rqs.DeleteSegmentation('seg1'), + new rqs.DeleteSegmentation('seg1') + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 200); + chai.equal(responses[1].code, 404); + done(); + }); + } + })); + }); +}); diff --git a/test/delete-segmentation-callback_test.js b/test/delete-segmentation-callback_test.js new file mode 100644 index 0000000..2e3466e --- /dev/null +++ b/test/delete-segmentation-callback_test.js @@ -0,0 +1,53 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('DeleteSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('deletes segmentation', (done) => { + let req, req2, resp; + req2 = new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property'); + env.client.send(req2,((err,res) => { + if(err) { + chai.fail(); + } + else { + req = new rqs.DeleteSegmentation('seg1'); + env.client.send(req,((err,res) => { + if(err) { + chai.fail(); + } + else { + req = new rqs.DeleteSegmentation('seg1'); + env.client.send(req,((err,res) => { + if(err) { + chai.equal(err.name, 'ResponseError'); + chai.equal(err.statusCode, 404); + done(); + } + else { + chai.fail(); + } + })); + } + })); + } + })); + }); +}); diff --git a/test/delete-segmentation-test.js b/test/delete-segmentation-test.js new file mode 100644 index 0000000..b0d91ca --- /dev/null +++ b/test/delete-segmentation-test.js @@ -0,0 +1,47 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('DeleteSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('deletes segmentation', (done) => { + let req, req2, resp; + req2 = new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property'); + env.client.send(req2) + .then((res) => { + req = new rqs.DeleteSegmentation('seg1'); + env.client.send(req) + .then((res) => { + req = new rqs.DeleteSegmentation('seg1'); + env.client.send(req) + .then((res) => { + chai.fail(); + done(); + }) + .catch((err) => { + if (err instanceof recombee.errors.ResponseError) { + chai.equal(err.statusCode, 404); + done(); + } + throw err; + }); + }); + }); + }); +}); diff --git a/test/get-segmentation-batch_test.js b/test/get-segmentation-batch_test.js new file mode 100644 index 0000000..0e21cb2 --- /dev/null +++ b/test/get-segmentation-batch_test.js @@ -0,0 +1,41 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('GetSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + it ('works in batch', (done) => { + env.client.send(new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property'),((err,res) => { + if(err) { + chai.fail(); + } + else { + let requests = [ + new rqs.GetSegmentation('seg1') + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 200); + chai.deepEqual('seg1', responses[0].json['segmentationId']); + done(); + }); + } + })); + }); +}); diff --git a/test/get-segmentation-callback_test.js b/test/get-segmentation-callback_test.js new file mode 100644 index 0000000..bd1f37d --- /dev/null +++ b/test/get-segmentation-callback_test.js @@ -0,0 +1,44 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('GetSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('gets existing segmentation', (done) => { + let req, req2, resp; + req2 = new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property'); + env.client.send(req2,((err,res) => { + if(err) { + chai.fail(); + } + else { + req = new rqs.GetSegmentation('seg1'); + env.client.send(req,((err,res) => { + if(err) { + chai.fail(); + } + else { + chai.deepEqual('seg1', res['segmentationId']); + done(); + } + })); + } + })); + }); +}); diff --git a/test/get-segmentation-test.js b/test/get-segmentation-test.js new file mode 100644 index 0000000..d129a05 --- /dev/null +++ b/test/get-segmentation-test.js @@ -0,0 +1,36 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('GetSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('gets existing segmentation', (done) => { + let req, req2, resp; + req2 = new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property'); + env.client.send(req2) + .then((res) => { + req = new rqs.GetSegmentation('seg1'); + env.client.send(req) + .then((res) => { + chai.deepEqual('seg1', res['segmentationId']); + done(); + }); + }); + }); +}); diff --git a/test/list-segmentations-batch_test.js b/test/list-segmentations-batch_test.js new file mode 100644 index 0000000..0371f94 --- /dev/null +++ b/test/list-segmentations-batch_test.js @@ -0,0 +1,41 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('ListSegmentations', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + setTimeout(done, 20000); + }); + }); + it ('works in batch', (done) => { + env.client.send(new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property'),((err,res) => { + if(err) { + chai.fail(); + } + else { + let requests = [ + new rqs.ListSegmentations('items') + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 200); + chai.equal(responses[0].json['segmentations'].length, 1); + done(); + }); + } + })); + }); +}); diff --git a/test/list-segmentations-callback_test.js b/test/list-segmentations-callback_test.js new file mode 100644 index 0000000..43d13f2 --- /dev/null +++ b/test/list-segmentations-callback_test.js @@ -0,0 +1,44 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('ListSegmentations', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + setTimeout(done, 20000); + }); + }); + + it ('lists existing segmentations', (done) => { + let req, req2, resp; + req2 = new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property'); + env.client.send(req2,((err,res) => { + if(err) { + chai.fail(); + } + else { + req = new rqs.ListSegmentations('items'); + env.client.send(req,((err,res) => { + if(err) { + chai.fail(); + } + else { + chai.equal(res['segmentations'].length, 1); + done(); + } + })); + } + })); + }); +}); diff --git a/test/list-segmentations-test.js b/test/list-segmentations-test.js new file mode 100644 index 0000000..fa77b41 --- /dev/null +++ b/test/list-segmentations-test.js @@ -0,0 +1,36 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('ListSegmentations', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + setTimeout(done, 20000); + }); + }); + + it ('lists existing segmentations', (done) => { + let req, req2, resp; + req2 = new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property'); + env.client.send(req2) + .then((res) => { + req = new rqs.ListSegmentations('items'); + env.client.send(req) + .then((res) => { + chai.equal(res['segmentations'].length, 1); + done(); + }); + }); + }); +}); diff --git a/test/recommend-item-segments-to-item-batch_test.js b/test/recommend-item-segments-to-item-batch_test.js new file mode 100644 index 0000000..81ffdbe --- /dev/null +++ b/test/recommend-item-segments-to-item-batch_test.js @@ -0,0 +1,33 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('RecommendItemSegmentsToItem', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + it ('works in batch', (done) => { + let requests = [ + new rqs.RecommendItemSegmentsToItem('entity_id','entity_id',5,{'scenario': 'scenario1','cascadeCreate': true}) + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 400); + done(); + }); + }); +}); diff --git a/test/recommend-item-segments-to-item-callback_test.js b/test/recommend-item-segments-to-item-callback_test.js new file mode 100644 index 0000000..c0447dd --- /dev/null +++ b/test/recommend-item-segments-to-item-callback_test.js @@ -0,0 +1,37 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('RecommendItemSegmentsToItem', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('rejects request to scenario which is not set up', (done) => { + let req, req2, resp; + req = new rqs.RecommendItemSegmentsToItem('entity_id','entity_id',5,{'scenario': 'scenario1','cascadeCreate': true}); + env.client.send(req,((err,res) => { + if(err) { + chai.equal(err.name, 'ResponseError'); + chai.equal(err.statusCode, 400); + done(); + } + else { + chai.fail(); + } + })); + }); +}); diff --git a/test/recommend-item-segments-to-item-segment-batch_test.js b/test/recommend-item-segments-to-item-segment-batch_test.js new file mode 100644 index 0000000..5025e1e --- /dev/null +++ b/test/recommend-item-segments-to-item-segment-batch_test.js @@ -0,0 +1,33 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('RecommendItemSegmentsToItemSegment', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + it ('works in batch', (done) => { + let requests = [ + new rqs.RecommendItemSegmentsToItemSegment('segment_id','entity_id',5,{'scenario': 'scenario1','cascadeCreate': true}) + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 400); + done(); + }); + }); +}); diff --git a/test/recommend-item-segments-to-item-segment-callback_test.js b/test/recommend-item-segments-to-item-segment-callback_test.js new file mode 100644 index 0000000..b541511 --- /dev/null +++ b/test/recommend-item-segments-to-item-segment-callback_test.js @@ -0,0 +1,37 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('RecommendItemSegmentsToItemSegment', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('rejects request to scenario which is not set up', (done) => { + let req, req2, resp; + req = new rqs.RecommendItemSegmentsToItemSegment('segment_id','entity_id',5,{'scenario': 'scenario1','cascadeCreate': true}); + env.client.send(req,((err,res) => { + if(err) { + chai.equal(err.name, 'ResponseError'); + chai.equal(err.statusCode, 400); + done(); + } + else { + chai.fail(); + } + })); + }); +}); diff --git a/test/recommend-item-segments-to-item-segment-test.js b/test/recommend-item-segments-to-item-segment-test.js new file mode 100644 index 0000000..4d4ca13 --- /dev/null +++ b/test/recommend-item-segments-to-item-segment-test.js @@ -0,0 +1,39 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('RecommendItemSegmentsToItemSegment', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('rejects request to scenario which is not set up', (done) => { + let req, req2, resp; + req = new rqs.RecommendItemSegmentsToItemSegment('segment_id','entity_id',5,{'scenario': 'scenario1','cascadeCreate': true}); + env.client.send(req) + .then((res) => { + chai.fail(); + done(); + }) + .catch((err) => { + if (err instanceof recombee.errors.ResponseError) { + chai.equal(err.statusCode, 400); + done(); + } + throw err; + }); + }); +}); diff --git a/test/recommend-item-segments-to-item-test.js b/test/recommend-item-segments-to-item-test.js new file mode 100644 index 0000000..2f74e16 --- /dev/null +++ b/test/recommend-item-segments-to-item-test.js @@ -0,0 +1,39 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('RecommendItemSegmentsToItem', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('rejects request to scenario which is not set up', (done) => { + let req, req2, resp; + req = new rqs.RecommendItemSegmentsToItem('entity_id','entity_id',5,{'scenario': 'scenario1','cascadeCreate': true}); + env.client.send(req) + .then((res) => { + chai.fail(); + done(); + }) + .catch((err) => { + if (err instanceof recombee.errors.ResponseError) { + chai.equal(err.statusCode, 400); + done(); + } + throw err; + }); + }); +}); diff --git a/test/recommend-item-segments-to-user-batch_test.js b/test/recommend-item-segments-to-user-batch_test.js new file mode 100644 index 0000000..de38cbd --- /dev/null +++ b/test/recommend-item-segments-to-user-batch_test.js @@ -0,0 +1,33 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('RecommendItemSegmentsToUser', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + it ('works in batch', (done) => { + let requests = [ + new rqs.RecommendItemSegmentsToUser('entity_id',5,{'scenario': 'scenario1','cascadeCreate': true}) + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 400); + done(); + }); + }); +}); diff --git a/test/recommend-item-segments-to-user-callback_test.js b/test/recommend-item-segments-to-user-callback_test.js new file mode 100644 index 0000000..87e36b6 --- /dev/null +++ b/test/recommend-item-segments-to-user-callback_test.js @@ -0,0 +1,37 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('RecommendItemSegmentsToUser', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('rejects request to scenario which is not set up', (done) => { + let req, req2, resp; + req = new rqs.RecommendItemSegmentsToUser('entity_id',5,{'scenario': 'scenario1','cascadeCreate': true}); + env.client.send(req,((err,res) => { + if(err) { + chai.equal(err.name, 'ResponseError'); + chai.equal(err.statusCode, 400); + done(); + } + else { + chai.fail(); + } + })); + }); +}); diff --git a/test/recommend-item-segments-to-user-test.js b/test/recommend-item-segments-to-user-test.js new file mode 100644 index 0000000..c4ef6ff --- /dev/null +++ b/test/recommend-item-segments-to-user-test.js @@ -0,0 +1,39 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('RecommendItemSegmentsToUser', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('rejects request to scenario which is not set up', (done) => { + let req, req2, resp; + req = new rqs.RecommendItemSegmentsToUser('entity_id',5,{'scenario': 'scenario1','cascadeCreate': true}); + env.client.send(req) + .then((res) => { + chai.fail(); + done(); + }) + .catch((err) => { + if (err instanceof recombee.errors.ResponseError) { + chai.equal(err.statusCode, 400); + done(); + } + throw err; + }); + }); +}); diff --git a/test/search-item-segments-batch_test.js b/test/search-item-segments-batch_test.js new file mode 100644 index 0000000..2c684bc --- /dev/null +++ b/test/search-item-segments-batch_test.js @@ -0,0 +1,33 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('SearchItemSegments', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + it ('works in batch', (done) => { + let requests = [ + new rqs.SearchItemSegments('entity_id','query',5,{'scenario': 'scenario1','cascadeCreate': true}) + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 400); + done(); + }); + }); +}); diff --git a/test/search-item-segments-callback_test.js b/test/search-item-segments-callback_test.js new file mode 100644 index 0000000..3a80b50 --- /dev/null +++ b/test/search-item-segments-callback_test.js @@ -0,0 +1,37 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('SearchItemSegments', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('rejects request to scenario which is not set up', (done) => { + let req, req2, resp; + req = new rqs.SearchItemSegments('entity_id','query',5,{'scenario': 'scenario1','cascadeCreate': true}); + env.client.send(req,((err,res) => { + if(err) { + chai.equal(err.name, 'ResponseError'); + chai.equal(err.statusCode, 400); + done(); + } + else { + chai.fail(); + } + })); + }); +}); diff --git a/test/search-item-segments-test.js b/test/search-item-segments-test.js new file mode 100644 index 0000000..0978cf3 --- /dev/null +++ b/test/search-item-segments-test.js @@ -0,0 +1,39 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('SearchItemSegments', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('rejects request to scenario which is not set up', (done) => { + let req, req2, resp; + req = new rqs.SearchItemSegments('entity_id','query',5,{'scenario': 'scenario1','cascadeCreate': true}); + env.client.send(req) + .then((res) => { + chai.fail(); + done(); + }) + .catch((err) => { + if (err instanceof recombee.errors.ResponseError) { + chai.equal(err.statusCode, 400); + done(); + } + throw err; + }); + }); +}); diff --git a/test/update-auto-reql-segmentation-batch_test.js b/test/update-auto-reql-segmentation-batch_test.js new file mode 100644 index 0000000..1dac7d0 --- /dev/null +++ b/test/update-auto-reql-segmentation-batch_test.js @@ -0,0 +1,40 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('UpdateAutoReqlSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + it ('works in batch', (done) => { + env.client.send(new rqs.CreateAutoReqlSegmentation('seg1','items','{\'str_property\'}',{'title': 'Test Segmentation','description': 'For test purposes'}),((err,res) => { + if(err) { + chai.fail(); + } + else { + let requests = [ + new rqs.UpdateAutoReqlSegmentation('seg1',{'title': 'New title','expression': '{\'str_property\' + \'str_property\'}','description': 'Updated'}) + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 200); + done(); + }); + } + })); + }); +}); diff --git a/test/update-auto-reql-segmentation-callback_test.js b/test/update-auto-reql-segmentation-callback_test.js new file mode 100644 index 0000000..0253106 --- /dev/null +++ b/test/update-auto-reql-segmentation-callback_test.js @@ -0,0 +1,43 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('UpdateAutoReqlSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('updates auto ReQL segmentation', (done) => { + let req, req2, resp; + req2 = new rqs.CreateAutoReqlSegmentation('seg1','items','{\'str_property\'}',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req2,((err,res) => { + if(err) { + chai.fail(); + } + else { + req = new rqs.UpdateAutoReqlSegmentation('seg1',{'title': 'New title','expression': '{\'str_property\' + \'str_property\'}','description': 'Updated'}); + env.client.send(req,((err,res) => { + if(err) { + chai.fail(); + } + else { + done(); + } + })); + } + })); + }); +}); diff --git a/test/update-auto-reql-segmentation-test.js b/test/update-auto-reql-segmentation-test.js new file mode 100644 index 0000000..d7eeb6a --- /dev/null +++ b/test/update-auto-reql-segmentation-test.js @@ -0,0 +1,35 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('UpdateAutoReqlSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('updates auto ReQL segmentation', (done) => { + let req, req2, resp; + req2 = new rqs.CreateAutoReqlSegmentation('seg1','items','{\'str_property\'}',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req2) + .then((res) => { + req = new rqs.UpdateAutoReqlSegmentation('seg1',{'title': 'New title','expression': '{\'str_property\' + \'str_property\'}','description': 'Updated'}); + env.client.send(req) + .then((res) => { + done(); + }); + }); + }); +}); diff --git a/test/update-manual-reql-segment-batch_test.js b/test/update-manual-reql-segment-batch_test.js new file mode 100644 index 0000000..e720515 --- /dev/null +++ b/test/update-manual-reql-segment-batch_test.js @@ -0,0 +1,47 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('UpdateManualReqlSegment', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + it ('works in batch', (done) => { + env.client.send(new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}),((err,res) => { + if(err) { + chai.fail(); + } + else { + env.client.send(new rqs.AddManualReqlSegment('seg1','first-segment','\'str_property\' != null',{'title': 'First Segment'}),((err,res) => { + if(err) { + chai.fail(); + } + else { + let requests = [ + new rqs.UpdateManualReqlSegment('seg1','first-segment','\'str_property\' == null',{'title': 'Updated Segment'}) + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 200); + done(); + }); + } + })); + } + })); + }); +}); diff --git a/test/update-manual-reql-segment-callback_test.js b/test/update-manual-reql-segment-callback_test.js new file mode 100644 index 0000000..9439be4 --- /dev/null +++ b/test/update-manual-reql-segment-callback_test.js @@ -0,0 +1,51 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('UpdateManualReqlSegment', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('updates manual ReQL segment', (done) => { + let req, req2, resp; + req2 = new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req2,((err,res) => { + if(err) { + chai.fail(); + } + else { + req2 = new rqs.AddManualReqlSegment('seg1','first-segment','\'str_property\' != null',{'title': 'First Segment'}); + env.client.send(req2,((err,res) => { + if(err) { + chai.fail(); + } + else { + req = new rqs.UpdateManualReqlSegment('seg1','first-segment','\'str_property\' == null',{'title': 'Updated Segment'}); + env.client.send(req,((err,res) => { + if(err) { + chai.fail(); + } + else { + done(); + } + })); + } + })); + } + })); + }); +}); diff --git a/test/update-manual-reql-segment-test.js b/test/update-manual-reql-segment-test.js new file mode 100644 index 0000000..1b85e68 --- /dev/null +++ b/test/update-manual-reql-segment-test.js @@ -0,0 +1,39 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('UpdateManualReqlSegment', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('updates manual ReQL segment', (done) => { + let req, req2, resp; + req2 = new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req2) + .then((res) => { + req2 = new rqs.AddManualReqlSegment('seg1','first-segment','\'str_property\' != null',{'title': 'First Segment'}); + env.client.send(req2) + .then((res) => { + req = new rqs.UpdateManualReqlSegment('seg1','first-segment','\'str_property\' == null',{'title': 'Updated Segment'}); + env.client.send(req) + .then((res) => { + done(); + }); + }); + }); + }); +}); diff --git a/test/update-manual-reql-segmentation-batch_test.js b/test/update-manual-reql-segmentation-batch_test.js new file mode 100644 index 0000000..d1ed513 --- /dev/null +++ b/test/update-manual-reql-segmentation-batch_test.js @@ -0,0 +1,40 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('UpdateManualReqlSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + it ('works in batch', (done) => { + env.client.send(new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}),((err,res) => { + if(err) { + chai.fail(); + } + else { + let requests = [ + new rqs.UpdateManualReqlSegmentation('seg1',{'title': 'New title','description': 'Updated'}) + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 200); + done(); + }); + } + })); + }); +}); diff --git a/test/update-manual-reql-segmentation-callback_test.js b/test/update-manual-reql-segmentation-callback_test.js new file mode 100644 index 0000000..a955607 --- /dev/null +++ b/test/update-manual-reql-segmentation-callback_test.js @@ -0,0 +1,43 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('UpdateManualReqlSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('updates manual ReQL segmentation', (done) => { + let req, req2, resp; + req2 = new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req2,((err,res) => { + if(err) { + chai.fail(); + } + else { + req = new rqs.UpdateManualReqlSegmentation('seg1',{'title': 'New title','description': 'Updated'}); + env.client.send(req,((err,res) => { + if(err) { + chai.fail(); + } + else { + done(); + } + })); + } + })); + }); +}); diff --git a/test/update-manual-reql-segmentation-test.js b/test/update-manual-reql-segmentation-test.js new file mode 100644 index 0000000..1fb1761 --- /dev/null +++ b/test/update-manual-reql-segmentation-test.js @@ -0,0 +1,35 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('UpdateManualReqlSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('updates manual ReQL segmentation', (done) => { + let req, req2, resp; + req2 = new rqs.CreateManualReqlSegmentation('seg1','items',{'title': 'Test Segmentation','description': 'For test purposes'}); + env.client.send(req2) + .then((res) => { + req = new rqs.UpdateManualReqlSegmentation('seg1',{'title': 'New title','description': 'Updated'}); + env.client.send(req) + .then((res) => { + done(); + }); + }); + }); +}); diff --git a/test/update-property-based-segmentation-batch_test.js b/test/update-property-based-segmentation-batch_test.js new file mode 100644 index 0000000..5a893c4 --- /dev/null +++ b/test/update-property-based-segmentation-batch_test.js @@ -0,0 +1,40 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('UpdatePropertyBasedSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + it ('works in batch', (done) => { + env.client.send(new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property'),((err,res) => { + if(err) { + chai.fail(); + } + else { + let requests = [ + new rqs.UpdatePropertyBasedSegmentation('seg1',{'title': 'New title','propertyName': 'str_property','description': 'Updated'}) + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 200); + done(); + }); + } + })); + }); +}); diff --git a/test/update-property-based-segmentation-callback_test.js b/test/update-property-based-segmentation-callback_test.js new file mode 100644 index 0000000..1994e1e --- /dev/null +++ b/test/update-property-based-segmentation-callback_test.js @@ -0,0 +1,43 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('UpdatePropertyBasedSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('updates property based segmentation', (done) => { + let req, req2, resp; + req2 = new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property'); + env.client.send(req2,((err,res) => { + if(err) { + chai.fail(); + } + else { + req = new rqs.UpdatePropertyBasedSegmentation('seg1',{'title': 'New title','propertyName': 'str_property','description': 'Updated'}); + env.client.send(req,((err,res) => { + if(err) { + chai.fail(); + } + else { + done(); + } + })); + } + })); + }); +}); diff --git a/test/update-property-based-segmentation-test.js b/test/update-property-based-segmentation-test.js new file mode 100644 index 0000000..7fc322f --- /dev/null +++ b/test/update-property-based-segmentation-test.js @@ -0,0 +1,35 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict' +var chai = require('chai').assert; +var recombee = require('./../index.js'); +var rqs = recombee.requests; + +var env = require('./set-environment.js'); + +describe('UpdatePropertyBasedSegmentation', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('updates property based segmentation', (done) => { + let req, req2, resp; + req2 = new rqs.CreatePropertyBasedSegmentation('seg1','items','str_property'); + env.client.send(req2) + .then((res) => { + req = new rqs.UpdatePropertyBasedSegmentation('seg1',{'title': 'New title','propertyName': 'str_property','description': 'Updated'}); + env.client.send(req) + .then((res) => { + done(); + }); + }); + }); +});