PostApiV3SearchRequest.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858
  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: 2026.9.28
  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. 'granularity' => 'string',
  57. 'language' => 'string',
  58. 'category' => 'string',
  59. 'tags' => 'string',
  60. 'page_refs' => 'string[]',
  61. 'related_id' => 'string[]',
  62. 'author' => 'string',
  63. 'channel' => 'string',
  64. 'page' => 'int',
  65. 'page_size' => 'int'
  66. ];
  67. /**
  68. * Array of property to format mappings. Used for (de)serialization
  69. *
  70. * @var string[]
  71. * @phpstan-var array<string, string|null>
  72. * @psalm-var array<string, string|null>
  73. */
  74. protected static $openAPIFormats = [
  75. 'q' => null,
  76. 'search_mode' => null,
  77. 'resource_type' => null,
  78. 'granularity' => null,
  79. 'language' => null,
  80. 'category' => null,
  81. 'tags' => null,
  82. 'page_refs' => null,
  83. 'related_id' => null,
  84. 'author' => null,
  85. 'channel' => null,
  86. 'page' => null,
  87. 'page_size' => null
  88. ];
  89. /**
  90. * Array of nullable properties. Used for (de)serialization
  91. *
  92. * @var boolean[]
  93. */
  94. protected static array $openAPINullables = [
  95. 'q' => false,
  96. 'search_mode' => false,
  97. 'resource_type' => false,
  98. 'granularity' => false,
  99. 'language' => false,
  100. 'category' => false,
  101. 'tags' => false,
  102. 'page_refs' => false,
  103. 'related_id' => false,
  104. 'author' => false,
  105. 'channel' => false,
  106. 'page' => false,
  107. 'page_size' => false
  108. ];
  109. /**
  110. * If a nullable field gets set to null, insert it here
  111. *
  112. * @var boolean[]
  113. */
  114. protected array $openAPINullablesSetToNull = [];
  115. /**
  116. * Array of property to type mappings. Used for (de)serialization
  117. *
  118. * @return array
  119. */
  120. public static function openAPITypes()
  121. {
  122. return self::$openAPITypes;
  123. }
  124. /**
  125. * Array of property to format mappings. Used for (de)serialization
  126. *
  127. * @return array
  128. */
  129. public static function openAPIFormats()
  130. {
  131. return self::$openAPIFormats;
  132. }
  133. /**
  134. * Array of nullable properties
  135. *
  136. * @return array
  137. */
  138. protected static function openAPINullables(): array
  139. {
  140. return self::$openAPINullables;
  141. }
  142. /**
  143. * Array of nullable field names deliberately set to null
  144. *
  145. * @return boolean[]
  146. */
  147. private function getOpenAPINullablesSetToNull(): array
  148. {
  149. return $this->openAPINullablesSetToNull;
  150. }
  151. /**
  152. * Setter - Array of nullable field names deliberately set to null
  153. *
  154. * @param boolean[] $openAPINullablesSetToNull
  155. */
  156. private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
  157. {
  158. $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
  159. }
  160. /**
  161. * Checks if a property is nullable
  162. *
  163. * @param string $property
  164. * @return bool
  165. */
  166. public static function isNullable(string $property): bool
  167. {
  168. return self::openAPINullables()[$property] ?? false;
  169. }
  170. /**
  171. * Checks if a nullable property is set to null.
  172. *
  173. * @param string $property
  174. * @return bool
  175. */
  176. public function isNullableSetToNull(string $property): bool
  177. {
  178. return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
  179. }
  180. /**
  181. * Array of attributes where the key is the local name,
  182. * and the value is the original name
  183. *
  184. * @var string[]
  185. */
  186. protected static $attributeMap = [
  187. 'q' => 'q',
  188. 'search_mode' => 'search_mode',
  189. 'resource_type' => 'resource_type',
  190. 'granularity' => 'granularity',
  191. 'language' => 'language',
  192. 'category' => 'category',
  193. 'tags' => 'tags',
  194. 'page_refs' => 'page_refs',
  195. 'related_id' => 'related_id',
  196. 'author' => 'author',
  197. 'channel' => 'channel',
  198. 'page' => 'page',
  199. 'page_size' => 'page_size'
  200. ];
  201. /**
  202. * Array of attributes to setter functions (for deserialization of responses)
  203. *
  204. * @var string[]
  205. */
  206. protected static $setters = [
  207. 'q' => 'setQ',
  208. 'search_mode' => 'setSearchMode',
  209. 'resource_type' => 'setResourceType',
  210. 'granularity' => 'setGranularity',
  211. 'language' => 'setLanguage',
  212. 'category' => 'setCategory',
  213. 'tags' => 'setTags',
  214. 'page_refs' => 'setPageRefs',
  215. 'related_id' => 'setRelatedId',
  216. 'author' => 'setAuthor',
  217. 'channel' => 'setChannel',
  218. 'page' => 'setPage',
  219. 'page_size' => 'setPageSize'
  220. ];
  221. /**
  222. * Array of attributes to getter functions (for serialization of requests)
  223. *
  224. * @var string[]
  225. */
  226. protected static $getters = [
  227. 'q' => 'getQ',
  228. 'search_mode' => 'getSearchMode',
  229. 'resource_type' => 'getResourceType',
  230. 'granularity' => 'getGranularity',
  231. 'language' => 'getLanguage',
  232. 'category' => 'getCategory',
  233. 'tags' => 'getTags',
  234. 'page_refs' => 'getPageRefs',
  235. 'related_id' => 'getRelatedId',
  236. 'author' => 'getAuthor',
  237. 'channel' => 'getChannel',
  238. 'page' => 'getPage',
  239. 'page_size' => 'getPageSize'
  240. ];
  241. /**
  242. * Array of attributes where the key is the local name,
  243. * and the value is the original name
  244. *
  245. * @return array
  246. */
  247. public static function attributeMap()
  248. {
  249. return self::$attributeMap;
  250. }
  251. /**
  252. * Array of attributes to setter functions (for deserialization of responses)
  253. *
  254. * @return array
  255. */
  256. public static function setters()
  257. {
  258. return self::$setters;
  259. }
  260. /**
  261. * Array of attributes to getter functions (for serialization of requests)
  262. *
  263. * @return array
  264. */
  265. public static function getters()
  266. {
  267. return self::$getters;
  268. }
  269. /**
  270. * The original name of the model.
  271. *
  272. * @return string
  273. */
  274. public function getModelName()
  275. {
  276. return self::$openAPIModelName;
  277. }
  278. public const SEARCH_MODE_FUZZY = 'fuzzy';
  279. public const SEARCH_MODE_EXACT = 'exact';
  280. public const SEARCH_MODE_SEMANTIC = 'semantic';
  281. public const SEARCH_MODE_HYBRID = 'hybrid';
  282. /**
  283. * Gets allowable values of the enum
  284. *
  285. * @return string[]
  286. */
  287. public function getSearchModeAllowableValues()
  288. {
  289. return [
  290. self::SEARCH_MODE_FUZZY,
  291. self::SEARCH_MODE_EXACT,
  292. self::SEARCH_MODE_SEMANTIC,
  293. self::SEARCH_MODE_HYBRID,
  294. ];
  295. }
  296. /**
  297. * Associative array for storing property values
  298. *
  299. * @var mixed[]
  300. */
  301. protected $container = [];
  302. /**
  303. * Constructor
  304. *
  305. * @param mixed[]|null $data Associated array of property values
  306. * initializing the model
  307. */
  308. public function __construct(?array $data = null)
  309. {
  310. $this->setIfExists('q', $data ?? [], null);
  311. $this->setIfExists('search_mode', $data ?? [], 'fuzzy');
  312. $this->setIfExists('resource_type', $data ?? [], null);
  313. $this->setIfExists('granularity', $data ?? [], null);
  314. $this->setIfExists('language', $data ?? [], null);
  315. $this->setIfExists('category', $data ?? [], null);
  316. $this->setIfExists('tags', $data ?? [], null);
  317. $this->setIfExists('page_refs', $data ?? [], null);
  318. $this->setIfExists('related_id', $data ?? [], null);
  319. $this->setIfExists('author', $data ?? [], null);
  320. $this->setIfExists('channel', $data ?? [], null);
  321. $this->setIfExists('page', $data ?? [], 1);
  322. $this->setIfExists('page_size', $data ?? [], 20);
  323. }
  324. /**
  325. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  326. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  327. * $this->openAPINullablesSetToNull array
  328. *
  329. * @param string $variableName
  330. * @param array $fields
  331. * @param mixed $defaultValue
  332. */
  333. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  334. {
  335. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  336. $this->openAPINullablesSetToNull[] = $variableName;
  337. }
  338. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  339. }
  340. /**
  341. * Show all the invalid properties with reasons.
  342. *
  343. * @return array invalid properties with reasons
  344. */
  345. public function listInvalidProperties()
  346. {
  347. $invalidProperties = [];
  348. if ($this->container['q'] === null) {
  349. $invalidProperties[] = "'q' can't be null";
  350. }
  351. $allowedValues = $this->getSearchModeAllowableValues();
  352. if (!is_null($this->container['search_mode']) && !in_array($this->container['search_mode'], $allowedValues, true)) {
  353. $invalidProperties[] = sprintf(
  354. "invalid value '%s' for 'search_mode', must be one of '%s'",
  355. $this->container['search_mode'],
  356. implode("', '", $allowedValues)
  357. );
  358. }
  359. return $invalidProperties;
  360. }
  361. /**
  362. * Validate all the properties in the model
  363. * return true if all passed
  364. *
  365. * @return bool True if all properties are valid
  366. */
  367. public function valid()
  368. {
  369. return count($this->listInvalidProperties()) === 0;
  370. }
  371. /**
  372. * Gets q
  373. *
  374. * @return string
  375. */
  376. public function getQ()
  377. {
  378. return $this->container['q'];
  379. }
  380. /**
  381. * Sets q
  382. *
  383. * @param string $q 搜索关键词
  384. *
  385. * @return self
  386. */
  387. public function setQ($q)
  388. {
  389. if (is_null($q)) {
  390. throw new \InvalidArgumentException('non-nullable q cannot be null');
  391. }
  392. $this->container['q'] = $q;
  393. return $this;
  394. }
  395. /**
  396. * Gets search_mode
  397. *
  398. * @return string|null
  399. */
  400. public function getSearchMode()
  401. {
  402. return $this->container['search_mode'];
  403. }
  404. /**
  405. * Sets search_mode
  406. *
  407. * @param string|null $search_mode 检索模式
  408. *
  409. * @return self
  410. */
  411. public function setSearchMode($search_mode)
  412. {
  413. if (is_null($search_mode)) {
  414. throw new \InvalidArgumentException('non-nullable search_mode cannot be null');
  415. }
  416. $allowedValues = $this->getSearchModeAllowableValues();
  417. if (!in_array($search_mode, $allowedValues, true)) {
  418. throw new \InvalidArgumentException(
  419. sprintf(
  420. "Invalid value '%s' for 'search_mode', must be one of '%s'",
  421. $search_mode,
  422. implode("', '", $allowedValues)
  423. )
  424. );
  425. }
  426. $this->container['search_mode'] = $search_mode;
  427. return $this;
  428. }
  429. /**
  430. * Gets resource_type
  431. *
  432. * @return string|null
  433. */
  434. public function getResourceType()
  435. {
  436. return $this->container['resource_type'];
  437. }
  438. /**
  439. * Sets resource_type
  440. *
  441. * @param string|null $resource_type 资源类型
  442. *
  443. * @return self
  444. */
  445. public function setResourceType($resource_type)
  446. {
  447. if (is_null($resource_type)) {
  448. throw new \InvalidArgumentException('non-nullable resource_type cannot be null');
  449. }
  450. $this->container['resource_type'] = $resource_type;
  451. return $this;
  452. }
  453. /**
  454. * Gets granularity
  455. *
  456. * @return string|null
  457. */
  458. public function getGranularity()
  459. {
  460. return $this->container['granularity'];
  461. }
  462. /**
  463. * Sets granularity
  464. *
  465. * @param string|null $granularity 文档颗粒度
  466. *
  467. * @return self
  468. */
  469. public function setGranularity($granularity)
  470. {
  471. if (is_null($granularity)) {
  472. throw new \InvalidArgumentException('non-nullable granularity cannot be null');
  473. }
  474. $this->container['granularity'] = $granularity;
  475. return $this;
  476. }
  477. /**
  478. * Gets language
  479. *
  480. * @return string|null
  481. */
  482. public function getLanguage()
  483. {
  484. return $this->container['language'];
  485. }
  486. /**
  487. * Sets language
  488. *
  489. * @param string|null $language 语言
  490. *
  491. * @return self
  492. */
  493. public function setLanguage($language)
  494. {
  495. if (is_null($language)) {
  496. throw new \InvalidArgumentException('non-nullable language cannot be null');
  497. }
  498. $this->container['language'] = $language;
  499. return $this;
  500. }
  501. /**
  502. * Gets category
  503. *
  504. * @return string|null
  505. */
  506. public function getCategory()
  507. {
  508. return $this->container['category'];
  509. }
  510. /**
  511. * Sets category
  512. *
  513. * @param string|null $category 文档分类,逗号分隔
  514. *
  515. * @return self
  516. */
  517. public function setCategory($category)
  518. {
  519. if (is_null($category)) {
  520. throw new \InvalidArgumentException('non-nullable category cannot be null');
  521. }
  522. $this->container['category'] = $category;
  523. return $this;
  524. }
  525. /**
  526. * Gets tags
  527. *
  528. * @return string|null
  529. */
  530. public function getTags()
  531. {
  532. return $this->container['tags'];
  533. }
  534. /**
  535. * Sets tags
  536. *
  537. * @param string|null $tags 标签,逗号分隔
  538. *
  539. * @return self
  540. */
  541. public function setTags($tags)
  542. {
  543. if (is_null($tags)) {
  544. throw new \InvalidArgumentException('non-nullable tags cannot be null');
  545. }
  546. $this->container['tags'] = $tags;
  547. return $this;
  548. }
  549. /**
  550. * Gets page_refs
  551. *
  552. * @return string[]|null
  553. */
  554. public function getPageRefs()
  555. {
  556. return $this->container['page_refs'];
  557. }
  558. /**
  559. * Sets page_refs
  560. *
  561. * @param string[]|null $page_refs 页码标记
  562. *
  563. * @return self
  564. */
  565. public function setPageRefs($page_refs)
  566. {
  567. if (is_null($page_refs)) {
  568. throw new \InvalidArgumentException('non-nullable page_refs cannot be null');
  569. }
  570. $this->container['page_refs'] = $page_refs;
  571. return $this;
  572. }
  573. /**
  574. * Gets related_id
  575. *
  576. * @return string[]|null
  577. */
  578. public function getRelatedId()
  579. {
  580. return $this->container['related_id'];
  581. }
  582. /**
  583. * Sets related_id
  584. *
  585. * @param string[]|null $related_id 关联 id
  586. *
  587. * @return self
  588. */
  589. public function setRelatedId($related_id)
  590. {
  591. if (is_null($related_id)) {
  592. throw new \InvalidArgumentException('non-nullable related_id cannot be null');
  593. }
  594. $this->container['related_id'] = $related_id;
  595. return $this;
  596. }
  597. /**
  598. * Gets author
  599. *
  600. * @return string|null
  601. */
  602. public function getAuthor()
  603. {
  604. return $this->container['author'];
  605. }
  606. /**
  607. * Sets author
  608. *
  609. * @param string|null $author 作者或译者
  610. *
  611. * @return self
  612. */
  613. public function setAuthor($author)
  614. {
  615. if (is_null($author)) {
  616. throw new \InvalidArgumentException('non-nullable author cannot be null');
  617. }
  618. $this->container['author'] = $author;
  619. return $this;
  620. }
  621. /**
  622. * Gets channel
  623. *
  624. * @return string|null
  625. */
  626. public function getChannel()
  627. {
  628. return $this->container['channel'];
  629. }
  630. /**
  631. * Sets channel
  632. *
  633. * @param string|null $channel 来源 channel
  634. *
  635. * @return self
  636. */
  637. public function setChannel($channel)
  638. {
  639. if (is_null($channel)) {
  640. throw new \InvalidArgumentException('non-nullable channel cannot be null');
  641. }
  642. $this->container['channel'] = $channel;
  643. return $this;
  644. }
  645. /**
  646. * Gets page
  647. *
  648. * @return int|null
  649. */
  650. public function getPage()
  651. {
  652. return $this->container['page'];
  653. }
  654. /**
  655. * Sets page
  656. *
  657. * @param int|null $page 页码
  658. *
  659. * @return self
  660. */
  661. public function setPage($page)
  662. {
  663. if (is_null($page)) {
  664. throw new \InvalidArgumentException('non-nullable page cannot be null');
  665. }
  666. $this->container['page'] = $page;
  667. return $this;
  668. }
  669. /**
  670. * Gets page_size
  671. *
  672. * @return int|null
  673. */
  674. public function getPageSize()
  675. {
  676. return $this->container['page_size'];
  677. }
  678. /**
  679. * Sets page_size
  680. *
  681. * @param int|null $page_size 每页数量,上限 100
  682. *
  683. * @return self
  684. */
  685. public function setPageSize($page_size)
  686. {
  687. if (is_null($page_size)) {
  688. throw new \InvalidArgumentException('non-nullable page_size cannot be null');
  689. }
  690. $this->container['page_size'] = $page_size;
  691. return $this;
  692. }
  693. /**
  694. * Returns true if offset exists. False otherwise.
  695. *
  696. * @param integer|string $offset Offset
  697. *
  698. * @return boolean
  699. */
  700. public function offsetExists(mixed $offset): bool
  701. {
  702. return isset($this->container[$offset]);
  703. }
  704. /**
  705. * Gets offset.
  706. *
  707. * @param integer|string $offset Offset
  708. *
  709. * @return mixed|null
  710. */
  711. #[\ReturnTypeWillChange]
  712. public function offsetGet(mixed $offset)
  713. {
  714. return $this->container[$offset] ?? null;
  715. }
  716. /**
  717. * Sets value based on offset.
  718. *
  719. * @param int|null $offset Offset
  720. * @param mixed $value Value to be set
  721. *
  722. * @return void
  723. */
  724. public function offsetSet($offset, $value): void
  725. {
  726. if (is_null($offset)) {
  727. $this->container[] = $value;
  728. } else {
  729. $this->container[$offset] = $value;
  730. }
  731. }
  732. /**
  733. * Unsets offset.
  734. *
  735. * @param integer|string $offset Offset
  736. *
  737. * @return void
  738. */
  739. public function offsetUnset(mixed $offset): void
  740. {
  741. unset($this->container[$offset]);
  742. }
  743. /**
  744. * Serializes the object to a value that can be serialized natively by json_encode().
  745. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  746. *
  747. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  748. * of any type other than a resource.
  749. */
  750. #[\ReturnTypeWillChange]
  751. public function jsonSerialize()
  752. {
  753. return ObjectSerializer::sanitizeForSerialization($this);
  754. }
  755. /**
  756. * Gets the string presentation of the object
  757. *
  758. * @return string
  759. */
  760. public function __toString()
  761. {
  762. return json_encode(
  763. ObjectSerializer::sanitizeForSerialization($this),
  764. JSON_PRETTY_PRINT
  765. );
  766. }
  767. /**
  768. * Gets a header-safe presentation of the object
  769. *
  770. * @return string
  771. */
  772. public function toHeaderValue()
  773. {
  774. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  775. }
  776. }