|
| 1 | +<?php |
| 2 | +/* |
| 3 | + This file is auto-generated, do not edit |
| 4 | +*/ |
| 5 | + |
| 6 | +/** |
| 7 | + * AddSearchSynonym request |
| 8 | + */ |
| 9 | +namespace Recombee\RecommApi\Requests; |
| 10 | +use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException; |
| 11 | + |
| 12 | +/** |
| 13 | + * Adds a new synonym for the [Search items](https://docs.recombee.com/api.html#search-items). |
| 14 | + * When the `term` is used in the search query, the `synonym` is also used for the full-text search. |
| 15 | + * Unless `oneWay=true`, it works also in the opposite way (`synonym` -> `term`). |
| 16 | + * An example of a synonym can be `science fiction` for the term `sci-fi`. |
| 17 | + */ |
| 18 | +class AddSearchSynonym extends Request { |
| 19 | + |
| 20 | + /** |
| 21 | + * @var string $term A word to which the `synonym` is specified. |
| 22 | + */ |
| 23 | + protected $term; |
| 24 | + /** |
| 25 | + * @var string $synonym A word that should be considered equal to the `term` by the full-text search engine. |
| 26 | + */ |
| 27 | + protected $synonym; |
| 28 | + /** |
| 29 | + * @var bool $one_way If set to `true`, only `term` -> `synonym` is considered. If set to `false`, also `synonym` -> `term` works. |
| 30 | + * Default: `false`. |
| 31 | + */ |
| 32 | + protected $one_way; |
| 33 | + /** |
| 34 | + * @var array Array containing values of optional parameters |
| 35 | + */ |
| 36 | + protected $optional; |
| 37 | + |
| 38 | + /** |
| 39 | + * Construct the request |
| 40 | + * @param string $term A word to which the `synonym` is specified. |
| 41 | + * @param string $synonym A word that should be considered equal to the `term` by the full-text search engine. |
| 42 | + * @param array $optional Optional parameters given as an array containing pairs name of the parameter => value |
| 43 | + * - Allowed parameters: |
| 44 | + * - *oneWay* |
| 45 | + * - Type: bool |
| 46 | + * - Description: If set to `true`, only `term` -> `synonym` is considered. If set to `false`, also `synonym` -> `term` works. |
| 47 | + * Default: `false`. |
| 48 | + * @throws Exceptions\UnknownOptionalParameterException UnknownOptionalParameterException if an unknown optional parameter is given in $optional |
| 49 | + */ |
| 50 | + public function __construct($term, $synonym, $optional = array()) { |
| 51 | + $this->term = $term; |
| 52 | + $this->synonym = $synonym; |
| 53 | + $this->one_way = isset($optional['oneWay']) ? $optional['oneWay'] : null; |
| 54 | + $this->optional = $optional; |
| 55 | + |
| 56 | + $existing_optional = array('oneWay'); |
| 57 | + foreach ($this->optional as $key => $value) { |
| 58 | + if (!in_array($key, $existing_optional)) |
| 59 | + throw new UnknownOptionalParameterException($key); |
| 60 | + } |
| 61 | + $this->timeout = 10000; |
| 62 | + $this->ensure_https = false; |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * Get used HTTP method |
| 67 | + * @return static Used HTTP method |
| 68 | + */ |
| 69 | + public function getMethod() { |
| 70 | + return Request::HTTP_POST; |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Get URI to the endpoint |
| 75 | + * @return string URI to the endpoint |
| 76 | + */ |
| 77 | + public function getPath() { |
| 78 | + return "/{databaseId}/synonyms/items/"; |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * Get query parameters |
| 83 | + * @return array Values of query parameters (name of parameter => value of the parameter) |
| 84 | + */ |
| 85 | + public function getQueryParameters() { |
| 86 | + $params = array(); |
| 87 | + return $params; |
| 88 | + } |
| 89 | + |
| 90 | + /** |
| 91 | + * Get body parameters |
| 92 | + * @return array Values of body parameters (name of parameter => value of the parameter) |
| 93 | + */ |
| 94 | + public function getBodyParameters() { |
| 95 | + $p = array(); |
| 96 | + $p['term'] = $this->term; |
| 97 | + $p['synonym'] = $this->synonym; |
| 98 | + if (isset($this->optional['oneWay'])) |
| 99 | + $p['oneWay'] = $this-> optional['oneWay']; |
| 100 | + return $p; |
| 101 | + } |
| 102 | + |
| 103 | +} |
| 104 | +?> |
0 commit comments