recombee-api-client 4.1.4 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/index.js +1 -1
  2. package/lib/api-client.js +20 -15
  3. package/lib/errors/index.js +1 -1
  4. package/lib/index.d.ts +127 -175
  5. package/lib/requests/add-bookmark.js +1 -1
  6. package/lib/requests/add-cart-addition.js +1 -1
  7. package/lib/requests/add-detail-view.js +1 -1
  8. package/lib/requests/add-item-property.js +1 -1
  9. package/lib/requests/add-item.js +1 -1
  10. package/lib/requests/add-purchase.js +1 -1
  11. package/lib/requests/add-rating.js +1 -1
  12. package/lib/requests/add-series.js +12 -2
  13. package/lib/requests/add-user-property.js +1 -1
  14. package/lib/requests/add-user.js +1 -1
  15. package/lib/requests/delete-bookmark.js +1 -1
  16. package/lib/requests/delete-cart-addition.js +1 -1
  17. package/lib/requests/delete-detail-view.js +1 -1
  18. package/lib/requests/delete-item.js +1 -1
  19. package/lib/requests/delete-purchase.js +1 -1
  20. package/lib/requests/delete-rating.js +1 -1
  21. package/lib/requests/delete-series.js +12 -2
  22. package/lib/requests/delete-user.js +1 -1
  23. package/lib/requests/delete-view-portion.js +1 -1
  24. package/lib/requests/get-item-property-info.js +1 -1
  25. package/lib/requests/get-item-values.js +1 -1
  26. package/lib/requests/get-user-values.js +1 -1
  27. package/lib/requests/index.js +1 -6
  28. package/lib/requests/insert-to-series.js +2 -2
  29. package/lib/requests/recommend-item-segments-to-item-segment.js +2 -2
  30. package/lib/requests/recommend-item-segments-to-item.js +2 -2
  31. package/lib/requests/recommend-item-segments-to-user.js +2 -2
  32. package/lib/requests/recommend-items-to-item-segment.js +214 -0
  33. package/lib/requests/remove-from-series.js +4 -7
  34. package/lib/requests/request.js +1 -1
  35. package/lib/requests/set-view-portion.js +1 -1
  36. package/package.json +8 -5
  37. package/test/add-bookmark-batch_test.js +2 -4
  38. package/test/add-bookmark-callback_test.js +0 -15
  39. package/test/add-bookmark-test.js +0 -17
  40. package/test/add-cart-addition-batch_test.js +2 -4
  41. package/test/add-cart-addition-callback_test.js +0 -15
  42. package/test/add-cart-addition-test.js +0 -17
  43. package/test/add-detail-view-batch_test.js +2 -4
  44. package/test/add-detail-view-callback_test.js +0 -15
  45. package/test/add-detail-view-test.js +0 -17
  46. package/test/add-purchase-batch_test.js +2 -4
  47. package/test/add-purchase-callback_test.js +0 -15
  48. package/test/add-purchase-test.js +0 -17
  49. package/test/add-rating-batch_test.js +2 -4
  50. package/test/add-rating-callback_test.js +0 -15
  51. package/test/add-rating-test.js +0 -17
  52. package/test/list-items-batch_test.js +1 -1
  53. package/test/list-items-callback_test.js +1 -1
  54. package/test/list-items-test.js +1 -1
  55. package/test/list-users-batch_test.js +1 -1
  56. package/test/list-users-callback_test.js +1 -1
  57. package/test/list-users-test.js +1 -1
  58. package/test/{list-groups-batch_test.js → recommend-items-to-item-segment-batch_test.js} +4 -5
  59. package/test/{list-groups-callback_test.js → recommend-items-to-item-segment-callback_test.js} +8 -7
  60. package/test/{remove-from-group-test.js → recommend-items-to-item-segment-test.js} +5 -14
  61. package/test/remove-from-series-batch_test.js +4 -6
  62. package/test/remove-from-series-callback_test.js +2 -17
  63. package/test/remove-from-series-test.js +2 -19
  64. package/test/set-environment.js +89 -86
  65. package/test/set-view-portion-batch_test.js +0 -2
  66. package/test/set-view-portion-callback_test.js +0 -15
  67. package/test/set-view-portion-test.js +0 -17
  68. package/lib/requests/add-group.js +0 -42
  69. package/lib/requests/delete-group.js +0 -43
  70. package/lib/requests/insert-to-group.js +0 -58
  71. package/lib/requests/list-group-items.js +0 -42
  72. package/lib/requests/list-groups.js +0 -40
  73. package/lib/requests/remove-from-group.js +0 -48
  74. package/test/add-group-batch_test.js +0 -39
  75. package/test/add-group-callback_test.js +0 -72
  76. package/test/add-group-test.js +0 -68
  77. package/test/delete-group-batch_test.js +0 -39
  78. package/test/delete-group-callback_test.js +0 -74
  79. package/test/delete-group-test.js +0 -76
  80. package/test/insert-to-group-batch_test.js +0 -53
  81. package/test/insert-to-group-callback_test.js +0 -86
  82. package/test/insert-to-group-test.js +0 -68
  83. package/test/list-group-items-batch_test.js +0 -36
  84. package/test/list-group-items-callback_test.js +0 -38
  85. package/test/list-group-items-test.js +0 -34
  86. package/test/list-groups-test.js +0 -32
  87. package/test/remove-from-group-batch_test.js +0 -35
  88. package/test/remove-from-group-callback_test.js +0 -50
@@ -21,7 +21,7 @@ class DeleteDetailView extends rqs.Request {
21
21
  * - 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.
22
22
  */
23
23
  constructor(userId, itemId, optional) {
24
- super('DELETE', '/detailviews/', 1000, false);
24
+ super('DELETE', '/detailviews/', 3000, false);
25
25
  this.userId = userId;
26
26
  this.itemId = itemId;
27
27
  optional = optional || {};
@@ -17,7 +17,7 @@ class DeleteItem extends rqs.Request {
17
17
  * @param {string} itemId - ID of the item to be deleted.
18
18
  */
19
19
  constructor(itemId) {
20
- super('DELETE', `/items/${itemId}`, 1000, false);
20
+ super('DELETE', `/items/${itemId}`, 3000, false);
21
21
  this.itemId = itemId;
22
22
  }
23
23
 
@@ -21,7 +21,7 @@ class DeletePurchase extends rqs.Request {
21
21
  * - Description: Unix timestamp of the purchase. If the `timestamp` is omitted, then all the purchases with the given `userId` and `itemId` are deleted.
22
22
  */
23
23
  constructor(userId, itemId, optional) {
24
- super('DELETE', '/purchases/', 1000, false);
24
+ super('DELETE', '/purchases/', 3000, false);
25
25
  this.userId = userId;
26
26
  this.itemId = itemId;
27
27
  optional = optional || {};
@@ -21,7 +21,7 @@ class DeleteRating extends rqs.Request {
21
21
  * - Description: Unix timestamp of the rating. If the `timestamp` is omitted, then all the ratings with the given `userId` and `itemId` are deleted.
22
22
  */
23
23
  constructor(userId, itemId, optional) {
24
- super('DELETE', '/ratings/', 1000, false);
24
+ super('DELETE', '/ratings/', 3000, false);
25
25
  this.userId = userId;
26
26
  this.itemId = itemId;
27
27
  optional = optional || {};
@@ -14,10 +14,17 @@ class DeleteSeries extends rqs.Request {
14
14
  /**
15
15
  * Construct the request
16
16
  * @param {string} seriesId - ID of the series to be deleted.
17
+ * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value
18
+ * - Allowed parameters:
19
+ * - *cascadeDelete*
20
+ * - Type: boolean
21
+ * - Description: If set to `true`, item with the same ID as seriesId will be also deleted. Default is `false`.
17
22
  */
18
- constructor(seriesId) {
19
- super('DELETE', `/series/${seriesId}`, 1000, false);
23
+ constructor(seriesId, optional) {
24
+ super('DELETE', `/series/${seriesId}`, 3000, false);
20
25
  this.seriesId = seriesId;
26
+ optional = optional || {};
27
+ this.cascadeDelete = optional.cascadeDelete;
21
28
  }
22
29
 
23
30
  /**
@@ -27,6 +34,9 @@ class DeleteSeries extends rqs.Request {
27
34
  bodyParameters() {
28
35
  let params = {};
29
36
 
37
+ if(this.cascadeDelete !== undefined)
38
+ params.cascadeDelete = this.cascadeDelete;
39
+
30
40
  return params;
31
41
  }
32
42
 
@@ -16,7 +16,7 @@ class DeleteUser extends rqs.Request {
16
16
  * @param {string} userId - ID of the user to be deleted.
17
17
  */
18
18
  constructor(userId) {
19
- super('DELETE', `/users/${userId}`, 1000, false);
19
+ super('DELETE', `/users/${userId}`, 3000, false);
20
20
  this.userId = userId;
21
21
  }
22
22
 
@@ -21,7 +21,7 @@ class DeleteViewPortion extends rqs.Request {
21
21
  * - Description: Identifier of a session.
22
22
  */
23
23
  constructor(userId, itemId, optional) {
24
- super('DELETE', '/viewportions/', 1000, false);
24
+ super('DELETE', '/viewportions/', 3000, false);
25
25
  this.userId = userId;
26
26
  this.itemId = itemId;
27
27
  optional = optional || {};
@@ -15,7 +15,7 @@ class GetItemPropertyInfo extends rqs.Request {
15
15
  * @param {string} propertyName - Name of the property about which the information is to be retrieved.
16
16
  */
17
17
  constructor(propertyName) {
18
- super('GET', `/items/properties/${propertyName}`, 1000, false);
18
+ super('GET', `/items/properties/${propertyName}`, 3000, false);
19
19
  this.propertyName = propertyName;
20
20
  }
21
21
 
@@ -15,7 +15,7 @@ class GetItemValues extends rqs.Request {
15
15
  * @param {string} itemId - ID of the item whose properties are to be obtained.
16
16
  */
17
17
  constructor(itemId) {
18
- super('GET', `/items/${itemId}`, 1000, false);
18
+ super('GET', `/items/${itemId}`, 3000, false);
19
19
  this.itemId = itemId;
20
20
  }
21
21
 
@@ -15,7 +15,7 @@ class GetUserValues extends rqs.Request {
15
15
  * @param {string} userId - ID of the user whose properties are to be obtained.
16
16
  */
17
17
  constructor(userId) {
18
- super('GET', `/users/${userId}`, 1000, false);
18
+ super('GET', `/users/${userId}`, 3000, false);
19
19
  this.userId = userId;
20
20
  }
21
21
 
@@ -20,12 +20,6 @@ exports.ListSeries = require("./list-series").ListSeries;
20
20
  exports.ListSeriesItems = require("./list-series-items").ListSeriesItems;
21
21
  exports.InsertToSeries = require("./insert-to-series").InsertToSeries;
22
22
  exports.RemoveFromSeries = require("./remove-from-series").RemoveFromSeries;
23
- exports.AddGroup = require("./add-group").AddGroup;
24
- exports.DeleteGroup = require("./delete-group").DeleteGroup;
25
- exports.ListGroups = require("./list-groups").ListGroups;
26
- exports.ListGroupItems = require("./list-group-items").ListGroupItems;
27
- exports.InsertToGroup = require("./insert-to-group").InsertToGroup;
28
- exports.RemoveFromGroup = require("./remove-from-group").RemoveFromGroup;
29
23
  exports.AddUser = require("./add-user").AddUser;
30
24
  exports.DeleteUser = require("./delete-user").DeleteUser;
31
25
  exports.SetUserValues = require("./set-user-values").SetUserValues;
@@ -68,6 +62,7 @@ exports.RecommendUsersToItem = require("./recommend-users-to-item").RecommendUse
68
62
  exports.RecommendItemSegmentsToUser = require("./recommend-item-segments-to-user").RecommendItemSegmentsToUser;
69
63
  exports.RecommendItemSegmentsToItem = require("./recommend-item-segments-to-item").RecommendItemSegmentsToItem;
70
64
  exports.RecommendItemSegmentsToItemSegment = require("./recommend-item-segments-to-item-segment").RecommendItemSegmentsToItemSegment;
65
+ exports.RecommendItemsToItemSegment = require("./recommend-items-to-item-segment").RecommendItemsToItemSegment;
71
66
  exports.SearchItems = require("./search-items").SearchItems;
72
67
  exports.SearchItemSegments = require("./search-item-segments").SearchItemSegments;
73
68
  exports.AddSearchSynonym = require("./add-search-synonym").AddSearchSynonym;
@@ -20,10 +20,10 @@ class InsertToSeries extends rqs.Request {
20
20
  * - Allowed parameters:
21
21
  * - *cascadeCreate*
22
22
  * - Type: boolean
23
- * - 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.
23
+ * - 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`. In case of `item`, an item is created, in case of `series` a series + corresponding item with the same ID is created.
24
24
  */
25
25
  constructor(seriesId, itemType, itemId, time, optional) {
26
- super('POST', `/series/${seriesId}/items/`, 1000, false);
26
+ super('POST', `/series/${seriesId}/items/`, 3000, false);
27
27
  this.seriesId = seriesId;
28
28
  this.itemType = itemType;
29
29
  this.itemId = itemId;
@@ -6,12 +6,12 @@
6
6
  const rqs = require("./request");
7
7
 
8
8
  /**
9
- * Recommends Segments from a result Segmentation that are the most relevant to a particular Segment from a context Segmentation.
9
+ * Recommends Segments from a result [Segmentation](https://docs.recombee.com/segmentations.html) that are the most relevant to a particular Segment from a context Segmentation.
10
10
  * Based on the used Segmentations, this endpoint can be used for example for:
11
11
  * - Recommending the related brands to particular brand
12
12
  * - Recommending the related brands to particular category
13
13
  * - Recommending the related artists to a particular genre (assuming songs are the Items)
14
- * You need to set the used context and result Segmentation the Admin UI in the Scenario settings prior to using this endpoint.
14
+ * You need to set the used context and result Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint.
15
15
  * The returned segments are sorted by relevance (first segment being the most relevant).
16
16
  * It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
17
17
  */
@@ -6,13 +6,13 @@
6
6
  const rqs = require("./request");
7
7
 
8
8
  /**
9
- * Recommends Segments from a Segmentation that are the most relevant to a particular item.
9
+ * Recommends Segments from a [Segmentation](https://docs.recombee.com/segmentations.html) that are the most relevant to a particular item.
10
10
  * Based on the used Segmentation, this endpoint can be used for example for:
11
11
  * - Recommending the related categories
12
12
  * - Recommending the related genres
13
13
  * - Recommending the related brands
14
14
  * - Recommending the related artists
15
- * You need to set the used Segmentation the Admin UI in the Scenario settings prior to using this endpoint.
15
+ * You need to set the used Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint.
16
16
  * The returned segments are sorted by relevance (first segment being the most relevant).
17
17
  * It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
18
18
  */
@@ -6,13 +6,13 @@
6
6
  const rqs = require("./request");
7
7
 
8
8
  /**
9
- * Recommends the top Segments from a Segmentation for a particular user, based on the user's past interactions.
9
+ * Recommends the top Segments from a [Segmentation](https://docs.recombee.com/segmentations.html) for a particular user, based on the user's past interactions.
10
10
  * Based on the used Segmentation, this endpoint can be used for example for:
11
11
  * - Recommending the top categories for the user
12
12
  * - Recommending the top genres for the user
13
13
  * - Recommending the top brands for the user
14
14
  * - Recommending the top artists for the user
15
- * You need to set the used Segmentation the Admin UI in the Scenario settings prior to using this endpoint.
15
+ * You need to set the used Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint.
16
16
  * The returned segments are sorted by relevance (first segment being the most relevant).
17
17
  * It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
18
18
  */
@@ -0,0 +1,214 @@
1
+ /*
2
+ This file is auto-generated, do not edit
3
+ */
4
+
5
+ 'use strict';
6
+ const rqs = require("./request");
7
+
8
+ /**
9
+ * Recommends Items that are the most relevant to a particular Segment from a context [Segmentation](https://docs.recombee.com/segmentations.html).
10
+ * Based on the used Segmentation, this endpoint can be used for example for:
11
+ * - Recommending articles related to a particular topic
12
+ * - Recommending songs belonging to a particular genre
13
+ * - Recommending products produced by a particular brand
14
+ * You need to set the used context Segmentation in the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint.
15
+ * The returned items are sorted by relevance (the first item being the most relevant).
16
+ * It is also possible to use the POST HTTP method (for example, in the case of a very long ReQL filter) — query parameters then become body parameters.
17
+ */
18
+ class RecommendItemsToItemSegment extends rqs.Request {
19
+
20
+ /**
21
+ * Construct the request
22
+ * @param {string} contextSegmentId - ID of the segment from `contextSegmentationId` for which the recommendations are to be generated.
23
+ * @param {string} targetUserId - ID of the user who will see the recommendations.
24
+ * Specifying the *targetUserId* is beneficial because:
25
+ * * It makes the recommendations personalized
26
+ * * Allows the calculation of Actions and Conversions
27
+ * in the graphical user interface,
28
+ * as Recombee can pair the user who got recommendations
29
+ * and who afterward viewed/purchased an item.
30
+ * If you insist on not specifying the user, pass `null`
31
+ * (`None`, `nil`, `NULL` etc., depending on the language) to *targetUserId*.
32
+ * Do not create some special dummy user for getting recommendations,
33
+ * as it could mislead the recommendation models,
34
+ * and result in wrong recommendations.
35
+ * For anonymous/unregistered users, it is possible to use, for example, their session ID.
36
+ * @param {number} count - Number of items to be recommended (N for the top-N recommendation).
37
+ * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value
38
+ * - Allowed parameters:
39
+ * - *scenario*
40
+ * - Type: string
41
+ * - Description: Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".
42
+ * 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.
43
+ * 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.
44
+ * - *cascadeCreate*
45
+ * - Type: boolean
46
+ * - 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.
47
+ * - *returnProperties*
48
+ * - Type: boolean
49
+ * - 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.
50
+ * Example response:
51
+ * ```
52
+ * {
53
+ * "recommId": "0c6189e7-dc1a-429a-b613-192696309361",
54
+ * "recomms":
55
+ * [
56
+ * {
57
+ * "id": "tv-178",
58
+ * "values": {
59
+ * "description": "4K TV with 3D feature",
60
+ * "categories": ["Electronics", "Televisions"],
61
+ * "price": 342,
62
+ * "url": "myshop.com/tv-178"
63
+ * }
64
+ * },
65
+ * {
66
+ * "id": "mixer-42",
67
+ * "values": {
68
+ * "description": "Stainless Steel Mixer",
69
+ * "categories": ["Home & Kitchen"],
70
+ * "price": 39,
71
+ * "url": "myshop.com/mixer-42"
72
+ * }
73
+ * }
74
+ * ],
75
+ * "numberNextRecommsCalls": 0
76
+ * }
77
+ * ```
78
+ * - *includedProperties*
79
+ * - Type: string[]
80
+ * - Description: Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
81
+ * Example response for `includedProperties=description,price`:
82
+ * ```
83
+ * {
84
+ * "recommId": "6842c725-a79f-4537-a02c-f34d668a3f80",
85
+ * "recomms":
86
+ * [
87
+ * {
88
+ * "id": "tv-178",
89
+ * "values": {
90
+ * "description": "4K TV with 3D feature",
91
+ * "price": 342
92
+ * }
93
+ * },
94
+ * {
95
+ * "id": "mixer-42",
96
+ * "values": {
97
+ * "description": "Stainless Steel Mixer",
98
+ * "price": 39
99
+ * }
100
+ * }
101
+ * ],
102
+ * "numberNextRecommsCalls": 0
103
+ * }
104
+ * ```
105
+ * - *filter*
106
+ * - Type: string
107
+ * - 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.
108
+ * Filters can also be assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
109
+ * - *booster*
110
+ * - Type: string
111
+ * - 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.
112
+ * Boosters can also be assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
113
+ * - *logic*
114
+ * - Type: string | object
115
+ * - Description: Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
116
+ * See [this section](https://docs.recombee.com/recommendation_logics.html) for a list of available logics and other details.
117
+ * The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
118
+ * Logic can also be set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
119
+ * - *minRelevance*
120
+ * - Type: string
121
+ * - 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.
122
+ * - *rotationRate*
123
+ * - Type: number
124
+ * - 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.
125
+ * - *rotationTime*
126
+ * - Type: number
127
+ * - 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.
128
+ * - *expertSettings*
129
+ * - Type: object
130
+ * - Description: Dictionary of custom options.
131
+ * - *returnAbGroup*
132
+ * - Type: boolean
133
+ * - Description: If there is a custom AB-testing running, return the name of the group to which the request belongs.
134
+ */
135
+ constructor(contextSegmentId, targetUserId, count, optional) {
136
+ super('POST', '/recomms/item-segments/items/', 3000, false);
137
+ this.contextSegmentId = contextSegmentId;
138
+ this.targetUserId = targetUserId;
139
+ this.count = count;
140
+ optional = optional || {};
141
+ this.scenario = optional.scenario;
142
+ this.cascadeCreate = optional.cascadeCreate;
143
+ this.returnProperties = optional.returnProperties;
144
+ this.includedProperties = optional.includedProperties;
145
+ this.filter = optional.filter;
146
+ this.booster = optional.booster;
147
+ this.logic = optional.logic;
148
+ this.minRelevance = optional.minRelevance;
149
+ this.rotationRate = optional.rotationRate;
150
+ this.rotationTime = optional.rotationTime;
151
+ this.expertSettings = optional.expertSettings;
152
+ this.returnAbGroup = optional.returnAbGroup;
153
+ }
154
+
155
+ /**
156
+ * Get body parameters
157
+ * @return {Object} The values of body parameters (name of parameter: value of the parameter)
158
+ */
159
+ bodyParameters() {
160
+ let params = {};
161
+ params.contextSegmentId = this.contextSegmentId;
162
+ params.targetUserId = this.targetUserId;
163
+ params.count = this.count;
164
+
165
+ if(this.scenario !== undefined)
166
+ params.scenario = this.scenario;
167
+
168
+ if(this.cascadeCreate !== undefined)
169
+ params.cascadeCreate = this.cascadeCreate;
170
+
171
+ if(this.returnProperties !== undefined)
172
+ params.returnProperties = this.returnProperties;
173
+
174
+ if(this.includedProperties !== undefined)
175
+ params.includedProperties = this.includedProperties;
176
+
177
+ if(this.filter !== undefined)
178
+ params.filter = this.filter;
179
+
180
+ if(this.booster !== undefined)
181
+ params.booster = this.booster;
182
+
183
+ if(this.logic !== undefined)
184
+ params.logic = this.logic;
185
+
186
+ if(this.minRelevance !== undefined)
187
+ params.minRelevance = this.minRelevance;
188
+
189
+ if(this.rotationRate !== undefined)
190
+ params.rotationRate = this.rotationRate;
191
+
192
+ if(this.rotationTime !== undefined)
193
+ params.rotationTime = this.rotationTime;
194
+
195
+ if(this.expertSettings !== undefined)
196
+ params.expertSettings = this.expertSettings;
197
+
198
+ if(this.returnAbGroup !== undefined)
199
+ params.returnAbGroup = this.returnAbGroup;
200
+
201
+ return params;
202
+ }
203
+
204
+ /**
205
+ * Get query parameters
206
+ * @return {Object} The values of query parameters (name of parameter: value of the parameter)
207
+ */
208
+ queryParameters() {
209
+ let params = {};
210
+ return params;
211
+ }
212
+ }
213
+
214
+ exports.RecommendItemsToItemSegment = RecommendItemsToItemSegment
@@ -15,14 +15,12 @@ class RemoveFromSeries extends rqs.Request {
15
15
  * @param {string} seriesId - ID of the series from which a series item is to be removed.
16
16
  * @param {string} itemType - Type of the item to be removed.
17
17
  * @param {string} itemId - ID of the item iff `itemType` is `item`. ID of the series iff `itemType` is `series`.
18
- * @param {number} time - Time index of the item to be removed.
19
18
  */
20
- constructor(seriesId, itemType, itemId, time) {
21
- super('DELETE', `/series/${seriesId}/items/`, 1000, false);
19
+ constructor(seriesId, itemType, itemId) {
20
+ super('DELETE', `/series/${seriesId}/items/`, 3000, false);
22
21
  this.seriesId = seriesId;
23
22
  this.itemType = itemType;
24
23
  this.itemId = itemId;
25
- this.time = time;
26
24
  }
27
25
 
28
26
  /**
@@ -31,6 +29,8 @@ class RemoveFromSeries extends rqs.Request {
31
29
  */
32
30
  bodyParameters() {
33
31
  let params = {};
32
+ params.itemType = this.itemType;
33
+ params.itemId = this.itemId;
34
34
 
35
35
  return params;
36
36
  }
@@ -41,9 +41,6 @@ class RemoveFromSeries extends rqs.Request {
41
41
  */
42
42
  queryParameters() {
43
43
  let params = {};
44
- params.itemType = this.itemType;
45
- params.itemId = this.itemId;
46
- params.time = this.time;
47
44
  return params;
48
45
  }
49
46
  }
@@ -19,4 +19,4 @@ class Request {
19
19
  }
20
20
  }
21
21
 
22
- exports.Request = Request
22
+ exports.Request = Request
@@ -35,7 +35,7 @@ class SetViewPortion extends rqs.Request {
35
35
  * - Description: A dictionary of additional data for the interaction.
36
36
  */
37
37
  constructor(userId, itemId, portion, optional) {
38
- super('POST', '/viewportions/', 1000, false);
38
+ super('POST', '/viewportions/', 3000, false);
39
39
  this.userId = userId;
40
40
  this.itemId = itemId;
41
41
  this.portion = portion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recombee-api-client",
3
- "version": "4.1.4",
3
+ "version": "5.0.0",
4
4
  "description": "Node.js client (SDK) for easy use of the Recombee recommendation API",
5
5
  "main": "index.js",
6
6
  "types": "lib/index.d.ts",
@@ -20,6 +20,9 @@
20
20
  "API",
21
21
  "SDK"
22
22
  ],
23
+ "engines": {
24
+ "node": ">=13.2.0"
25
+ },
23
26
  "author": "Ondrej Fiedler <ondrej.fiedler@recombee.com> (https://www.recombee.com/)",
24
27
  "license": "MIT",
25
28
  "bugs": {
@@ -27,12 +30,12 @@
27
30
  },
28
31
  "homepage": "https://github.com/Recombee/node-api-client#readme",
29
32
  "dependencies": {
30
- "got": "^11.8.2",
31
- "jssha": "^2.3.0"
33
+ "jssha": "^2.3.0",
34
+ "ky": "^1.7.2"
32
35
  },
33
36
  "devDependencies": {
34
37
  "chai": "^3.5.0",
35
- "mocha": "~10.2.0",
36
- "typescript": "~5.3.3"
38
+ "mocha": "~10.2.0",
39
+ "typescript": "~5.3.3"
37
40
  }
38
41
  }
@@ -26,7 +26,6 @@ describe('AddBookmark', function(){
26
26
  new rqs.AddBookmark('entity_id','entity_id',{'timestamp': '2013-10-29T09:38:41.341Z'}),
27
27
  new rqs.AddBookmark('entity_id','nonex_id'),
28
28
  new rqs.AddBookmark('nonex_id','entity_id'),
29
- new rqs.AddBookmark('entity_id','entity_id',{'timestamp': -15}),
30
29
  new rqs.AddBookmark('u_id2','i_id2',{'cascadeCreate': true,'timestamp': 5}),
31
30
  new rqs.AddBookmark('u_id2','i_id2',{'cascadeCreate': true,'timestamp': 5})
32
31
  ];
@@ -38,9 +37,8 @@ describe('AddBookmark', function(){
38
37
  chai.equal(responses[2].code, 200);
39
38
  chai.equal(responses[3].code, 404);
40
39
  chai.equal(responses[4].code, 404);
41
- chai.equal(responses[5].code, 400);
42
- chai.equal(responses[6].code, 200);
43
- chai.equal(responses[7].code, 409);
40
+ chai.equal(responses[5].code, 200);
41
+ chai.equal(responses[6].code, 409);
44
42
  done();
45
43
  });
46
44
  });
@@ -89,21 +89,6 @@ describe('AddBookmark', function(){
89
89
  }));
90
90
  });
91
91
 
92
- it ('fails with invalid time', (done) => {
93
- let req, req2, resp;
94
- req = new rqs.AddBookmark('entity_id','entity_id',{'timestamp': -15});
95
- env.client.send(req,((err,res) => {
96
- if(err) {
97
- chai.equal(err.name, 'ResponseError');
98
- chai.equal(err.statusCode, 400);
99
- done();
100
- }
101
- else {
102
- chai.fail();
103
- }
104
- }));
105
- });
106
-
107
92
  it ('really stores interaction to the system', (done) => {
108
93
  let req, req2, resp;
109
94
  req = new rqs.AddBookmark('u_id2','i_id2',{'cascadeCreate': true,'timestamp': 5});
@@ -81,23 +81,6 @@ describe('AddBookmark', function(){
81
81
  });
82
82
  });
83
83
 
84
- it ('fails with invalid time', (done) => {
85
- let req, req2, resp;
86
- req = new rqs.AddBookmark('entity_id','entity_id',{'timestamp': -15});
87
- env.client.send(req)
88
- .then((res) => {
89
- chai.fail();
90
- done();
91
- })
92
- .catch((err) => {
93
- if (err instanceof recombee.errors.ResponseError) {
94
- chai.equal(err.statusCode, 400);
95
- done();
96
- }
97
- throw err;
98
- });
99
- });
100
-
101
84
  it ('really stores interaction to the system', (done) => {
102
85
  let req, req2, resp;
103
86
  req = new rqs.AddBookmark('u_id2','i_id2',{'cascadeCreate': true,'timestamp': 5});
@@ -26,7 +26,6 @@ describe('AddCartAddition', function(){
26
26
  new rqs.AddCartAddition('entity_id','entity_id',{'timestamp': '2013-10-29T09:38:41.341Z'}),
27
27
  new rqs.AddCartAddition('entity_id','nonex_id'),
28
28
  new rqs.AddCartAddition('nonex_id','entity_id'),
29
- new rqs.AddCartAddition('entity_id','entity_id',{'timestamp': -15}),
30
29
  new rqs.AddCartAddition('u_id2','i_id2',{'cascadeCreate': true,'timestamp': 5}),
31
30
  new rqs.AddCartAddition('u_id2','i_id2',{'cascadeCreate': true,'timestamp': 5})
32
31
  ];
@@ -38,9 +37,8 @@ describe('AddCartAddition', function(){
38
37
  chai.equal(responses[2].code, 200);
39
38
  chai.equal(responses[3].code, 404);
40
39
  chai.equal(responses[4].code, 404);
41
- chai.equal(responses[5].code, 400);
42
- chai.equal(responses[6].code, 200);
43
- chai.equal(responses[7].code, 409);
40
+ chai.equal(responses[5].code, 200);
41
+ chai.equal(responses[6].code, 409);
44
42
  done();
45
43
  });
46
44
  });
@@ -89,21 +89,6 @@ describe('AddCartAddition', function(){
89
89
  }));
90
90
  });
91
91
 
92
- it ('fails with invalid time', (done) => {
93
- let req, req2, resp;
94
- req = new rqs.AddCartAddition('entity_id','entity_id',{'timestamp': -15});
95
- env.client.send(req,((err,res) => {
96
- if(err) {
97
- chai.equal(err.name, 'ResponseError');
98
- chai.equal(err.statusCode, 400);
99
- done();
100
- }
101
- else {
102
- chai.fail();
103
- }
104
- }));
105
- });
106
-
107
92
  it ('really stores interaction to the system', (done) => {
108
93
  let req, req2, resp;
109
94
  req = new rqs.AddCartAddition('u_id2','i_id2',{'cascadeCreate': true,'timestamp': 5});
@@ -81,23 +81,6 @@ describe('AddCartAddition', function(){
81
81
  });
82
82
  });
83
83
 
84
- it ('fails with invalid time', (done) => {
85
- let req, req2, resp;
86
- req = new rqs.AddCartAddition('entity_id','entity_id',{'timestamp': -15});
87
- env.client.send(req)
88
- .then((res) => {
89
- chai.fail();
90
- done();
91
- })
92
- .catch((err) => {
93
- if (err instanceof recombee.errors.ResponseError) {
94
- chai.equal(err.statusCode, 400);
95
- done();
96
- }
97
- throw err;
98
- });
99
- });
100
-
101
84
  it ('really stores interaction to the system', (done) => {
102
85
  let req, req2, resp;
103
86
  req = new rqs.AddCartAddition('u_id2','i_id2',{'cascadeCreate': true,'timestamp': 5});