Skip to content

Commit 96c4baf

Browse files
committed
Add recommId parameter to add interaction requests
1 parent 60dfb42 commit 96c4baf

20 files changed

+97
-25
lines changed

recombee_api_client/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def send(self, request):
6363

6464
@staticmethod
6565
def __get_http_headers(additional_headers=None):
66-
headers = {'User-Agent': 'recombee-python-api-client/2.1.0'}
66+
headers = {'User-Agent': 'recombee-python-api-client/2.2.0'}
6767
if additional_headers:
6868
headers.update(additional_headers)
6969
return headers

recombee_api_client/api_requests/add_bookmark.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class AddBookmark(Request):
99
1010
"""
1111

12-
def __init__(self, user_id, item_id, timestamp=DEFAULT, cascade_create=DEFAULT):
12+
def __init__(self, user_id, item_id, timestamp=DEFAULT, cascade_create=DEFAULT, recomm_id=DEFAULT):
1313
"""
1414
Required parameters:
1515
@param user_id: User who bookmarked the item
@@ -22,11 +22,14 @@ def __init__(self, user_id, item_id, timestamp=DEFAULT, cascade_create=DEFAULT):
2222
2323
@param cascade_create: Sets whether the given user/item should be created if not present in the database.
2424
25+
@param recomm_id: If this bookmark is based on a recommendation request, `recommId` is the id of the clicked recommendation.
26+
2527
"""
2628
self.user_id = user_id
2729
self.item_id = item_id
2830
self.timestamp = timestamp
2931
self.cascade_create = cascade_create
32+
self.recomm_id = recomm_id
3033
self.timeout = 1000
3134
self.ensure_https = False
3235
self.method = 'post'
@@ -43,6 +46,8 @@ def get_body_parameters(self):
4346
p['timestamp'] = self.timestamp
4447
if self.cascade_create is not DEFAULT:
4548
p['cascadeCreate'] = self.cascade_create
49+
if self.recomm_id is not DEFAULT:
50+
p['recommId'] = self.recomm_id
4651
return p
4752

4853
def get_query_parameters(self):

recombee_api_client/api_requests/add_cart_addition.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class AddCartAddition(Request):
99
1010
"""
1111

12-
def __init__(self, user_id, item_id, timestamp=DEFAULT, cascade_create=DEFAULT, amount=DEFAULT, price=DEFAULT):
12+
def __init__(self, user_id, item_id, timestamp=DEFAULT, cascade_create=DEFAULT, amount=DEFAULT, price=DEFAULT, recomm_id=DEFAULT):
1313
"""
1414
Required parameters:
1515
@param user_id: User who added the item to the cart
@@ -26,13 +26,16 @@ def __init__(self, user_id, item_id, timestamp=DEFAULT, cascade_create=DEFAULT,
2626
2727
@param price: Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
2828
29+
@param recomm_id: If this cart addition is based on a recommendation request, `recommId` is the id of the clicked recommendation.
30+
2931
"""
3032
self.user_id = user_id
3133
self.item_id = item_id
3234
self.timestamp = timestamp
3335
self.cascade_create = cascade_create
3436
self.amount = amount
3537
self.price = price
38+
self.recomm_id = recomm_id
3639
self.timeout = 1000
3740
self.ensure_https = False
3841
self.method = 'post'
@@ -53,6 +56,8 @@ def get_body_parameters(self):
5356
p['amount'] = self.amount
5457
if self.price is not DEFAULT:
5558
p['price'] = self.price
59+
if self.recomm_id is not DEFAULT:
60+
p['recommId'] = self.recomm_id
5661
return p
5762

5863
def get_query_parameters(self):

recombee_api_client/api_requests/add_detail_view.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class AddDetailView(Request):
99
1010
"""
1111

12-
def __init__(self, user_id, item_id, timestamp=DEFAULT, duration=DEFAULT, cascade_create=DEFAULT):
12+
def __init__(self, user_id, item_id, timestamp=DEFAULT, duration=DEFAULT, cascade_create=DEFAULT, recomm_id=DEFAULT):
1313
"""
1414
Required parameters:
1515
@param user_id: User who viewed the item
@@ -24,12 +24,15 @@ def __init__(self, user_id, item_id, timestamp=DEFAULT, duration=DEFAULT, cascad
2424
2525
@param cascade_create: Sets whether the given user/item should be created if not present in the database.
2626
27+
@param recomm_id: If this detail view is based on a recommendation request, `recommId` is the id of the clicked recommendation.
28+
2729
"""
2830
self.user_id = user_id
2931
self.item_id = item_id
3032
self.timestamp = timestamp
3133
self.duration = duration
3234
self.cascade_create = cascade_create
35+
self.recomm_id = recomm_id
3336
self.timeout = 1000
3437
self.ensure_https = False
3538
self.method = 'post'
@@ -48,6 +51,8 @@ def get_body_parameters(self):
4851
p['duration'] = self.duration
4952
if self.cascade_create is not DEFAULT:
5053
p['cascadeCreate'] = self.cascade_create
54+
if self.recomm_id is not DEFAULT:
55+
p['recommId'] = self.recomm_id
5156
return p
5257

5358
def get_query_parameters(self):

recombee_api_client/api_requests/add_item_property.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,30 @@ def __init__(self, property_name, type):
1818
@param type: Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.
1919
2020
21+
* `int`- Signed integer number.
22+
23+
24+
* `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
25+
26+
27+
* `string` - UTF-8 string.
28+
29+
30+
* `boolean` - *true* / *false*
31+
32+
33+
* `timestamp` - Value representing date and time.
34+
35+
36+
* `set` - Set of strings.
37+
38+
39+
* `image` - URL of an image (`jpeg`, `png` or `gif`).
40+
41+
42+
* `imageList` - List of URLs that refer to images.
43+
44+
2145
"""
2246
self.property_name = property_name
2347
self.type = type

recombee_api_client/api_requests/add_purchase.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class AddPurchase(Request):
99
1010
"""
1111

12-
def __init__(self, user_id, item_id, timestamp=DEFAULT, cascade_create=DEFAULT, amount=DEFAULT, price=DEFAULT, profit=DEFAULT):
12+
def __init__(self, user_id, item_id, timestamp=DEFAULT, cascade_create=DEFAULT, amount=DEFAULT, price=DEFAULT, profit=DEFAULT, recomm_id=DEFAULT):
1313
"""
1414
Required parameters:
1515
@param user_id: User who purchased the item
@@ -28,6 +28,8 @@ def __init__(self, user_id, item_id, timestamp=DEFAULT, cascade_create=DEFAULT,
2828
2929
@param profit: 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.
3030
31+
@param recomm_id: If this purchase is based on a recommendation request, `recommId` is the id of the clicked recommendation.
32+
3133
"""
3234
self.user_id = user_id
3335
self.item_id = item_id
@@ -36,6 +38,7 @@ def __init__(self, user_id, item_id, timestamp=DEFAULT, cascade_create=DEFAULT,
3638
self.amount = amount
3739
self.price = price
3840
self.profit = profit
41+
self.recomm_id = recomm_id
3942
self.timeout = 1000
4043
self.ensure_https = False
4144
self.method = 'post'
@@ -58,6 +61,8 @@ def get_body_parameters(self):
5861
p['price'] = self.price
5962
if self.profit is not DEFAULT:
6063
p['profit'] = self.profit
64+
if self.recomm_id is not DEFAULT:
65+
p['recommId'] = self.recomm_id
6166
return p
6267

6368
def get_query_parameters(self):

recombee_api_client/api_requests/add_rating.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class AddRating(Request):
99
1010
"""
1111

12-
def __init__(self, user_id, item_id, rating, timestamp=DEFAULT, cascade_create=DEFAULT):
12+
def __init__(self, user_id, item_id, rating, timestamp=DEFAULT, cascade_create=DEFAULT, recomm_id=DEFAULT):
1313
"""
1414
Required parameters:
1515
@param user_id: User who submitted the rating
@@ -24,12 +24,15 @@ def __init__(self, user_id, item_id, rating, timestamp=DEFAULT, cascade_create=D
2424
2525
@param cascade_create: Sets whether the given user/item should be created if not present in the database.
2626
27+
@param recomm_id: If this rating is based on a recommendation request, `recommId` is the id of the clicked recommendation.
28+
2729
"""
2830
self.user_id = user_id
2931
self.item_id = item_id
3032
self.rating = rating
3133
self.timestamp = timestamp
3234
self.cascade_create = cascade_create
35+
self.recomm_id = recomm_id
3336
self.timeout = 1000
3437
self.ensure_https = False
3538
self.method = 'post'
@@ -47,6 +50,8 @@ def get_body_parameters(self):
4750
p['timestamp'] = self.timestamp
4851
if self.cascade_create is not DEFAULT:
4952
p['cascadeCreate'] = self.cascade_create
53+
if self.recomm_id is not DEFAULT:
54+
p['recommId'] = self.recomm_id
5055
return p
5156

5257
def get_query_parameters(self):

recombee_api_client/api_requests/add_user_property.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,25 @@ def __init__(self, property_name, type):
1515
@param property_name: 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.
1616
1717
18-
@param type: Value type of the user property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`
18+
@param type: Value type of the user property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`.
19+
20+
21+
* `int` - Signed integer number.
22+
23+
24+
* `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
25+
26+
27+
* `string` - UTF-8 string.
28+
29+
30+
* `boolean` - *true* / *false*
31+
32+
33+
* `timestamp` - Value representing date and time.
34+
35+
36+
* `set` - Set of strings.
1937
2038
2139
"""

recombee_api_client/api_requests/merge_users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class MergeUsers(Request):
88
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.
99
1010
11-
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** unless special parameter `keepSourceUser` is set `true`.
11+
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**.
1212
1313
"""
1414

recombee_api_client/api_requests/set_view_portion.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class SetViewPortion(Request):
1010
1111
"""
1212

13-
def __init__(self, user_id, item_id, portion, session_id=DEFAULT, timestamp=DEFAULT, cascade_create=DEFAULT):
13+
def __init__(self, user_id, item_id, portion, session_id=DEFAULT, timestamp=DEFAULT, cascade_create=DEFAULT, recomm_id=DEFAULT):
1414
"""
1515
Required parameters:
1616
@param user_id: User who viewed a portion of the item
@@ -27,13 +27,16 @@ def __init__(self, user_id, item_id, portion, session_id=DEFAULT, timestamp=DEFA
2727
2828
@param cascade_create: Sets whether the given user/item should be created if not present in the database.
2929
30+
@param recomm_id: If this view portion is based on a recommendation request, `recommId` is the id of the clicked recommendation.
31+
3032
"""
3133
self.user_id = user_id
3234
self.item_id = item_id
3335
self.portion = portion
3436
self.session_id = session_id
3537
self.timestamp = timestamp
3638
self.cascade_create = cascade_create
39+
self.recomm_id = recomm_id
3740
self.timeout = 1000
3841
self.ensure_https = False
3942
self.method = 'post'
@@ -53,6 +56,8 @@ def get_body_parameters(self):
5356
p['timestamp'] = self.timestamp
5457
if self.cascade_create is not DEFAULT:
5558
p['cascadeCreate'] = self.cascade_create
59+
if self.recomm_id is not DEFAULT:
60+
p['recommId'] = self.recomm_id
5661
return p
5762

5863
def get_query_parameters(self):

0 commit comments

Comments
 (0)