|
| 1 | +<?php |
| 2 | +/* |
| 3 | + This file is auto-generated, do not edit |
| 4 | +*/ |
| 5 | + |
| 6 | +/** |
| 7 | + * SetViewPortion request |
| 8 | + */ |
| 9 | +namespace Recombee\RecommApi\Requests; |
| 10 | +use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException; |
| 11 | + |
| 12 | +/** |
| 13 | + * The view portions feature is currently experimental. |
| 14 | + * Sets viewed portion of an item (for example a video or article) by a user (at a session). |
| 15 | + * If you send new request with the same (`userId`, `itemId`, `sessionId`), the portion gets updated. |
| 16 | + */ |
| 17 | +class SetViewPortion extends Request { |
| 18 | + |
| 19 | + /** |
| 20 | + * @var string $user_id User who viewed a portion of the item |
| 21 | + */ |
| 22 | + protected $user_id; |
| 23 | + /** |
| 24 | + * @var string $item_id Viewed item |
| 25 | + */ |
| 26 | + protected $item_id; |
| 27 | + /** |
| 28 | + * @var string $session_id Id of session in which the user viewed the item |
| 29 | + */ |
| 30 | + protected $session_id; |
| 31 | + /** |
| 32 | + * @var string|float $timestamp UTC timestamp of the rating as ISO8601-1 pattern or UTC epoch time. The default value is the current time. |
| 33 | + */ |
| 34 | + protected $timestamp; |
| 35 | + /** |
| 36 | + * @var float $portion Viewed portion of the item (number between 0.0 (viewed nothing) and 1.0 (viewed full item) ). |
| 37 | + */ |
| 38 | + protected $portion; |
| 39 | + /** |
| 40 | + * @var bool $cascade_create Sets whether the given user/item should be created if not present in the database. |
| 41 | + */ |
| 42 | + protected $cascade_create; |
| 43 | + /** |
| 44 | + * @var array Array containing values of optional parameters |
| 45 | + */ |
| 46 | + protected $optional; |
| 47 | + |
| 48 | + /** |
| 49 | + * Construct the request |
| 50 | + * @param string $user_id User who viewed a portion of the item |
| 51 | + * @param string $item_id Viewed item |
| 52 | + * @param float $portion Viewed portion of the item (number between 0.0 (viewed nothing) and 1.0 (viewed full item) ). |
| 53 | + * @param array $optional Optional parameters given as an array containing pairs name of the parameter => value |
| 54 | + * - Allowed parameters: |
| 55 | + * - *sessionId* |
| 56 | + * - Type: string |
| 57 | + * - Description: Id of session in which the user viewed the item |
| 58 | + * - *timestamp* |
| 59 | + * - Type: string|float |
| 60 | + * - Description: UTC timestamp of the rating as ISO8601-1 pattern or UTC epoch time. The default value is the current time. |
| 61 | + * - *cascadeCreate* |
| 62 | + * - Type: bool |
| 63 | + * - Description: Sets whether the given user/item should be created if not present in the database. |
| 64 | + * @throws Exceptions\UnknownOptionalParameterException UnknownOptionalParameterException if an unknown optional parameter is given in $optional |
| 65 | + */ |
| 66 | + public function __construct($user_id, $item_id, $portion, $optional = array()) { |
| 67 | + $this->user_id = $user_id; |
| 68 | + $this->item_id = $item_id; |
| 69 | + $this->portion = $portion; |
| 70 | + $this->session_id = isset($optional['sessionId']) ? $optional['sessionId'] : null; |
| 71 | + $this->timestamp = isset($optional['timestamp']) ? $optional['timestamp'] : null; |
| 72 | + $this->cascade_create = isset($optional['cascadeCreate']) ? $optional['cascadeCreate'] : null; |
| 73 | + $this->optional = $optional; |
| 74 | + |
| 75 | + $existing_optional = array('sessionId','timestamp','cascadeCreate'); |
| 76 | + foreach ($this->optional as $key => $value) { |
| 77 | + if (!in_array($key, $existing_optional)) |
| 78 | + throw new UnknownOptionalParameterException($key); |
| 79 | + } |
| 80 | + $this->timeout = 1000; |
| 81 | + $this->ensure_https = false; |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * Get used HTTP method |
| 86 | + * @return static Used HTTP method |
| 87 | + */ |
| 88 | + public function getMethod() { |
| 89 | + return Request::HTTP_POST; |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * Get URI to the endpoint |
| 94 | + * @return string URI to the endpoint |
| 95 | + */ |
| 96 | + public function getPath() { |
| 97 | + return "/{databaseId}/viewportions/"; |
| 98 | + } |
| 99 | + |
| 100 | + /** |
| 101 | + * Get query parameters |
| 102 | + * @return array Values of query parameters (name of parameter => value of the parameter) |
| 103 | + */ |
| 104 | + public function getQueryParameters() { |
| 105 | + $params = array(); |
| 106 | + return $params; |
| 107 | + } |
| 108 | + |
| 109 | + /** |
| 110 | + * Get body parameters |
| 111 | + * @return array Values of body parameters (name of parameter => value of the parameter) |
| 112 | + */ |
| 113 | + public function getBodyParameters() { |
| 114 | + $p = array(); |
| 115 | + $p['userId'] = $this->user_id; |
| 116 | + $p['itemId'] = $this->item_id; |
| 117 | + $p['portion'] = $this->portion; |
| 118 | + if (isset($this->optional['sessionId'])) |
| 119 | + $p['sessionId'] = $this-> optional['sessionId']; |
| 120 | + if (isset($this->optional['timestamp'])) |
| 121 | + $p['timestamp'] = $this-> optional['timestamp']; |
| 122 | + if (isset($this->optional['cascadeCreate'])) |
| 123 | + $p['cascadeCreate'] = $this-> optional['cascadeCreate']; |
| 124 | + return $p; |
| 125 | + } |
| 126 | + |
| 127 | +} |
| 128 | +?> |
0 commit comments