PatchApiV3DiscussionsDiscussionRequest.php 21 KB

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