PostApiV3ChannelsChannelTermsRequest.php 20 KB

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