Skip to content

Commit e0ef79c

Browse files
committed
Added parameters amount,price,profit to AddPurchase and amount,price to AddCartAddition
1 parent e7c599b commit e0ef79c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1037
-116
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A Python client for easy use of the `Recombee <https://www.recombee.com/>`_ rec
66

77
If you don't have an account at Recombee yet, you can create a free account `here <https://www.recombee.com/>`_.
88

9-
Documentation of the API can be found at `docs.recombee.com <https://docs.recombee.com/)>`_.
9+
Documentation of the API can be found at `docs.recombee.com <https://docs.recombee.com/>`_.
1010

1111
=============
1212
Installation

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/1.5.0'}
66+
headers = {'User-Agent': 'recombee-python-api-client/1.6.0'}
6767
if additional_headers:
6868
headers.update(additional_headers)
6969
return headers

recombee_api_client/api_requests/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
from recombee_api_client.api_requests.delete_view_portion import DeleteViewPortion
5454
from recombee_api_client.api_requests.list_item_view_portions import ListItemViewPortions
5555
from recombee_api_client.api_requests.list_user_view_portions import ListUserViewPortions
56+
from recombee_api_client.api_requests.recommend_items_to_user import RecommendItemsToUser
57+
from recombee_api_client.api_requests.recommend_users_to_user import RecommendUsersToUser
58+
from recombee_api_client.api_requests.recommend_items_to_item import RecommendItemsToItem
59+
from recombee_api_client.api_requests.recommend_users_to_item import RecommendUsersToItem
5660
from recombee_api_client.api_requests.user_based_recommendation import UserBasedRecommendation
5761
from recombee_api_client.api_requests.item_based_recommendation import ItemBasedRecommendation
5862
from recombee_api_client.api_requests.reset_database import ResetDatabase

recombee_api_client/api_requests/add_cart_addition.py

Lines changed: 11 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):
12+
def __init__(self, user_id, item_id, timestamp=DEFAULT, cascade_create=DEFAULT, amount=DEFAULT, price=DEFAULT):
1313
"""
1414
Required parameters:
1515
@param user_id: User who added the item to the cart
@@ -22,11 +22,17 @@ 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 amount: Amount (number) added to cart. The default is 1. For example if `user-x` adds two `item-y` during a single order (session...), the `amount` should equal to 2.
26+
27+
@param price: Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
28+
2529
"""
2630
self.user_id = user_id
2731
self.item_id = item_id
2832
self.timestamp = timestamp
2933
self.cascade_create = cascade_create
34+
self.amount = amount
35+
self.price = price
3036
self.timeout = 1000
3137
self.ensure_https = False
3238
self.method = 'post'
@@ -43,6 +49,10 @@ def get_body_parameters(self):
4349
p['timestamp'] = self.timestamp
4450
if self.cascade_create is not DEFAULT:
4551
p['cascadeCreate'] = self.cascade_create
52+
if self.amount is not DEFAULT:
53+
p['amount'] = self.amount
54+
if self.price is not DEFAULT:
55+
p['price'] = self.price
4656
return p
4757

4858
def get_query_parameters(self):

recombee_api_client/api_requests/add_item_property.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(self, property_name, type):
2121
"""
2222
self.property_name = property_name
2323
self.type = type
24-
self.timeout = 1000
24+
self.timeout = 100000
2525
self.ensure_https = False
2626
self.method = 'put'
2727
self.path = "/items/properties/%s" % (self.property_name)

recombee_api_client/api_requests/add_purchase.py

Lines changed: 16 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):
12+
def __init__(self, user_id, item_id, timestamp=DEFAULT, cascade_create=DEFAULT, amount=DEFAULT, price=DEFAULT, profit=DEFAULT):
1313
"""
1414
Required parameters:
1515
@param user_id: User who purchased the item
@@ -22,11 +22,20 @@ 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 amount: Amount (number) of purchased items. The default is 1. For example if `user-x` purchases two `item-y` during a single order (session...), the `amount` should equal to 2.
26+
27+
@param price: Price paid by the user for the item. If `amount` is greater than 1, sum of prices of all the items should be given.
28+
29+
@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.
30+
2531
"""
2632
self.user_id = user_id
2733
self.item_id = item_id
2834
self.timestamp = timestamp
2935
self.cascade_create = cascade_create
36+
self.amount = amount
37+
self.price = price
38+
self.profit = profit
3039
self.timeout = 1000
3140
self.ensure_https = False
3241
self.method = 'post'
@@ -43,6 +52,12 @@ def get_body_parameters(self):
4352
p['timestamp'] = self.timestamp
4453
if self.cascade_create is not DEFAULT:
4554
p['cascadeCreate'] = self.cascade_create
55+
if self.amount is not DEFAULT:
56+
p['amount'] = self.amount
57+
if self.price is not DEFAULT:
58+
p['price'] = self.price
59+
if self.profit is not DEFAULT:
60+
p['profit'] = self.profit
4661
return p
4762

4863
def get_query_parameters(self):

recombee_api_client/api_requests/add_user_property.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(self, property_name, type):
2121
"""
2222
self.property_name = property_name
2323
self.type = type
24-
self.timeout = 1000
24+
self.timeout = 100000
2525
self.ensure_https = False
2626
self.method = 'put'
2727
self.path = "/users/properties/%s" % (self.property_name)

recombee_api_client/api_requests/delete_item_property.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, property_name):
1616
1717
"""
1818
self.property_name = property_name
19-
self.timeout = 1000
19+
self.timeout = 100000
2020
self.ensure_https = False
2121
self.method = 'delete'
2222
self.path = "/items/properties/%s" % (self.property_name)

recombee_api_client/api_requests/delete_user_property.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, property_name):
1616
1717
"""
1818
self.property_name = property_name
19-
self.timeout = 1000
19+
self.timeout = 100000
2020
self.ensure_https = False
2121
self.method = 'delete'
2222
self.path = "/users/properties/%s" % (self.property_name)

recombee_api_client/api_requests/get_user_property_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, property_name):
1616
1717
"""
1818
self.property_name = property_name
19-
self.timeout = 1000
19+
self.timeout = 100000
2020
self.ensure_https = False
2121
self.method = 'get'
2222
self.path = "/users/properties/%s" % (self.property_name)

0 commit comments

Comments
 (0)