|
| 1 | +from recombee_api_client.api_requests.request import Request |
| 2 | +import uuid |
| 3 | + |
| 4 | +DEFAULT = uuid.uuid4() |
| 5 | + |
| 6 | +class SetViewPortion(Request): |
| 7 | + """ |
| 8 | + The view portions feature is currently experimental. |
| 9 | + |
| 10 | + Sets viewed portion of an item (for example a video or article) by a user (at a session). |
| 11 | + If you send new request with the same (`userId`, `itemId`, `sessionId`), the portion gets updated. |
| 12 | +
|
| 13 | + """ |
| 14 | + |
| 15 | + def __init__(self, user_id, item_id, portion, session_id=DEFAULT, timestamp=DEFAULT, cascade_create=DEFAULT): |
| 16 | + """ |
| 17 | + Required parameters: |
| 18 | + @param user_id: User who viewed a portion of the item |
| 19 | + |
| 20 | + @param item_id: Viewed item |
| 21 | + |
| 22 | + @param portion: Viewed portion of the item (number between 0.0 (viewed nothing) and 1.0 (viewed full item) ). |
| 23 | + |
| 24 | + |
| 25 | + Optional parameters: |
| 26 | + @param session_id: Id of session in which the user viewed the item |
| 27 | + |
| 28 | + @param timestamp: UTC timestamp of the rating as ISO8601-1 pattern or UTC epoch time. The default value is the current time. |
| 29 | + |
| 30 | + @param cascade_create: Sets whether the given user/item should be created if not present in the database. |
| 31 | + |
| 32 | + """ |
| 33 | + self.user_id = user_id |
| 34 | + self.item_id = item_id |
| 35 | + self.portion = portion |
| 36 | + self.session_id = session_id |
| 37 | + self.timestamp = timestamp |
| 38 | + self.cascade_create = cascade_create |
| 39 | + self.timeout = 1000 |
| 40 | + self.ensure_https = False |
| 41 | + self.method = 'post' |
| 42 | + self.path = "/viewportions/" % () |
| 43 | + |
| 44 | + def get_body_parameters(self): |
| 45 | + """ |
| 46 | + Values of body parameters as a dictionary (name of parameter: value of the parameter). |
| 47 | + """ |
| 48 | + p = dict() |
| 49 | + p['userId'] = self.user_id |
| 50 | + p['itemId'] = self.item_id |
| 51 | + p['portion'] = self.portion |
| 52 | + if self.session_id is not DEFAULT: |
| 53 | + p['sessionId'] = self.session_id |
| 54 | + if self.timestamp is not DEFAULT: |
| 55 | + p['timestamp'] = self.timestamp |
| 56 | + if self.cascade_create is not DEFAULT: |
| 57 | + p['cascadeCreate'] = self.cascade_create |
| 58 | + return p |
| 59 | + |
| 60 | + def get_query_parameters(self): |
| 61 | + """ |
| 62 | + Values of query parameters as a dictionary (name of parameter: value of the parameter). |
| 63 | + """ |
| 64 | + params = dict() |
| 65 | + return params |
0 commit comments