|
| 1 | +<?php |
| 2 | +/* |
| 3 | + This file is auto-generated, do not edit |
| 4 | +*/ |
| 5 | + |
| 6 | +/** |
| 7 | + * AddManualReqlSegment request |
| 8 | + */ |
| 9 | +namespace Recombee\RecommApi\Requests; |
| 10 | +use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException; |
| 11 | + |
| 12 | +/** |
| 13 | + * Adds a new Segment into a Manual ReQL Segmentation. |
| 14 | + * 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. |
| 15 | + */ |
| 16 | +class AddManualReqlSegment extends Request { |
| 17 | + |
| 18 | + /** |
| 19 | + * @var string $segmentation_id ID of the Segmentation to which the new Segment should be added |
| 20 | + */ |
| 21 | + protected $segmentation_id; |
| 22 | + /** |
| 23 | + * @var string $segment_id ID of the newly created Segment |
| 24 | + */ |
| 25 | + protected $segment_id; |
| 26 | + /** |
| 27 | + * @var string $filter ReQL filter that returns `true` for items that belong to this Segment. Otherwise returns `false`. |
| 28 | + */ |
| 29 | + protected $filter; |
| 30 | + /** |
| 31 | + * @var string $title Human-readable name of the Segment that is shown in the Recombee Admin UI. |
| 32 | + */ |
| 33 | + protected $title; |
| 34 | + /** |
| 35 | + * @var array Array containing values of optional parameters |
| 36 | + */ |
| 37 | + protected $optional; |
| 38 | + |
| 39 | + /** |
| 40 | + * Construct the request |
| 41 | + * @param string $segmentation_id ID of the Segmentation to which the new Segment should be added |
| 42 | + * @param string $segment_id ID of the newly created Segment |
| 43 | + * @param string $filter ReQL filter that returns `true` for items that belong to this Segment. Otherwise returns `false`. |
| 44 | + * @param array $optional Optional parameters given as an array containing pairs name of the parameter => value |
| 45 | + * - Allowed parameters: |
| 46 | + * - *title* |
| 47 | + * - Type: string |
| 48 | + * - Description: Human-readable name of the Segment that is shown in the Recombee Admin UI. |
| 49 | + * @throws Exceptions\UnknownOptionalParameterException UnknownOptionalParameterException if an unknown optional parameter is given in $optional |
| 50 | + */ |
| 51 | + public function __construct($segmentation_id, $segment_id, $filter, $optional = array()) { |
| 52 | + $this->segmentation_id = $segmentation_id; |
| 53 | + $this->segment_id = $segment_id; |
| 54 | + $this->filter = $filter; |
| 55 | + $this->title = isset($optional['title']) ? $optional['title'] : null; |
| 56 | + $this->optional = $optional; |
| 57 | + |
| 58 | + $existing_optional = array('title'); |
| 59 | + foreach ($this->optional as $key => $value) { |
| 60 | + if (!in_array($key, $existing_optional)) |
| 61 | + throw new UnknownOptionalParameterException($key); |
| 62 | + } |
| 63 | + $this->timeout = 10000; |
| 64 | + $this->ensure_https = false; |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * Get used HTTP method |
| 69 | + * @return static Used HTTP method |
| 70 | + */ |
| 71 | + public function getMethod() { |
| 72 | + return Request::HTTP_PUT; |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Get URI to the endpoint |
| 77 | + * @return string URI to the endpoint |
| 78 | + */ |
| 79 | + public function getPath() { |
| 80 | + return "/{databaseId}/segmentations/manual-reql/{$this->segmentation_id}/segments/{$this->segment_id}"; |
| 81 | + } |
| 82 | + |
| 83 | + /** |
| 84 | + * Get query parameters |
| 85 | + * @return array Values of query parameters (name of parameter => value of the parameter) |
| 86 | + */ |
| 87 | + public function getQueryParameters() { |
| 88 | + $params = array(); |
| 89 | + return $params; |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * Get body parameters |
| 94 | + * @return array Values of body parameters (name of parameter => value of the parameter) |
| 95 | + */ |
| 96 | + public function getBodyParameters() { |
| 97 | + $p = array(); |
| 98 | + $p['filter'] = $this->filter; |
| 99 | + if (isset($this->optional['title'])) |
| 100 | + $p['title'] = $this-> optional['title']; |
| 101 | + return $p; |
| 102 | + } |
| 103 | + |
| 104 | +} |
0 commit comments