PatchApiV3DiscussionsDiscussionRequest.php 20 KB

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