PostApiV3SearchRequest.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  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.11.12
  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. public const SEARCH_MODE_DEFINITION = 'definition';
  283. /**
  284. * Gets allowable values of the enum
  285. *
  286. * @return string[]
  287. */
  288. public function getSearchModeAllowableValues()
  289. {
  290. return [
  291. self::SEARCH_MODE_FUZZY,
  292. self::SEARCH_MODE_EXACT,
  293. self::SEARCH_MODE_SEMANTIC,
  294. self::SEARCH_MODE_HYBRID,
  295. self::SEARCH_MODE_DEFINITION,
  296. ];
  297. }
  298. /**
  299. * Associative array for storing property values
  300. *
  301. * @var mixed[]
  302. */
  303. protected $container = [];
  304. /**
  305. * Constructor
  306. *
  307. * @param mixed[]|null $data Associated array of property values
  308. * initializing the model
  309. */
  310. public function __construct(?array $data = null)
  311. {
  312. $this->setIfExists('q', $data ?? [], null);
  313. $this->setIfExists('search_mode', $data ?? [], 'fuzzy');
  314. $this->setIfExists('resource_type', $data ?? [], null);
  315. $this->setIfExists('granularity', $data ?? [], null);
  316. $this->setIfExists('language', $data ?? [], null);
  317. $this->setIfExists('category', $data ?? [], null);
  318. $this->setIfExists('tags', $data ?? [], null);
  319. $this->setIfExists('page_refs', $data ?? [], null);
  320. $this->setIfExists('related_id', $data ?? [], null);
  321. $this->setIfExists('author', $data ?? [], null);
  322. $this->setIfExists('channel', $data ?? [], null);
  323. $this->setIfExists('page', $data ?? [], 1);
  324. $this->setIfExists('page_size', $data ?? [], 20);
  325. }
  326. /**
  327. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  328. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  329. * $this->openAPINullablesSetToNull array
  330. *
  331. * @param string $variableName
  332. * @param array $fields
  333. * @param mixed $defaultValue
  334. */
  335. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  336. {
  337. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  338. $this->openAPINullablesSetToNull[] = $variableName;
  339. }
  340. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  341. }
  342. /**
  343. * Show all the invalid properties with reasons.
  344. *
  345. * @return array invalid properties with reasons
  346. */
  347. public function listInvalidProperties()
  348. {
  349. $invalidProperties = [];
  350. if ($this->container['q'] === null) {
  351. $invalidProperties[] = "'q' can't be null";
  352. }
  353. $allowedValues = $this->getSearchModeAllowableValues();
  354. if (!is_null($this->container['search_mode']) && !in_array($this->container['search_mode'], $allowedValues, true)) {
  355. $invalidProperties[] = sprintf(
  356. "invalid value '%s' for 'search_mode', must be one of '%s'",
  357. $this->container['search_mode'],
  358. implode("', '", $allowedValues)
  359. );
  360. }
  361. return $invalidProperties;
  362. }
  363. /**
  364. * Validate all the properties in the model
  365. * return true if all passed
  366. *
  367. * @return bool True if all properties are valid
  368. */
  369. public function valid()
  370. {
  371. return count($this->listInvalidProperties()) === 0;
  372. }
  373. /**
  374. * Gets q
  375. *
  376. * @return string
  377. */
  378. public function getQ()
  379. {
  380. return $this->container['q'];
  381. }
  382. /**
  383. * Sets q
  384. *
  385. * @param string $q 搜索关键词
  386. *
  387. * @return self
  388. */
  389. public function setQ($q)
  390. {
  391. if (is_null($q)) {
  392. throw new \InvalidArgumentException('non-nullable q cannot be null');
  393. }
  394. $this->container['q'] = $q;
  395. return $this;
  396. }
  397. /**
  398. * Gets search_mode
  399. *
  400. * @return string|null
  401. */
  402. public function getSearchMode()
  403. {
  404. return $this->container['search_mode'];
  405. }
  406. /**
  407. * Sets search_mode
  408. *
  409. * @param string|null $search_mode 检索模式
  410. *
  411. * @return self
  412. */
  413. public function setSearchMode($search_mode)
  414. {
  415. if (is_null($search_mode)) {
  416. throw new \InvalidArgumentException('non-nullable search_mode cannot be null');
  417. }
  418. $allowedValues = $this->getSearchModeAllowableValues();
  419. if (!in_array($search_mode, $allowedValues, true)) {
  420. throw new \InvalidArgumentException(
  421. sprintf(
  422. "Invalid value '%s' for 'search_mode', must be one of '%s'",
  423. $search_mode,
  424. implode("', '", $allowedValues)
  425. )
  426. );
  427. }
  428. $this->container['search_mode'] = $search_mode;
  429. return $this;
  430. }
  431. /**
  432. * Gets resource_type
  433. *
  434. * @return string|null
  435. */
  436. public function getResourceType()
  437. {
  438. return $this->container['resource_type'];
  439. }
  440. /**
  441. * Sets resource_type
  442. *
  443. * @param string|null $resource_type 资源类型
  444. *
  445. * @return self
  446. */
  447. public function setResourceType($resource_type)
  448. {
  449. if (is_null($resource_type)) {
  450. throw new \InvalidArgumentException('non-nullable resource_type cannot be null');
  451. }
  452. $this->container['resource_type'] = $resource_type;
  453. return $this;
  454. }
  455. /**
  456. * Gets granularity
  457. *
  458. * @return string|null
  459. */
  460. public function getGranularity()
  461. {
  462. return $this->container['granularity'];
  463. }
  464. /**
  465. * Sets granularity
  466. *
  467. * @param string|null $granularity 文档颗粒度
  468. *
  469. * @return self
  470. */
  471. public function setGranularity($granularity)
  472. {
  473. if (is_null($granularity)) {
  474. throw new \InvalidArgumentException('non-nullable granularity cannot be null');
  475. }
  476. $this->container['granularity'] = $granularity;
  477. return $this;
  478. }
  479. /**
  480. * Gets language
  481. *
  482. * @return string|null
  483. */
  484. public function getLanguage()
  485. {
  486. return $this->container['language'];
  487. }
  488. /**
  489. * Sets language
  490. *
  491. * @param string|null $language 语言
  492. *
  493. * @return self
  494. */
  495. public function setLanguage($language)
  496. {
  497. if (is_null($language)) {
  498. throw new \InvalidArgumentException('non-nullable language cannot be null');
  499. }
  500. $this->container['language'] = $language;
  501. return $this;
  502. }
  503. /**
  504. * Gets category
  505. *
  506. * @return string|null
  507. */
  508. public function getCategory()
  509. {
  510. return $this->container['category'];
  511. }
  512. /**
  513. * Sets category
  514. *
  515. * @param string|null $category 文档分类,逗号分隔
  516. *
  517. * @return self
  518. */
  519. public function setCategory($category)
  520. {
  521. if (is_null($category)) {
  522. throw new \InvalidArgumentException('non-nullable category cannot be null');
  523. }
  524. $this->container['category'] = $category;
  525. return $this;
  526. }
  527. /**
  528. * Gets tags
  529. *
  530. * @return string|null
  531. */
  532. public function getTags()
  533. {
  534. return $this->container['tags'];
  535. }
  536. /**
  537. * Sets tags
  538. *
  539. * @param string|null $tags 标签,逗号分隔
  540. *
  541. * @return self
  542. */
  543. public function setTags($tags)
  544. {
  545. if (is_null($tags)) {
  546. throw new \InvalidArgumentException('non-nullable tags cannot be null');
  547. }
  548. $this->container['tags'] = $tags;
  549. return $this;
  550. }
  551. /**
  552. * Gets page_refs
  553. *
  554. * @return string[]|null
  555. */
  556. public function getPageRefs()
  557. {
  558. return $this->container['page_refs'];
  559. }
  560. /**
  561. * Sets page_refs
  562. *
  563. * @param string[]|null $page_refs 页码标记
  564. *
  565. * @return self
  566. */
  567. public function setPageRefs($page_refs)
  568. {
  569. if (is_null($page_refs)) {
  570. throw new \InvalidArgumentException('non-nullable page_refs cannot be null');
  571. }
  572. $this->container['page_refs'] = $page_refs;
  573. return $this;
  574. }
  575. /**
  576. * Gets related_id
  577. *
  578. * @return string[]|null
  579. */
  580. public function getRelatedId()
  581. {
  582. return $this->container['related_id'];
  583. }
  584. /**
  585. * Sets related_id
  586. *
  587. * @param string[]|null $related_id 关联 id
  588. *
  589. * @return self
  590. */
  591. public function setRelatedId($related_id)
  592. {
  593. if (is_null($related_id)) {
  594. throw new \InvalidArgumentException('non-nullable related_id cannot be null');
  595. }
  596. $this->container['related_id'] = $related_id;
  597. return $this;
  598. }
  599. /**
  600. * Gets author
  601. *
  602. * @return string|null
  603. */
  604. public function getAuthor()
  605. {
  606. return $this->container['author'];
  607. }
  608. /**
  609. * Sets author
  610. *
  611. * @param string|null $author 作者或译者
  612. *
  613. * @return self
  614. */
  615. public function setAuthor($author)
  616. {
  617. if (is_null($author)) {
  618. throw new \InvalidArgumentException('non-nullable author cannot be null');
  619. }
  620. $this->container['author'] = $author;
  621. return $this;
  622. }
  623. /**
  624. * Gets channel
  625. *
  626. * @return string|null
  627. */
  628. public function getChannel()
  629. {
  630. return $this->container['channel'];
  631. }
  632. /**
  633. * Sets channel
  634. *
  635. * @param string|null $channel 来源 channel
  636. *
  637. * @return self
  638. */
  639. public function setChannel($channel)
  640. {
  641. if (is_null($channel)) {
  642. throw new \InvalidArgumentException('non-nullable channel cannot be null');
  643. }
  644. $this->container['channel'] = $channel;
  645. return $this;
  646. }
  647. /**
  648. * Gets page
  649. *
  650. * @return int|null
  651. */
  652. public function getPage()
  653. {
  654. return $this->container['page'];
  655. }
  656. /**
  657. * Sets page
  658. *
  659. * @param int|null $page 页码
  660. *
  661. * @return self
  662. */
  663. public function setPage($page)
  664. {
  665. if (is_null($page)) {
  666. throw new \InvalidArgumentException('non-nullable page cannot be null');
  667. }
  668. $this->container['page'] = $page;
  669. return $this;
  670. }
  671. /**
  672. * Gets page_size
  673. *
  674. * @return int|null
  675. */
  676. public function getPageSize()
  677. {
  678. return $this->container['page_size'];
  679. }
  680. /**
  681. * Sets page_size
  682. *
  683. * @param int|null $page_size 每页数量,上限 100
  684. *
  685. * @return self
  686. */
  687. public function setPageSize($page_size)
  688. {
  689. if (is_null($page_size)) {
  690. throw new \InvalidArgumentException('non-nullable page_size cannot be null');
  691. }
  692. $this->container['page_size'] = $page_size;
  693. return $this;
  694. }
  695. /**
  696. * Returns true if offset exists. False otherwise.
  697. *
  698. * @param integer|string $offset Offset
  699. *
  700. * @return boolean
  701. */
  702. public function offsetExists(mixed $offset): bool
  703. {
  704. return isset($this->container[$offset]);
  705. }
  706. /**
  707. * Gets offset.
  708. *
  709. * @param integer|string $offset Offset
  710. *
  711. * @return mixed|null
  712. */
  713. #[\ReturnTypeWillChange]
  714. public function offsetGet(mixed $offset)
  715. {
  716. return $this->container[$offset] ?? null;
  717. }
  718. /**
  719. * Sets value based on offset.
  720. *
  721. * @param int|null $offset Offset
  722. * @param mixed $value Value to be set
  723. *
  724. * @return void
  725. */
  726. public function offsetSet($offset, $value): void
  727. {
  728. if (is_null($offset)) {
  729. $this->container[] = $value;
  730. } else {
  731. $this->container[$offset] = $value;
  732. }
  733. }
  734. /**
  735. * Unsets offset.
  736. *
  737. * @param integer|string $offset Offset
  738. *
  739. * @return void
  740. */
  741. public function offsetUnset(mixed $offset): void
  742. {
  743. unset($this->container[$offset]);
  744. }
  745. /**
  746. * Serializes the object to a value that can be serialized natively by json_encode().
  747. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  748. *
  749. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  750. * of any type other than a resource.
  751. */
  752. #[\ReturnTypeWillChange]
  753. public function jsonSerialize()
  754. {
  755. return ObjectSerializer::sanitizeForSerialization($this);
  756. }
  757. /**
  758. * Gets the string presentation of the object
  759. *
  760. * @return string
  761. */
  762. public function __toString()
  763. {
  764. return json_encode(
  765. ObjectSerializer::sanitizeForSerialization($this),
  766. JSON_PRETTY_PRINT
  767. );
  768. }
  769. /**
  770. * Gets a header-safe presentation of the object
  771. *
  772. * @return string
  773. */
  774. public function toHeaderValue()
  775. {
  776. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  777. }
  778. }