Skip to content

Commit c7ab39b

Browse files
committed
Support Item Segmentations
1 parent 8f0829d commit c7ab39b

File tree

112 files changed

+1967
-215
lines changed

Some content is hidden

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

112 files changed

+1967
-215
lines changed

recombee_api_client/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def __get_base_uri(options: dict, region: str) -> str:
9494

9595
@staticmethod
9696
def __get_http_headers(additional_headers: dict = None) -> dict:
97-
headers = {'User-Agent': 'recombee-python-api-client/4.0.0'}
97+
headers = {'User-Agent': 'recombee-python-api-client/4.1.0'}
9898
if additional_headers:
9999
headers.update(additional_headers)
100100
return headers

recombee_api_client/api_requests/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,27 @@
6060
from recombee_api_client.api_requests.recommend_next_items import RecommendNextItems
6161
from recombee_api_client.api_requests.recommend_users_to_user import RecommendUsersToUser
6262
from recombee_api_client.api_requests.recommend_users_to_item import RecommendUsersToItem
63+
from recombee_api_client.api_requests.recommend_item_segments_to_user import RecommendItemSegmentsToUser
64+
from recombee_api_client.api_requests.recommend_item_segments_to_item import RecommendItemSegmentsToItem
65+
from recombee_api_client.api_requests.recommend_item_segments_to_item_segment import RecommendItemSegmentsToItemSegment
6366
from recombee_api_client.api_requests.search_items import SearchItems
67+
from recombee_api_client.api_requests.search_item_segments import SearchItemSegments
6468
from recombee_api_client.api_requests.add_search_synonym import AddSearchSynonym
6569
from recombee_api_client.api_requests.list_search_synonyms import ListSearchSynonyms
6670
from recombee_api_client.api_requests.delete_all_search_synonyms import DeleteAllSearchSynonyms
6771
from recombee_api_client.api_requests.delete_search_synonym import DeleteSearchSynonym
72+
from recombee_api_client.api_requests.create_property_based_segmentation import CreatePropertyBasedSegmentation
73+
from recombee_api_client.api_requests.update_property_based_segmentation import UpdatePropertyBasedSegmentation
74+
from recombee_api_client.api_requests.create_auto_reql_segmentation import CreateAutoReqlSegmentation
75+
from recombee_api_client.api_requests.update_auto_reql_segmentation import UpdateAutoReqlSegmentation
76+
from recombee_api_client.api_requests.create_manual_reql_segmentation import CreateManualReqlSegmentation
77+
from recombee_api_client.api_requests.update_manual_reql_segmentation import UpdateManualReqlSegmentation
78+
from recombee_api_client.api_requests.add_manual_reql_segment import AddManualReqlSegment
79+
from recombee_api_client.api_requests.update_manual_reql_segment import UpdateManualReqlSegment
80+
from recombee_api_client.api_requests.delete_manual_reql_segment import DeleteManualReqlSegment
81+
from recombee_api_client.api_requests.list_segmentations import ListSegmentations
82+
from recombee_api_client.api_requests.get_segmentation import GetSegmentation
83+
from recombee_api_client.api_requests.delete_segmentation import DeleteSegmentation
6884
from recombee_api_client.api_requests.reset_database import ResetDatabase
6985
from recombee_api_client.api_requests.batch import Batch
7086
from recombee_api_client.api_requests.request import Request

recombee_api_client/api_requests/add_bookmark.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class AddBookmark(Request):
88
"""
9-
Adds a bookmark of a given item made by a given user.
9+
Adds a bookmark of the given item made by the given user.
1010
1111
Required parameters:
1212
@@ -29,7 +29,7 @@ class AddBookmark(Request):
2929
"""
3030

3131
def __init__(self, user_id: str, item_id: str, timestamp: Union[str, int] = DEFAULT, cascade_create: bool = DEFAULT, recomm_id: str = DEFAULT, additional_data: dict = DEFAULT):
32-
super().__init__(path="/bookmarks/" % (), method='post', timeout=1000, ensure_https=False)
32+
super().__init__(path="/bookmarks/", method='post', timeout=1000, ensure_https=False)
3333
self.user_id = user_id
3434
self.item_id = item_id
3535
self.timestamp = timestamp

recombee_api_client/api_requests/add_cart_addition.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class AddCartAddition(Request):
88
"""
9-
Adds a cart addition of a given item made by a given user.
9+
Adds a cart addition of the given item made by the given user.
1010
1111
Required parameters:
1212
@@ -21,9 +21,9 @@ class AddCartAddition(Request):
2121
2222
:param cascade_create: Sets whether the given user/item should be created if not present in the database.
2323
24-
: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.
24+
: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 2.
2525
26-
:param price: Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
26+
:param price: Price of the added item. If `amount` is greater than 1, the sum of prices of all the items should be given.
2727
2828
:param recomm_id: If this cart addition is based on a recommendation request, `recommId` is the id of the clicked recommendation.
2929
@@ -33,7 +33,7 @@ class AddCartAddition(Request):
3333
"""
3434

3535
def __init__(self, user_id: str, item_id: str, timestamp: Union[str, int] = DEFAULT, cascade_create: bool = DEFAULT, amount: float = DEFAULT, price: float = DEFAULT, recomm_id: str = DEFAULT, additional_data: dict = DEFAULT):
36-
super().__init__(path="/cartadditions/" % (), method='post', timeout=1000, ensure_https=False)
36+
super().__init__(path="/cartadditions/", method='post', timeout=1000, ensure_https=False)
3737
self.user_id = user_id
3838
self.item_id = item_id
3939
self.timestamp = timestamp

recombee_api_client/api_requests/add_detail_view.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class AddDetailView(Request):
88
"""
9-
Adds a detail view of a given item made by a given user.
9+
Adds a detail view of the given item made by the given user.
1010
1111
Required parameters:
1212
@@ -31,7 +31,7 @@ class AddDetailView(Request):
3131
"""
3232

3333
def __init__(self, user_id: str, item_id: str, timestamp: Union[str, int] = DEFAULT, duration: int = DEFAULT, cascade_create: bool = DEFAULT, recomm_id: str = DEFAULT, additional_data: dict = DEFAULT):
34-
super().__init__(path="/detailviews/" % (), method='post', timeout=1000, ensure_https=False)
34+
super().__init__(path="/detailviews/", method='post', timeout=1000, ensure_https=False)
3535
self.user_id = user_id
3636
self.item_id = item_id
3737
self.timestamp = timestamp

recombee_api_client/api_requests/add_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class AddGroup(Request):
88
"""
9-
Creates new group in the database.
9+
Creates a new group in the database.
1010
Required parameters:
1111
1212
:param group_id: ID of the group to be created.

recombee_api_client/api_requests/add_item.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
class AddItem(Request):
88
"""
9-
Adds new item of given `itemId` to the items catalog.
9+
Adds new item of the given `itemId` to the items catalog.
1010
11-
All the item properties for the newly created items are set null.
11+
All the item properties for the newly created items are set to null.
1212
1313
Required parameters:
1414

recombee_api_client/api_requests/add_item_property.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class AddItemProperty(Request):
1010
1111
Required parameters:
1212
13-
:param property_name: Name of the item property to be created. Currently, the following names are reserved:`id`, `itemid`, case insensitively. Also, the length of the property name must not exceed 63 characters.
13+
:param property_name: Name of the item property to be created. Currently, the following names are reserved: `id`, `itemid`, case-insensitively. Also, the length of the property name must not exceed 63 characters.
1414
1515
1616
:param type: Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from recombee_api_client.api_requests.request import Request
2+
from typing import Union, List
3+
import uuid
4+
5+
DEFAULT = uuid.uuid4()
6+
7+
class AddManualReqlSegment(Request):
8+
"""
9+
Adds a new Segment into a Manual ReQL Segmentation.
10+
11+
The new Segment is defined by a [ReQL](https://docs.recombee.com/reql.html) filter that returns `true` for an item in case that this item belongs to the segment.
12+
13+
Required parameters:
14+
15+
:param segmentation_id: ID of the Segmentation to which the new Segment should be added
16+
17+
:param segment_id: ID of the newly created Segment
18+
19+
:param filter: ReQL filter that returns `true` for items that belong to this Segment. Otherwise returns `false`.
20+
21+
22+
23+
Optional parameters:
24+
25+
:param title: Human-readable name of the Segment that is shown in the Recombee Admin UI.
26+
27+
28+
29+
"""
30+
31+
def __init__(self, segmentation_id: str, segment_id: str, filter: str, title: str = DEFAULT):
32+
super().__init__(path="/segmentations/manual-reql/%s/segments/%s" % (segmentation_id,segment_id), method='put', timeout=10000, ensure_https=False)
33+
self.segmentation_id = segmentation_id
34+
self.segment_id = segment_id
35+
self.filter = filter
36+
self.title = title
37+
38+
def get_body_parameters(self) -> dict:
39+
"""
40+
Values of body parameters as a dictionary (name of parameter: value of the parameter).
41+
"""
42+
p = dict()
43+
p['filter'] = self.filter
44+
if self.title is not DEFAULT:
45+
p['title'] = self.title
46+
return p
47+
48+
def get_query_parameters(self) -> dict:
49+
"""
50+
Values of query parameters as a dictionary (name of parameter: value of the parameter).
51+
"""
52+
params = dict()
53+
return params

recombee_api_client/api_requests/add_purchase.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class AddPurchase(Request):
88
"""
9-
Adds a purchase of a given item made by a given user.
9+
Adds a purchase of the given item made by the given user.
1010
1111
Required parameters:
1212
@@ -21,11 +21,11 @@ class AddPurchase(Request):
2121
2222
:param cascade_create: Sets whether the given user/item should be created if not present in the database.
2323
24-
: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.
24+
: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 2.
2525
26-
: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.
26+
:param price: Price paid by the user for the item. If `amount` is greater than 1, the sum of prices of all the items should be given.
2727
28-
: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.
28+
:param profit: Your profit from the purchased item. The profit is natural in the 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 also applicable in other domains (for example, at a news company it may be income from a displayed advertisement on article page). If `amount` is greater than 1, the sum of profit of all the items should be given.
2929
3030
:param recomm_id: If this purchase is based on a recommendation request, `recommId` is the id of the clicked recommendation.
3131
@@ -35,7 +35,7 @@ class AddPurchase(Request):
3535
"""
3636

3737
def __init__(self, user_id: str, item_id: str, timestamp: Union[str, int] = DEFAULT, cascade_create: bool = DEFAULT, amount: float = DEFAULT, price: float = DEFAULT, profit: float = DEFAULT, recomm_id: str = DEFAULT, additional_data: dict = DEFAULT):
38-
super().__init__(path="/purchases/" % (), method='post', timeout=1000, ensure_https=False)
38+
super().__init__(path="/purchases/", method='post', timeout=1000, ensure_https=False)
3939
self.user_id = user_id
4040
self.item_id = item_id
4141
self.timestamp = timestamp

0 commit comments

Comments
 (0)