Skip to content

Commit a1cf652

Browse files
committed
MergeUsers (allowed for a db on request)
1 parent 791e8ae commit a1cf652

10 files changed

+144
-21
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The library is [UMD](https://github.com/umdjs/umd) compatible.
1515
You can download [recombee-api-client.min.js](./dist/recombee-api-client.min.js) and host it at your site, or use a CDN such as [jsDelivr](https://www.jsdelivr.com/) CDN:
1616

1717
```js
18-
<script src="https://cdn.jsdelivr.net/gh/recombee/[email protected].0/dist/recombee-api-client.min.js"></script>
18+
<script src="https://cdn.jsdelivr.net/gh/recombee/[email protected].1/dist/recombee-api-client.min.js"></script>
1919
```
2020

2121
### npm
@@ -147,7 +147,7 @@ Let's assume we want to show recommendations at product page of pants `product-2
147147
</div>
148148
</div>
149149

150-
<script src="https://cdn.jsdelivr.net/gh/recombee/[email protected].0/dist/recombee-api-client.min.js"></script>
150+
<script src="https://cdn.jsdelivr.net/gh/recombee/[email protected].1/dist/recombee-api-client.min.js"></script>
151151

152152
<script type="text/javascript">
153153

dist/recombee-api-client.js

Lines changed: 90 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/recombee-api-client.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/recombee-api-client.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/recombee-api-client.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "recombee-js-api-client",
3-
"version": "2.2.0",
3+
"version": "2.2.1",
44
"description": "Client-side js library for easy use of the Recombee recommendation API",
55
"browser": "./src/index.js",
66
"repository": {

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ exports.ApiClient = require("./api-client").ApiClient;
77
exports.ApiError = require("./errors/api-error").ApiError;
88
exports.ResponseError = require("./errors/response-error").ResponseError;
99
exports.TimeoutError = require("./errors/timeout-error").TimeoutError;
10+
exports.MergeUsers = require("./requests/merge-users").MergeUsers;
1011
exports.AddDetailView = require("./requests/add-detail-view").AddDetailView;
1112
exports.AddPurchase = require("./requests/add-purchase").AddPurchase;
1213
exports.AddRating = require("./requests/add-rating").AddRating;

src/requests/merge-users.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
This file is auto-generated, do not edit
3+
*/
4+
5+
'use strict';
6+
const rqs = require("./request");
7+
8+
/**
9+
* 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.
10+
* 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**.
11+
*/
12+
class MergeUsers extends rqs.Request {
13+
14+
/**
15+
* Construct the request
16+
* @param {string} targetUserId - ID of the targer user.
17+
* @param {string} sourceUserId - ID of the source user.
18+
* @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value
19+
* - Allowed parameters:
20+
* - *cascadeCreate*
21+
* - Type: boolean
22+
* - Description: Sets whether the user *targetUserId* should be created if not present in the database.
23+
*/
24+
constructor(targetUserId, sourceUserId, optional) {
25+
super('PUT', `/users/${encodeURIComponent(targetUserId)}/merge/${encodeURIComponent(sourceUserId)}`, 30000, false);
26+
this.targetUserId = targetUserId;
27+
this.sourceUserId = sourceUserId;
28+
optional = optional || {};
29+
this.cascadeCreate = optional.cascadeCreate;
30+
}
31+
32+
/**
33+
* Get body parameters
34+
* @return {Object} The values of body parameters (name of parameter: value of the parameter)
35+
*/
36+
bodyParameters() {
37+
let params = {};
38+
39+
params.cascadeCreate = (this.cascadeCreate !== undefined) ? this.cascadeCreate : true;
40+
return params;
41+
}
42+
43+
}
44+
45+
exports.MergeUsers = MergeUsers

src/requests/recommend-items-to-item.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const rqs = require("./request");
88
/**
99
* 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.
1010
* It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
11+
* The returned items are sorted by relevancy (first item being the most relevant).
1112
*/
1213
class RecommendItemsToItem extends rqs.Request {
1314

src/requests/recommend-items-to-user.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const rqs = require("./request");
88
/**
99
* 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.
1010
* It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
11+
* The returned items are sorted by relevancy (first item being the most relevant).
1112
*/
1213
class RecommendItemsToUser extends rqs.Request {
1314

0 commit comments

Comments
 (0)