PostApiV3SearchRequest.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002
  1. <?php
  2. /**
  3. * PostApiV3SearchRequest
  4. *
  5. * PHP version 8.1
  6. *
  7. * @category Class
  8. * @package WikipaliApi
  9. * @author OpenAPI Generator team
  10. * @link https://openapi-generator.tech
  11. */
  12. /**
  13. * MINT API
  14. *
  15. * International Academy Of Pali Tipitaka(国际巴利三藏学院) 由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
  16. *
  17. * The version of the OpenAPI document: 1.0.0
  18. * Generated by: https://openapi-generator.tech
  19. * Generator version: 7.25.0
  20. */
  21. /**
  22. * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
  23. * https://openapi-generator.tech
  24. * Do not edit the class manually.
  25. */
  26. namespace WikipaliApi\Model;
  27. use \ArrayAccess;
  28. use \WikipaliApi\ObjectSerializer;
  29. /**
  30. * PostApiV3SearchRequest Class Doc Comment
  31. *
  32. * @category Class
  33. * @package WikipaliApi
  34. * @author OpenAPI Generator team
  35. * @link https://openapi-generator.tech
  36. * @implements \ArrayAccess<string, mixed>
  37. */
  38. class PostApiV3SearchRequest implements ModelInterface, ArrayAccess, \JsonSerializable
  39. {
  40. public const DISCRIMINATOR = null;
  41. /**
  42. * The original name of the model.
  43. *
  44. * @var string
  45. */
  46. protected static $openAPIModelName = 'post_api_v3_search_request';
  47. /**
  48. * Array of property to type mappings. Used for (de)serialization
  49. *
  50. * @var string[]
  51. */
  52. protected static $openAPITypes = [
  53. 'q' => 'string',
  54. 'search_mode' => 'string',
  55. 'resource_type' => 'string',
  56. 'resource_id' => 'string',
  57. 'granularity' => 'string',
  58. 'language' => 'string',
  59. 'category' => 'string',
  60. 'tags' => 'string',
  61. 'page_refs' => 'string[]',
  62. 'related_id' => 'string[]',
  63. 'author' => 'string',
  64. 'channel' => 'string',
  65. 'facets' => 'bool',
  66. 'page' => 'int',
  67. 'per_page' => 'int'
  68. ];
  69. /**
  70. * Array of property to format mappings. Used for (de)serialization
  71. *
  72. * @var string[]
  73. * @phpstan-var array<string, string|null>
  74. * @psalm-var array<string, string|null>
  75. */
  76. protected static $openAPIFormats = [
  77. 'q' => null,
  78. 'search_mode' => null,
  79. 'resource_type' => null,
  80. 'resource_id' => null,
  81. 'granularity' => null,
  82. 'language' => null,
  83. 'category' => null,
  84. 'tags' => null,
  85. 'page_refs' => null,
  86. 'related_id' => null,
  87. 'author' => null,
  88. 'channel' => null,
  89. 'facets' => null,
  90. 'page' => null,
  91. 'per_page' => null
  92. ];
  93. /**
  94. * Array of nullable properties. Used for (de)serialization
  95. *
  96. * @var boolean[]
  97. */
  98. protected static array $openAPINullables = [
  99. 'q' => false,
  100. 'search_mode' => false,
  101. 'resource_type' => false,
  102. 'resource_id' => false,
  103. 'granularity' => false,
  104. 'language' => false,
  105. 'category' => false,
  106. 'tags' => false,
  107. 'page_refs' => false,
  108. 'related_id' => false,
  109. 'author' => false,
  110. 'channel' => false,
  111. 'facets' => false,
  112. 'page' => false,
  113. 'per_page' => false
  114. ];
  115. /**
  116. * If a nullable field gets set to null, insert it here
  117. *
  118. * @var boolean[]
  119. */
  120. protected array $openAPINullablesSetToNull = [];
  121. /**
  122. * Array of property to type mappings. Used for (de)serialization
  123. *
  124. * @return array
  125. */
  126. public static function openAPITypes()
  127. {
  128. return self::$openAPITypes;
  129. }
  130. /**
  131. * Array of property to format mappings. Used for (de)serialization
  132. *
  133. * @return array
  134. */
  135. public static function openAPIFormats()
  136. {
  137. return self::$openAPIFormats;
  138. }
  139. /**
  140. * Array of nullable properties
  141. *
  142. * @return array
  143. */
  144. protected static function openAPINullables(): array
  145. {
  146. return self::$openAPINullables;
  147. }
  148. /**
  149. * Array of nullable field names deliberately set to null
  150. *
  151. * @return boolean[]
  152. */
  153. private function getOpenAPINullablesSetToNull(): array
  154. {
  155. return $this->openAPINullablesSetToNull;
  156. }
  157. /**
  158. * Setter - Array of nullable field names deliberately set to null
  159. *
  160. * @param boolean[] $openAPINullablesSetToNull
  161. */
  162. private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
  163. {
  164. $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
  165. }
  166. /**
  167. * Checks if a property is nullable
  168. *
  169. * @param string $property
  170. * @return bool
  171. */
  172. public static function isNullable(string $property): bool
  173. {
  174. return self::openAPINullables()[$property] ?? false;
  175. }
  176. /**
  177. * Checks if a nullable property is set to null.
  178. *
  179. * @param string $property
  180. * @return bool
  181. */
  182. public function isNullableSetToNull(string $property): bool
  183. {
  184. return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
  185. }
  186. /**
  187. * Array of attributes where the key is the local name,
  188. * and the value is the original name
  189. *
  190. * @var string[]
  191. */
  192. protected static $attributeMap = [
  193. 'q' => 'q',
  194. 'search_mode' => 'search_mode',
  195. 'resource_type' => 'resource_type',
  196. 'resource_id' => 'resource_id',
  197. 'granularity' => 'granularity',
  198. 'language' => 'language',
  199. 'category' => 'category',
  200. 'tags' => 'tags',
  201. 'page_refs' => 'page_refs',
  202. 'related_id' => 'related_id',
  203. 'author' => 'author',
  204. 'channel' => 'channel',
  205. 'facets' => 'facets',
  206. 'page' => 'page',
  207. 'per_page' => 'per_page'
  208. ];
  209. /**
  210. * Array of attributes to setter functions (for deserialization of responses)
  211. *
  212. * @var string[]
  213. */
  214. protected static $setters = [
  215. 'q' => 'setQ',
  216. 'search_mode' => 'setSearchMode',
  217. 'resource_type' => 'setResourceType',
  218. 'resource_id' => 'setResourceId',
  219. 'granularity' => 'setGranularity',
  220. 'language' => 'setLanguage',
  221. 'category' => 'setCategory',
  222. 'tags' => 'setTags',
  223. 'page_refs' => 'setPageRefs',
  224. 'related_id' => 'setRelatedId',
  225. 'author' => 'setAuthor',
  226. 'channel' => 'setChannel',
  227. 'facets' => 'setFacets',
  228. 'page' => 'setPage',
  229. 'per_page' => 'setPerPage'
  230. ];
  231. /**
  232. * Array of attributes to getter functions (for serialization of requests)
  233. *
  234. * @var string[]
  235. */
  236. protected static $getters = [
  237. 'q' => 'getQ',
  238. 'search_mode' => 'getSearchMode',
  239. 'resource_type' => 'getResourceType',
  240. 'resource_id' => 'getResourceId',
  241. 'granularity' => 'getGranularity',
  242. 'language' => 'getLanguage',
  243. 'category' => 'getCategory',
  244. 'tags' => 'getTags',
  245. 'page_refs' => 'getPageRefs',
  246. 'related_id' => 'getRelatedId',
  247. 'author' => 'getAuthor',
  248. 'channel' => 'getChannel',
  249. 'facets' => 'getFacets',
  250. 'page' => 'getPage',
  251. 'per_page' => 'getPerPage'
  252. ];
  253. /**
  254. * Array of attributes where the key is the local name,
  255. * and the value is the original name
  256. *
  257. * @return array
  258. */
  259. public static function attributeMap()
  260. {
  261. return self::$attributeMap;
  262. }
  263. /**
  264. * Array of attributes to setter functions (for deserialization of responses)
  265. *
  266. * @return array
  267. */
  268. public static function setters()
  269. {
  270. return self::$setters;
  271. }
  272. /**
  273. * Array of attributes to getter functions (for serialization of requests)
  274. *
  275. * @return array
  276. */
  277. public static function getters()
  278. {
  279. return self::$getters;
  280. }
  281. /**
  282. * The original name of the model.
  283. *
  284. * @return string
  285. */
  286. public function getModelName()
  287. {
  288. return self::$openAPIModelName;
  289. }
  290. public const SEARCH_MODE_FUZZY = 'fuzzy';
  291. public const SEARCH_MODE_EXACT = 'exact';
  292. public const SEARCH_MODE_SEMANTIC = 'semantic';
  293. public const SEARCH_MODE_HYBRID = 'hybrid';
  294. public const SEARCH_MODE_DEFINITION = 'definition';
  295. public const RESOURCE_TYPE_TIPITAKA = 'tipitaka';
  296. public const RESOURCE_TYPE_ORIGINAL_TEXT = 'original_text';
  297. public const RESOURCE_TYPE_TERM = 'term';
  298. public const GRANULARITY_BOOK = 'book';
  299. public const GRANULARITY_CHAPTER = 'chapter';
  300. public const GRANULARITY_SESSION = 'session';
  301. public const GRANULARITY_PARAGRAPH = 'paragraph';
  302. /**
  303. * Gets allowable values of the enum
  304. *
  305. * @return string[]
  306. */
  307. public function getSearchModeAllowableValues()
  308. {
  309. return [
  310. self::SEARCH_MODE_FUZZY,
  311. self::SEARCH_MODE_EXACT,
  312. self::SEARCH_MODE_SEMANTIC,
  313. self::SEARCH_MODE_HYBRID,
  314. self::SEARCH_MODE_DEFINITION,
  315. ];
  316. }
  317. /**
  318. * Gets allowable values of the enum
  319. *
  320. * @return string[]
  321. */
  322. public function getResourceTypeAllowableValues()
  323. {
  324. return [
  325. self::RESOURCE_TYPE_TIPITAKA,
  326. self::RESOURCE_TYPE_ORIGINAL_TEXT,
  327. self::RESOURCE_TYPE_TERM,
  328. ];
  329. }
  330. /**
  331. * Gets allowable values of the enum
  332. *
  333. * @return string[]
  334. */
  335. public function getGranularityAllowableValues()
  336. {
  337. return [
  338. self::GRANULARITY_BOOK,
  339. self::GRANULARITY_CHAPTER,
  340. self::GRANULARITY_SESSION,
  341. self::GRANULARITY_PARAGRAPH,
  342. ];
  343. }
  344. /**
  345. * Associative array for storing property values
  346. *
  347. * @var mixed[]
  348. */
  349. protected $container = [];
  350. /**
  351. * Constructor
  352. *
  353. * @param mixed[]|null $data Associated array of property values
  354. * initializing the model
  355. */
  356. public function __construct(?array $data = null)
  357. {
  358. $this->setIfExists('q', $data ?? [], null);
  359. $this->setIfExists('search_mode', $data ?? [], 'fuzzy');
  360. $this->setIfExists('resource_type', $data ?? [], null);
  361. $this->setIfExists('resource_id', $data ?? [], null);
  362. $this->setIfExists('granularity', $data ?? [], null);
  363. $this->setIfExists('language', $data ?? [], null);
  364. $this->setIfExists('category', $data ?? [], null);
  365. $this->setIfExists('tags', $data ?? [], null);
  366. $this->setIfExists('page_refs', $data ?? [], null);
  367. $this->setIfExists('related_id', $data ?? [], null);
  368. $this->setIfExists('author', $data ?? [], null);
  369. $this->setIfExists('channel', $data ?? [], null);
  370. $this->setIfExists('facets', $data ?? [], false);
  371. $this->setIfExists('page', $data ?? [], 1);
  372. $this->setIfExists('per_page', $data ?? [], 20);
  373. }
  374. /**
  375. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  376. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  377. * $this->openAPINullablesSetToNull array
  378. *
  379. * @param string $variableName
  380. * @param array $fields
  381. * @param mixed $defaultValue
  382. */
  383. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  384. {
  385. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  386. $this->openAPINullablesSetToNull[] = $variableName;
  387. }
  388. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  389. }
  390. /**
  391. * Show all the invalid properties with reasons.
  392. *
  393. * @return array invalid properties with reasons
  394. */
  395. public function listInvalidProperties()
  396. {
  397. $invalidProperties = [];
  398. if ($this->container['q'] === null) {
  399. $invalidProperties[] = "'q' can't be null";
  400. }
  401. $allowedValues = $this->getSearchModeAllowableValues();
  402. if (!is_null($this->container['search_mode']) && !in_array($this->container['search_mode'], $allowedValues, true)) {
  403. $invalidProperties[] = sprintf(
  404. "invalid value '%s' for 'search_mode', must be one of '%s'",
  405. $this->container['search_mode'],
  406. implode("', '", $allowedValues)
  407. );
  408. }
  409. $allowedValues = $this->getResourceTypeAllowableValues();
  410. if (!is_null($this->container['resource_type']) && !in_array($this->container['resource_type'], $allowedValues, true)) {
  411. $invalidProperties[] = sprintf(
  412. "invalid value '%s' for 'resource_type', must be one of '%s'",
  413. $this->container['resource_type'],
  414. implode("', '", $allowedValues)
  415. );
  416. }
  417. $allowedValues = $this->getGranularityAllowableValues();
  418. if (!is_null($this->container['granularity']) && !in_array($this->container['granularity'], $allowedValues, true)) {
  419. $invalidProperties[] = sprintf(
  420. "invalid value '%s' for 'granularity', must be one of '%s'",
  421. $this->container['granularity'],
  422. implode("', '", $allowedValues)
  423. );
  424. }
  425. return $invalidProperties;
  426. }
  427. /**
  428. * Validate all the properties in the model
  429. * return true if all passed
  430. *
  431. * @return bool True if all properties are valid
  432. */
  433. public function valid()
  434. {
  435. return count($this->listInvalidProperties()) === 0;
  436. }
  437. /**
  438. * Gets q
  439. *
  440. * @return string
  441. */
  442. public function getQ()
  443. {
  444. return $this->container['q'];
  445. }
  446. /**
  447. * Sets q
  448. *
  449. * @param string $q 检索词
  450. *
  451. * @return self
  452. */
  453. public function setQ($q)
  454. {
  455. if (is_null($q)) {
  456. throw new \InvalidArgumentException('non-nullable q cannot be null');
  457. }
  458. $this->container['q'] = $q;
  459. return $this;
  460. }
  461. /**
  462. * Gets search_mode
  463. *
  464. * @return string|null
  465. */
  466. public function getSearchMode()
  467. {
  468. return $this->container['search_mode'];
  469. }
  470. /**
  471. * Sets search_mode
  472. *
  473. * @param string|null $search_mode 检索模式
  474. *
  475. * @return self
  476. */
  477. public function setSearchMode($search_mode)
  478. {
  479. if (is_null($search_mode)) {
  480. throw new \InvalidArgumentException('non-nullable search_mode cannot be null');
  481. }
  482. $allowedValues = $this->getSearchModeAllowableValues();
  483. if (!in_array($search_mode, $allowedValues, true)) {
  484. throw new \InvalidArgumentException(
  485. sprintf(
  486. "Invalid value '%s' for 'search_mode', must be one of '%s'",
  487. $search_mode,
  488. implode("', '", $allowedValues)
  489. )
  490. );
  491. }
  492. $this->container['search_mode'] = $search_mode;
  493. return $this;
  494. }
  495. /**
  496. * Gets resource_type
  497. *
  498. * @return string|null
  499. */
  500. public function getResourceType()
  501. {
  502. return $this->container['resource_type'];
  503. }
  504. /**
  505. * Sets resource_type
  506. *
  507. * @param string|null $resource_type 资源类型
  508. *
  509. * @return self
  510. */
  511. public function setResourceType($resource_type)
  512. {
  513. if (is_null($resource_type)) {
  514. throw new \InvalidArgumentException('non-nullable resource_type cannot be null');
  515. }
  516. $allowedValues = $this->getResourceTypeAllowableValues();
  517. if (!in_array($resource_type, $allowedValues, true)) {
  518. throw new \InvalidArgumentException(
  519. sprintf(
  520. "Invalid value '%s' for 'resource_type', must be one of '%s'",
  521. $resource_type,
  522. implode("', '", $allowedValues)
  523. )
  524. );
  525. }
  526. $this->container['resource_type'] = $resource_type;
  527. return $this;
  528. }
  529. /**
  530. * Gets resource_id
  531. *
  532. * @return string|null
  533. */
  534. public function getResourceId()
  535. {
  536. return $this->container['resource_id'];
  537. }
  538. /**
  539. * Sets resource_id
  540. *
  541. * @param string|null $resource_id 限定某个资源 id
  542. *
  543. * @return self
  544. */
  545. public function setResourceId($resource_id)
  546. {
  547. if (is_null($resource_id)) {
  548. throw new \InvalidArgumentException('non-nullable resource_id cannot be null');
  549. }
  550. $this->container['resource_id'] = $resource_id;
  551. return $this;
  552. }
  553. /**
  554. * Gets granularity
  555. *
  556. * @return string|null
  557. */
  558. public function getGranularity()
  559. {
  560. return $this->container['granularity'];
  561. }
  562. /**
  563. * Sets granularity
  564. *
  565. * @param string|null $granularity 文档颗粒度
  566. *
  567. * @return self
  568. */
  569. public function setGranularity($granularity)
  570. {
  571. if (is_null($granularity)) {
  572. throw new \InvalidArgumentException('non-nullable granularity cannot be null');
  573. }
  574. $allowedValues = $this->getGranularityAllowableValues();
  575. if (!in_array($granularity, $allowedValues, true)) {
  576. throw new \InvalidArgumentException(
  577. sprintf(
  578. "Invalid value '%s' for 'granularity', must be one of '%s'",
  579. $granularity,
  580. implode("', '", $allowedValues)
  581. )
  582. );
  583. }
  584. $this->container['granularity'] = $granularity;
  585. return $this;
  586. }
  587. /**
  588. * Gets language
  589. *
  590. * @return string|null
  591. */
  592. public function getLanguage()
  593. {
  594. return $this->container['language'];
  595. }
  596. /**
  597. * Sets language
  598. *
  599. * @param string|null $language 文档语言
  600. *
  601. * @return self
  602. */
  603. public function setLanguage($language)
  604. {
  605. if (is_null($language)) {
  606. throw new \InvalidArgumentException('non-nullable language cannot be null');
  607. }
  608. $this->container['language'] = $language;
  609. return $this;
  610. }
  611. /**
  612. * Gets category
  613. *
  614. * @return string|null
  615. */
  616. public function getCategory()
  617. {
  618. return $this->container['category'];
  619. }
  620. /**
  621. * Sets category
  622. *
  623. * @param string|null $category 分类,逗号分隔,须全部命中
  624. *
  625. * @return self
  626. */
  627. public function setCategory($category)
  628. {
  629. if (is_null($category)) {
  630. throw new \InvalidArgumentException('non-nullable category cannot be null');
  631. }
  632. $this->container['category'] = $category;
  633. return $this;
  634. }
  635. /**
  636. * Gets tags
  637. *
  638. * @return string|null
  639. */
  640. public function getTags()
  641. {
  642. return $this->container['tags'];
  643. }
  644. /**
  645. * Sets tags
  646. *
  647. * @param string|null $tags 标签,逗号分隔,命中任一
  648. *
  649. * @return self
  650. */
  651. public function setTags($tags)
  652. {
  653. if (is_null($tags)) {
  654. throw new \InvalidArgumentException('non-nullable tags cannot be null');
  655. }
  656. $this->container['tags'] = $tags;
  657. return $this;
  658. }
  659. /**
  660. * Gets page_refs
  661. *
  662. * @return string[]|null
  663. */
  664. public function getPageRefs()
  665. {
  666. return $this->container['page_refs'];
  667. }
  668. /**
  669. * Sets page_refs
  670. *
  671. * @param string[]|null $page_refs 页码标记,命中任一
  672. *
  673. * @return self
  674. */
  675. public function setPageRefs($page_refs)
  676. {
  677. if (is_null($page_refs)) {
  678. throw new \InvalidArgumentException('non-nullable page_refs cannot be null');
  679. }
  680. $this->container['page_refs'] = $page_refs;
  681. return $this;
  682. }
  683. /**
  684. * Gets related_id
  685. *
  686. * @return string[]|null
  687. */
  688. public function getRelatedId()
  689. {
  690. return $this->container['related_id'];
  691. }
  692. /**
  693. * Sets related_id
  694. *
  695. * @param string[]|null $related_id 关联 id,命中任一
  696. *
  697. * @return self
  698. */
  699. public function setRelatedId($related_id)
  700. {
  701. if (is_null($related_id)) {
  702. throw new \InvalidArgumentException('non-nullable related_id cannot be null');
  703. }
  704. $this->container['related_id'] = $related_id;
  705. return $this;
  706. }
  707. /**
  708. * Gets author
  709. *
  710. * @return string|null
  711. */
  712. public function getAuthor()
  713. {
  714. return $this->container['author'];
  715. }
  716. /**
  717. * Sets author
  718. *
  719. * @param string|null $author 作者或译者
  720. *
  721. * @return self
  722. */
  723. public function setAuthor($author)
  724. {
  725. if (is_null($author)) {
  726. throw new \InvalidArgumentException('non-nullable author cannot be null');
  727. }
  728. $this->container['author'] = $author;
  729. return $this;
  730. }
  731. /**
  732. * Gets channel
  733. *
  734. * @return string|null
  735. */
  736. public function getChannel()
  737. {
  738. return $this->container['channel'];
  739. }
  740. /**
  741. * Sets channel
  742. *
  743. * @param string|null $channel 来源 channel 的 uuid
  744. *
  745. * @return self
  746. */
  747. public function setChannel($channel)
  748. {
  749. if (is_null($channel)) {
  750. throw new \InvalidArgumentException('non-nullable channel cannot be null');
  751. }
  752. $this->container['channel'] = $channel;
  753. return $this;
  754. }
  755. /**
  756. * Gets facets
  757. *
  758. * @return bool|null
  759. */
  760. public function getFacets()
  761. {
  762. return $this->container['facets'];
  763. }
  764. /**
  765. * Sets facets
  766. *
  767. * @param bool|null $facets 是否返回分面计数
  768. *
  769. * @return self
  770. */
  771. public function setFacets($facets)
  772. {
  773. if (is_null($facets)) {
  774. throw new \InvalidArgumentException('non-nullable facets cannot be null');
  775. }
  776. $this->container['facets'] = $facets;
  777. return $this;
  778. }
  779. /**
  780. * Gets page
  781. *
  782. * @return int|null
  783. */
  784. public function getPage()
  785. {
  786. return $this->container['page'];
  787. }
  788. /**
  789. * Sets page
  790. *
  791. * @param int|null $page 页码
  792. *
  793. * @return self
  794. */
  795. public function setPage($page)
  796. {
  797. if (is_null($page)) {
  798. throw new \InvalidArgumentException('non-nullable page cannot be null');
  799. }
  800. $this->container['page'] = $page;
  801. return $this;
  802. }
  803. /**
  804. * Gets per_page
  805. *
  806. * @return int|null
  807. */
  808. public function getPerPage()
  809. {
  810. return $this->container['per_page'];
  811. }
  812. /**
  813. * Sets per_page
  814. *
  815. * @param int|null $per_page 每页条数,上限 100
  816. *
  817. * @return self
  818. */
  819. public function setPerPage($per_page)
  820. {
  821. if (is_null($per_page)) {
  822. throw new \InvalidArgumentException('non-nullable per_page cannot be null');
  823. }
  824. $this->container['per_page'] = $per_page;
  825. return $this;
  826. }
  827. /**
  828. * Returns true if offset exists. False otherwise.
  829. *
  830. * @param integer|string $offset Offset
  831. *
  832. * @return boolean
  833. */
  834. public function offsetExists(mixed $offset): bool
  835. {
  836. return isset($this->container[$offset]);
  837. }
  838. /**
  839. * Gets offset.
  840. *
  841. * @param integer|string $offset Offset
  842. *
  843. * @return mixed|null
  844. */
  845. #[\ReturnTypeWillChange]
  846. public function offsetGet(mixed $offset)
  847. {
  848. return $this->container[$offset] ?? null;
  849. }
  850. /**
  851. * Sets value based on offset.
  852. *
  853. * @param int|null $offset Offset
  854. * @param mixed $value Value to be set
  855. *
  856. * @return void
  857. */
  858. public function offsetSet($offset, $value): void
  859. {
  860. if (is_null($offset)) {
  861. $this->container[] = $value;
  862. } else {
  863. $this->container[$offset] = $value;
  864. }
  865. }
  866. /**
  867. * Unsets offset.
  868. *
  869. * @param integer|string $offset Offset
  870. *
  871. * @return void
  872. */
  873. public function offsetUnset(mixed $offset): void
  874. {
  875. unset($this->container[$offset]);
  876. }
  877. /**
  878. * Serializes the object to a value that can be serialized natively by json_encode().
  879. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  880. *
  881. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  882. * of any type other than a resource.
  883. */
  884. #[\ReturnTypeWillChange]
  885. public function jsonSerialize()
  886. {
  887. return ObjectSerializer::sanitizeForSerialization($this);
  888. }
  889. /**
  890. * Gets the string presentation of the object
  891. *
  892. * @return string
  893. */
  894. public function __toString()
  895. {
  896. return json_encode(
  897. ObjectSerializer::sanitizeForSerialization($this),
  898. JSON_PRETTY_PRINT
  899. );
  900. }
  901. /**
  902. * Gets a header-safe presentation of the object
  903. *
  904. * @return string
  905. */
  906. public function toHeaderValue()
  907. {
  908. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  909. }
  910. }