diff --git a/doc/DeleteViewPortion.html b/doc/DeleteViewPortion.html new file mode 100644 index 0000000..7638279 --- /dev/null +++ b/doc/DeleteViewPortion.html @@ -0,0 +1,492 @@ + + + + + JSDoc: Class: DeleteViewPortion + + + + + + + + + + +
+ +

Class: DeleteViewPortion

+ + + + + + +
+ +
+ +

DeleteViewPortion(userId, itemId, optional)

+ +
The view portions feature is currently experimental. +Deletes an existing view portion specified by (`userId`, `itemId`, `sessionId`) from the database.
+ + +
+ +
+
+ + + + +

Constructor

+ + + +

new DeleteViewPortion(userId, itemId, optional)

+ + + + + + +
+ Construct the request +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
userId + + +string + + + + ID of the user who rated the item.
itemId + + +string + + + + ID of the item which was rated.
optional + + +Object + + + + Optional parameters given as an object with structure name of the parameter: value +- Allowed parameters: + - *sessionId* + - Type: string + - Description: Identifier of a session.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

bodyParameters() → {Object}

+ + + + + + +
+ Get body parameters +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ The values of body parameters (name of parameter: value of the parameter) +
+ + + +
+
+ Type +
+
+ +Object + + +
+
+ + + + + + + + + + + + + +

queryParameters() → {Object}

+ + + + + + +
+ Get query parameters +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ The values of query parameters (name of parameter: value of the parameter) +
+ + + +
+
+ Type +
+
+ +Object + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/doc/ListItemViewPortions.html b/doc/ListItemViewPortions.html new file mode 100644 index 0000000..49248b2 --- /dev/null +++ b/doc/ListItemViewPortions.html @@ -0,0 +1,442 @@ + + + + + JSDoc: Class: ListItemViewPortions + + + + + + + + + + +
+ +

Class: ListItemViewPortions

+ + + + + + +
+ +
+ +

ListItemViewPortions(itemId)

+ +
The view portions feature is currently experimental. +List all the view portions of an item ever submitted by different users.
+ + +
+ +
+
+ + + + +

Constructor

+ + + +

new ListItemViewPortions(itemId)

+ + + + + + +
+ Construct the request +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
itemId + + +string + + + + ID of the item of which the view portions are to be listed.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

bodyParameters() → {Object}

+ + + + + + +
+ Get body parameters +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ The values of body parameters (name of parameter: value of the parameter) +
+ + + +
+
+ Type +
+
+ +Object + + +
+
+ + + + + + + + + + + + + +

queryParameters() → {Object}

+ + + + + + +
+ Get query parameters +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ The values of query parameters (name of parameter: value of the parameter) +
+ + + +
+
+ Type +
+
+ +Object + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/doc/ListUserViewPortions.html b/doc/ListUserViewPortions.html new file mode 100644 index 0000000..852a79b --- /dev/null +++ b/doc/ListUserViewPortions.html @@ -0,0 +1,442 @@ + + + + + JSDoc: Class: ListUserViewPortions + + + + + + + + + + +
+ +

Class: ListUserViewPortions

+ + + + + + +
+ +
+ +

ListUserViewPortions(userId)

+ +
The view portions feature is currently experimental. +List all the view portions ever submitted by a given user.
+ + +
+ +
+
+ + + + +

Constructor

+ + + +

new ListUserViewPortions(userId)

+ + + + + + +
+ Construct the request +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
userId + + +string + + + + ID of the user whose view portions are to be listed.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

bodyParameters() → {Object}

+ + + + + + +
+ Get body parameters +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ The values of body parameters (name of parameter: value of the parameter) +
+ + + +
+
+ Type +
+
+ +Object + + +
+
+ + + + + + + + + + + + + +

queryParameters() → {Object}

+ + + + + + +
+ Get query parameters +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ The values of query parameters (name of parameter: value of the parameter) +
+ + + +
+
+ Type +
+
+ +Object + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/doc/SetViewPortion.html b/doc/SetViewPortion.html new file mode 100644 index 0000000..65fad99 --- /dev/null +++ b/doc/SetViewPortion.html @@ -0,0 +1,522 @@ + + + + + JSDoc: Class: SetViewPortion + + + + + + + + + + +
+ +

Class: SetViewPortion

+ + + + + + +
+ +
+ +

SetViewPortion(userId, itemId, portion, optional)

+ +
The view portions feature is currently experimental. +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.
+ + +
+ +
+
+ + + + +

Constructor

+ + + +

new SetViewPortion(userId, itemId, portion, optional)

+ + + + + + +
+ Construct the request +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
userId + + +string + + + + User who viewed a portion of the item
itemId + + +string + + + + Viewed item
portion + + +number + + + + Viewed portion of the item (number between 0.0 (viewed nothing) and 1.0 (viewed full item) ).
optional + + +Object + + + + 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 + - *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. + - *cascadeCreate* + - Type: boolean + - Description: Sets whether the given user/item should be created if not present in the database.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

bodyParameters() → {Object}

+ + + + + + +
+ Get body parameters +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ The values of body parameters (name of parameter: value of the parameter) +
+ + + +
+
+ Type +
+
+ +Object + + +
+
+ + + + + + + + + + + + + +

queryParameters() → {Object}

+ + + + + + +
+ Get query parameters +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ The values of query parameters (name of parameter: value of the parameter) +
+ + + +
+
+ Type +
+
+ +Object + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/doc/index.html b/doc/index.html index f58c1ca..15103b6 100644 --- a/doc/index.html +++ b/doc/index.html @@ -50,13 +50,13 @@


diff --git a/doc/requests_delete-view-portion.js.html b/doc/requests_delete-view-portion.js.html new file mode 100644 index 0000000..69a763b --- /dev/null +++ b/doc/requests_delete-view-portion.js.html @@ -0,0 +1,107 @@ + + + + + JSDoc: Source: requests/delete-view-portion.js + + + + + + + + + + +
+ +

Source: requests/delete-view-portion.js

+ + + + + + +
+
+
/*
+ This file is auto-generated, do not edit
+*/
+
+'use strict';
+const rqs = require("./request");
+
+/**
+ * The view portions feature is currently experimental.
+ * Deletes an existing view portion specified by (`userId`, `itemId`, `sessionId`) from the database.
+ */
+class DeleteViewPortion extends rqs.Request {
+
+  /**
+   * Construct the request
+   * @param {string} userId - ID of the user who rated the item.
+   * @param {string} itemId - ID of the item which was rated.
+   * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value
+   * - Allowed parameters:
+   *     - *sessionId*
+   *         - Type: string
+   *         - Description: Identifier of a session.
+   */
+  constructor(userId, itemId, optional) {
+    super('DELETE', '/viewportions/', 1000, false);
+    this.userId = userId;
+    this.itemId = itemId;
+    optional = optional || {};
+    this.sessionId = optional.sessionId;
+  }
+
+  /**
+   * 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.userId = this.userId;
+    params.itemId = this.itemId;
+    if (this.sessionId !== undefined)
+      params.sessionId = this.sessionId;
+    return params;
+  }
+}
+
+exports.DeleteViewPortion = DeleteViewPortion
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/doc/requests_list-item-view-portions.js.html b/doc/requests_list-item-view-portions.js.html new file mode 100644 index 0000000..80abcc7 --- /dev/null +++ b/doc/requests_list-item-view-portions.js.html @@ -0,0 +1,94 @@ + + + + + JSDoc: Source: requests/list-item-view-portions.js + + + + + + + + + + +
+ +

Source: requests/list-item-view-portions.js

+ + + + + + +
+
+
/*
+ This file is auto-generated, do not edit
+*/
+
+'use strict';
+const rqs = require("./request");
+
+/**
+ * The view portions feature is currently experimental.
+ * List 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.
+   */
+  constructor(itemId) {
+    super('GET', `/items/${itemId}/viewportions/`, 100000, false);
+    this.itemId = itemId;
+  }
+
+  /**
+   * 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.ListItemViewPortions = ListItemViewPortions
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/doc/requests_list-user-view-portions.js.html b/doc/requests_list-user-view-portions.js.html new file mode 100644 index 0000000..3f2a7ed --- /dev/null +++ b/doc/requests_list-user-view-portions.js.html @@ -0,0 +1,94 @@ + + + + + JSDoc: Source: requests/list-user-view-portions.js + + + + + + + + + + +
+ +

Source: requests/list-user-view-portions.js

+ + + + + + +
+
+
/*
+ This file is auto-generated, do not edit
+*/
+
+'use strict';
+const rqs = require("./request");
+
+/**
+ * The view portions feature is currently experimental.
+ * List all the view portions ever submitted by a given user.
+ */
+class ListUserViewPortions extends rqs.Request {
+
+  /**
+   * Construct the request
+   * @param {string} userId - ID of the user whose view portions are to be listed.
+   */
+  constructor(userId) {
+    super('GET', `/users/${userId}/viewportions/`, 100000, false);
+    this.userId = userId;
+  }
+
+  /**
+   * 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.ListUserViewPortions = ListUserViewPortions
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/doc/requests_set-view-portion.js.html b/doc/requests_set-view-portion.js.html new file mode 100644 index 0000000..e134acd --- /dev/null +++ b/doc/requests_set-view-portion.js.html @@ -0,0 +1,126 @@ + + + + + JSDoc: Source: requests/set-view-portion.js + + + + + + + + + + +
+ +

Source: requests/set-view-portion.js

+ + + + + + +
+
+
/*
+ This file is auto-generated, do not edit
+*/
+
+'use strict';
+const rqs = require("./request");
+
+/**
+ * The view portions feature is currently experimental.
+ * 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.
+ */
+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) ).
+   * @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
+   *     - *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.
+   *     - *cascadeCreate*
+   *         - Type: boolean
+   *         - Description: Sets whether the given user/item should be created if not present in the database.
+   */
+  constructor(userId, itemId, portion, optional) {
+    super('POST', '/viewportions/', 1000, false);
+    this.userId = userId;
+    this.itemId = itemId;
+    this.portion = portion;
+    optional = optional || {};
+    this.sessionId = optional.sessionId;
+    this.timestamp = optional.timestamp;
+    this.cascadeCreate = optional.cascadeCreate;
+  }
+
+  /**
+   * Get body parameters
+   * @return {Object} The values of body parameters (name of parameter: value of the parameter)
+   */
+  bodyParameters() {
+    let params = {};
+    params.userId = this.userId;
+    params.itemId = this.itemId;
+    params.portion = this.portion;
+
+    if(this.sessionId !== undefined)
+      params.sessionId = this.sessionId;
+
+    if(this.timestamp !== undefined)
+      params.timestamp = this.timestamp;
+
+    if(this.cascadeCreate !== undefined)
+      params.cascadeCreate = this.cascadeCreate;
+
+    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.SetViewPortion = SetViewPortion
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/lib/api-client.js b/lib/api-client.js index 2740b04..3b125d3 100644 --- a/lib/api-client.js +++ b/lib/api-client.js @@ -44,7 +44,7 @@ class ApiClient { uri: url, headers: {'Accept': 'application/json', 'Content-Type': 'application/json', - 'User-Agent': 'recombee-node-api-client/1.4.0'}, + 'User-Agent': 'recombee-node-api-client/1.5.0'}, timeout: request.timeout, resolveWithFullResponse: true, json: true diff --git a/lib/requests/delete-view-portion.js b/lib/requests/delete-view-portion.js new file mode 100644 index 0000000..6354b90 --- /dev/null +++ b/lib/requests/delete-view-portion.js @@ -0,0 +1,56 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict'; +const rqs = require("./request"); + +/** + * The view portions feature is currently experimental. + * Deletes an existing view portion specified by (`userId`, `itemId`, `sessionId`) from the database. + */ +class DeleteViewPortion extends rqs.Request { + + /** + * Construct the request + * @param {string} userId - ID of the user who rated the item. + * @param {string} itemId - ID of the item which was rated. + * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value + * - Allowed parameters: + * - *sessionId* + * - Type: string + * - Description: Identifier of a session. + */ + constructor(userId, itemId, optional) { + super('DELETE', '/viewportions/', 1000, false); + this.userId = userId; + this.itemId = itemId; + optional = optional || {}; + this.sessionId = optional.sessionId; + } + + /** + * 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.userId = this.userId; + params.itemId = this.itemId; + if (this.sessionId !== undefined) + params.sessionId = this.sessionId; + return params; + } +} + +exports.DeleteViewPortion = DeleteViewPortion diff --git a/lib/requests/index.js b/lib/requests/index.js index 21027a2..459471f 100644 --- a/lib/requests/index.js +++ b/lib/requests/index.js @@ -54,6 +54,10 @@ exports.AddBookmark = require("./add-bookmark").AddBookmark; exports.DeleteBookmark = require("./delete-bookmark").DeleteBookmark; exports.ListItemBookmarks = require("./list-item-bookmarks").ListItemBookmarks; exports.ListUserBookmarks = require("./list-user-bookmarks").ListUserBookmarks; +exports.SetViewPortion = require("./set-view-portion").SetViewPortion; +exports.DeleteViewPortion = require("./delete-view-portion").DeleteViewPortion; +exports.ListItemViewPortions = require("./list-item-view-portions").ListItemViewPortions; +exports.ListUserViewPortions = require("./list-user-view-portions").ListUserViewPortions; exports.UserBasedRecommendation = require("./user-based-recommendation").UserBasedRecommendation; exports.ItemBasedRecommendation = require("./item-based-recommendation").ItemBasedRecommendation; exports.ResetDatabase = require("./reset-database").ResetDatabase; diff --git a/lib/requests/list-item-view-portions.js b/lib/requests/list-item-view-portions.js new file mode 100644 index 0000000..6eec736 --- /dev/null +++ b/lib/requests/list-item-view-portions.js @@ -0,0 +1,43 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict'; +const rqs = require("./request"); + +/** + * The view portions feature is currently experimental. + * List 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. + */ + constructor(itemId) { + super('GET', `/items/${itemId}/viewportions/`, 100000, false); + this.itemId = itemId; + } + + /** + * 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.ListItemViewPortions = ListItemViewPortions diff --git a/lib/requests/list-user-view-portions.js b/lib/requests/list-user-view-portions.js new file mode 100644 index 0000000..15e7454 --- /dev/null +++ b/lib/requests/list-user-view-portions.js @@ -0,0 +1,43 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict'; +const rqs = require("./request"); + +/** + * The view portions feature is currently experimental. + * List all the view portions ever submitted by a given user. + */ +class ListUserViewPortions extends rqs.Request { + + /** + * Construct the request + * @param {string} userId - ID of the user whose view portions are to be listed. + */ + constructor(userId) { + super('GET', `/users/${userId}/viewportions/`, 100000, false); + this.userId = userId; + } + + /** + * 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.ListUserViewPortions = ListUserViewPortions diff --git a/lib/requests/set-view-portion.js b/lib/requests/set-view-portion.js new file mode 100644 index 0000000..cb1991e --- /dev/null +++ b/lib/requests/set-view-portion.js @@ -0,0 +1,75 @@ +/* + This file is auto-generated, do not edit +*/ + +'use strict'; +const rqs = require("./request"); + +/** + * The view portions feature is currently experimental. + * 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. + */ +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) ). + * @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 + * - *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. + * - *cascadeCreate* + * - Type: boolean + * - Description: Sets whether the given user/item should be created if not present in the database. + */ + constructor(userId, itemId, portion, optional) { + super('POST', '/viewportions/', 1000, false); + this.userId = userId; + this.itemId = itemId; + this.portion = portion; + optional = optional || {}; + this.sessionId = optional.sessionId; + this.timestamp = optional.timestamp; + this.cascadeCreate = optional.cascadeCreate; + } + + /** + * Get body parameters + * @return {Object} The values of body parameters (name of parameter: value of the parameter) + */ + bodyParameters() { + let params = {}; + params.userId = this.userId; + params.itemId = this.itemId; + params.portion = this.portion; + + if(this.sessionId !== undefined) + params.sessionId = this.sessionId; + + if(this.timestamp !== undefined) + params.timestamp = this.timestamp; + + if(this.cascadeCreate !== undefined) + params.cascadeCreate = this.cascadeCreate; + + 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.SetViewPortion = SetViewPortion diff --git a/package.json b/package.json index 7ee164e..24c13dc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "recombee-api-client", - "version": "1.4.0", + "version": "1.5.0", "description": "Node.js client (SDK) for easy use of the Recombee recommendation API", "main": "index.js", "scripts": { diff --git a/test/delete-view-portion-batch_test.js b/test/delete-view-portion-batch_test.js new file mode 100644 index 0000000..46dfaaa --- /dev/null +++ b/test/delete-view-portion-batch_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('DeleteViewPortion', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(env.setInteractions) + .then(()=> { + done(); + }); + }); + it ('works in batch', (done) => { + let requests = [ + new rqs.DeleteViewPortion('user','item'), + new rqs.DeleteViewPortion('user','item') + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 200); + chai.equal(responses[1].code, 404); + done(); + }); + }); +}); \ No newline at end of file diff --git a/test/delete-view-portion-callback_test.js b/test/delete-view-portion-callback_test.js new file mode 100644 index 0000000..fefefa0 --- /dev/null +++ b/test/delete-view-portion-callback_test.js @@ -0,0 +1,46 @@ +/* + 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('DeleteViewPortion', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(env.setInteractions) + .then(()=> { + done(); + }); + }); + + it ('does not fail with existing entity id', (done) => { + let req, req2, resp; + req = new rqs.DeleteViewPortion('user','item'); + env.client.send(req,((err,res) => { + if(err) { + chai.fail(); + } + else { + req = new rqs.DeleteViewPortion('user','item'); + 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-view-portion-test.js b/test/delete-view-portion-test.js new file mode 100644 index 0000000..ad79fdd --- /dev/null +++ b/test/delete-view-portion-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('DeleteViewPortion', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(env.setInteractions) + .then(()=> { + done(); + }); + }); + + it ('does not fail with existing entity id', (done) => { + let req, req2, resp; + req = new rqs.DeleteViewPortion('user','item'); + env.client.send(req) + .then((res) => { + req = new rqs.DeleteViewPortion('user','item'); + env.client.send(req) + .then((res) => { + chai.fail(); + done(); + }) + .catch(recombee.errors.ResponseError,(err) => { + chai.equal(err.statusCode, 404); + done(); + }); + }); + }); +}); diff --git a/test/list-item-view-portions-batch_test.js b/test/list-item-view-portions-batch_test.js new file mode 100644 index 0000000..df18dac --- /dev/null +++ b/test/list-item-view-portions-batch_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('ListItemViewPortions', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(env.setInteractions) + .then(()=> { + setTimeout(done, 20000); + }); + }); + it ('works in batch', (done) => { + let requests = [ + new rqs.ListItemViewPortions('item') + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 200); + chai.equal(responses[0].json.length, 1); + chai.deepEqual('item', responses[0].json[0]['itemId']); + chai.deepEqual('user', responses[0].json[0]['userId']); + done(); + }); + }); +}); \ No newline at end of file diff --git a/test/list-item-view-portions-callback_test.js b/test/list-item-view-portions-callback_test.js new file mode 100644 index 0000000..7a7bf99 --- /dev/null +++ b/test/list-item-view-portions-callback_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('ListItemViewPortions', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(env.setInteractions) + .then(()=> { + setTimeout(done, 20000); + }); + }); + + it ('lists interactions', (done) => { + let req, req2, resp; + req = new rqs.ListItemViewPortions('item'); + env.client.send(req,((err,res) => { + if(err) { + chai.fail(); + } + else { + chai.equal(res.length, 1); + chai.deepEqual('item', res[0]['itemId']); + chai.deepEqual('user', res[0]['userId']); + done(); + } + })); + }); +}); diff --git a/test/list-item-view-portions-test.js b/test/list-item-view-portions-test.js new file mode 100644 index 0000000..d52dc53 --- /dev/null +++ b/test/list-item-view-portions-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('ListItemViewPortions', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(env.setInteractions) + .then(()=> { + setTimeout(done, 20000); + }); + }); + + it ('lists interactions', (done) => { + let req, req2, resp; + req = new rqs.ListItemViewPortions('item'); + env.client.send(req) + .then((res) => { + chai.equal(res.length, 1); + chai.deepEqual('item', res[0]['itemId']); + chai.deepEqual('user', res[0]['userId']); + done(); + }); + }); +}); diff --git a/test/list-user-view-portions-batch_test.js b/test/list-user-view-portions-batch_test.js new file mode 100644 index 0000000..bc10629 --- /dev/null +++ b/test/list-user-view-portions-batch_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('ListUserViewPortions', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(env.setInteractions) + .then(()=> { + setTimeout(done, 20000); + }); + }); + it ('works in batch', (done) => { + let requests = [ + new rqs.ListUserViewPortions('user') + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 200); + chai.equal(responses[0].json.length, 1); + chai.deepEqual('item', responses[0].json[0]['itemId']); + chai.deepEqual('user', responses[0].json[0]['userId']); + done(); + }); + }); +}); \ No newline at end of file diff --git a/test/list-user-view-portions-callback_test.js b/test/list-user-view-portions-callback_test.js new file mode 100644 index 0000000..4ab7283 --- /dev/null +++ b/test/list-user-view-portions-callback_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('ListUserViewPortions', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(env.setInteractions) + .then(()=> { + setTimeout(done, 20000); + }); + }); + + it ('lists user interactions', (done) => { + let req, req2, resp; + req = new rqs.ListUserViewPortions('user'); + env.client.send(req,((err,res) => { + if(err) { + chai.fail(); + } + else { + chai.equal(res.length, 1); + chai.deepEqual('item', res[0]['itemId']); + chai.deepEqual('user', res[0]['userId']); + done(); + } + })); + }); +}); diff --git a/test/list-user-view-portions-test.js b/test/list-user-view-portions-test.js new file mode 100644 index 0000000..5077eaa --- /dev/null +++ b/test/list-user-view-portions-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('ListUserViewPortions', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(env.setInteractions) + .then(()=> { + setTimeout(done, 20000); + }); + }); + + it ('lists user interactions', (done) => { + let req, req2, resp; + req = new rqs.ListUserViewPortions('user'); + env.client.send(req) + .then((res) => { + chai.equal(res.length, 1); + chai.deepEqual('item', res[0]['itemId']); + chai.deepEqual('user', res[0]['userId']); + done(); + }); + }); +}); diff --git a/test/set-environment.js b/test/set-environment.js index 63ca3d5..891989e 100644 --- a/test/set-environment.js +++ b/test/set-environment.js @@ -35,7 +35,8 @@ var setInteractions = (() => { new rqs.AddPurchase('user', 'item', {'timestamp': 0}), new rqs.AddRating('user', 'item', -1, {'timestamp': 0}), new rqs.AddCartAddition('user', 'item', {'timestamp': 0}), - new rqs.AddBookmark('user', 'item', {'timestamp': 0}) + new rqs.AddBookmark('user', 'item', {'timestamp': 0}), + new rqs.SetViewPortion('user', 'item',1, {'timestamp': 0}) ]); return client.send(requests); diff --git a/test/set-view-portion-batch_test.js b/test/set-view-portion-batch_test.js new file mode 100644 index 0000000..032a15a --- /dev/null +++ b/test/set-view-portion-batch_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('SetViewPortion', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + it ('works in batch', (done) => { + let requests = [ + new rqs.SetViewPortion('u_id','i_id',1,{'cascadeCreate': true}), + new rqs.SetViewPortion('entity_id','entity_id',0), + new rqs.SetViewPortion('entity_id','nonex_id',1), + new rqs.SetViewPortion('nonex_id','entity_id',0.5), + new rqs.SetViewPortion('entity_id','entity_id',0,{'timestamp': -15}), + new rqs.SetViewPortion('entity_id','entity_id',-2), + new rqs.SetViewPortion('entity_id','entity_id',0.7,{'sessionId': 'a****'}) + ]; + + env.client.send(new rqs.Batch(requests)) + .then((responses) => { + chai.equal(responses[0].code, 200); + chai.equal(responses[1].code, 200); + chai.equal(responses[2].code, 404); + chai.equal(responses[3].code, 404); + chai.equal(responses[4].code, 400); + chai.equal(responses[5].code, 400); + chai.equal(responses[6].code, 400); + done(); + }); + }); +}); \ No newline at end of file diff --git a/test/set-view-portion-callback_test.js b/test/set-view-portion-callback_test.js new file mode 100644 index 0000000..16059e0 --- /dev/null +++ b/test/set-view-portion-callback_test.js @@ -0,0 +1,123 @@ +/* + 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('SetViewPortion', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('does not fail with cascadeCreate', (done) => { + let req, req2, resp; + req = new rqs.SetViewPortion('u_id','i_id',1,{'cascadeCreate': true}); + env.client.send(req,((err,res) => { + if(err) { + chai.fail(); + } + else { + done(); + } + })); + }); + + it ('does not fail with existing item and user', (done) => { + let req, req2, resp; + req = new rqs.SetViewPortion('entity_id','entity_id',0); + env.client.send(req,((err,res) => { + if(err) { + chai.fail(); + } + else { + done(); + } + })); + }); + + it ('fails with nonexisting item id', (done) => { + let req, req2, resp; + req = new rqs.SetViewPortion('entity_id','nonex_id',1); + env.client.send(req,((err,res) => { + if(err) { + chai.equal(err.name, 'ResponseError'); + chai.equal(err.statusCode, 404); + done(); + } + else { + chai.fail(); + } + })); + }); + + it ('fails with nonexisting user id', (done) => { + let req, req2, resp; + req = new rqs.SetViewPortion('nonex_id','entity_id',0.5); + env.client.send(req,((err,res) => { + if(err) { + chai.equal(err.name, 'ResponseError'); + chai.equal(err.statusCode, 404); + done(); + } + else { + chai.fail(); + } + })); + }); + + it ('fails with invalid time', (done) => { + let req, req2, resp; + req = new rqs.SetViewPortion('entity_id','entity_id',0,{'timestamp': -15}); + env.client.send(req,((err,res) => { + if(err) { + chai.equal(err.name, 'ResponseError'); + chai.equal(err.statusCode, 400); + done(); + } + else { + chai.fail(); + } + })); + }); + + it ('fails with invalid portion', (done) => { + let req, req2, resp; + req = new rqs.SetViewPortion('entity_id','entity_id',-2); + env.client.send(req,((err,res) => { + if(err) { + chai.equal(err.name, 'ResponseError'); + chai.equal(err.statusCode, 400); + done(); + } + else { + chai.fail(); + } + })); + }); + + it ('fails with invalid sessionId', (done) => { + let req, req2, resp; + req = new rqs.SetViewPortion('entity_id','entity_id',0.7,{'sessionId': 'a****'}); + 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/set-view-portion-test.js b/test/set-view-portion-test.js new file mode 100644 index 0000000..68891a4 --- /dev/null +++ b/test/set-view-portion-test.js @@ -0,0 +1,110 @@ +/* + 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('SetViewPortion', function(){ + this.timeout(150000); + + before(function(done){ + + env.setEnvironment() + .then(()=> { + done(); + }); + }); + + it ('does not fail with cascadeCreate', (done) => { + let req, req2, resp; + req = new rqs.SetViewPortion('u_id','i_id',1,{'cascadeCreate': true}); + env.client.send(req) + .then((res) => { + done(); + }); + }); + + it ('does not fail with existing item and user', (done) => { + let req, req2, resp; + req = new rqs.SetViewPortion('entity_id','entity_id',0); + env.client.send(req) + .then((res) => { + done(); + }); + }); + + it ('fails with nonexisting item id', (done) => { + let req, req2, resp; + req = new rqs.SetViewPortion('entity_id','nonex_id',1); + env.client.send(req) + .then((res) => { + chai.fail(); + done(); + }) + .catch(recombee.errors.ResponseError,(err) => { + chai.equal(err.statusCode, 404); + done(); + }); + }); + + it ('fails with nonexisting user id', (done) => { + let req, req2, resp; + req = new rqs.SetViewPortion('nonex_id','entity_id',0.5); + env.client.send(req) + .then((res) => { + chai.fail(); + done(); + }) + .catch(recombee.errors.ResponseError,(err) => { + chai.equal(err.statusCode, 404); + done(); + }); + }); + + it ('fails with invalid time', (done) => { + let req, req2, resp; + req = new rqs.SetViewPortion('entity_id','entity_id',0,{'timestamp': -15}); + env.client.send(req) + .then((res) => { + chai.fail(); + done(); + }) + .catch(recombee.errors.ResponseError,(err) => { + chai.equal(err.statusCode, 400); + done(); + }); + }); + + it ('fails with invalid portion', (done) => { + let req, req2, resp; + req = new rqs.SetViewPortion('entity_id','entity_id',-2); + env.client.send(req) + .then((res) => { + chai.fail(); + done(); + }) + .catch(recombee.errors.ResponseError,(err) => { + chai.equal(err.statusCode, 400); + done(); + }); + }); + + it ('fails with invalid sessionId', (done) => { + let req, req2, resp; + req = new rqs.SetViewPortion('entity_id','entity_id',0.7,{'sessionId': 'a****'}); + env.client.send(req) + .then((res) => { + chai.fail(); + done(); + }) + .catch(recombee.errors.ResponseError,(err) => { + chai.equal(err.statusCode, 400); + done(); + }); + }); +});