PatchApiV3DiscussionsDiscussionRequest.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831
  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.15
  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_NOTE = 'note';
  267. public const TYPE_COMMENTARY = 'commentary';
  268. public const SEVERITY_ERROR = 'error';
  269. public const SEVERITY_WARNING = 'warning';
  270. public const SEVERITY_INFO = 'info';
  271. public const SEVERITY_URGENT = 'urgent';
  272. public const SEVERITY_NORMAL = 'normal';
  273. /**
  274. * Gets allowable values of the enum
  275. *
  276. * @return string[]
  277. */
  278. public function getStatusAllowableValues()
  279. {
  280. return [
  281. self::STATUS_ACTIVE,
  282. self::STATUS_CLOSE,
  283. ];
  284. }
  285. /**
  286. * Gets allowable values of the enum
  287. *
  288. * @return string[]
  289. */
  290. public function getTypeAllowableValues()
  291. {
  292. return [
  293. self::TYPE_DISCUSSION,
  294. self::TYPE_QA,
  295. self::TYPE_HELP,
  296. self::TYPE_ISSUE,
  297. self::TYPE_NOTE,
  298. self::TYPE_COMMENTARY,
  299. ];
  300. }
  301. /**
  302. * Gets allowable values of the enum
  303. *
  304. * @return string[]
  305. */
  306. public function getSeverityAllowableValues()
  307. {
  308. return [
  309. self::SEVERITY_ERROR,
  310. self::SEVERITY_WARNING,
  311. self::SEVERITY_INFO,
  312. self::SEVERITY_URGENT,
  313. self::SEVERITY_NORMAL,
  314. ];
  315. }
  316. /**
  317. * Associative array for storing property values
  318. *
  319. * @var mixed[]
  320. */
  321. protected $container = [];
  322. /**
  323. * Constructor
  324. *
  325. * @param mixed[]|null $data Associated array of property values
  326. * initializing the model
  327. */
  328. public function __construct(?array $data = null)
  329. {
  330. $this->setIfExists('title', $data ?? [], null);
  331. $this->setIfExists('content', $data ?? [], null);
  332. $this->setIfExists('status', $data ?? [], null);
  333. $this->setIfExists('type', $data ?? [], null);
  334. $this->setIfExists('severity', $data ?? [], null);
  335. $this->setIfExists('pos_start', $data ?? [], null);
  336. $this->setIfExists('pos_end', $data ?? [], null);
  337. $this->setIfExists('quote_exact', $data ?? [], null);
  338. $this->setIfExists('quote_prefix', $data ?? [], null);
  339. $this->setIfExists('quote_suffix', $data ?? [], null);
  340. }
  341. /**
  342. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  343. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  344. * $this->openAPINullablesSetToNull array
  345. *
  346. * @param string $variableName
  347. * @param array $fields
  348. * @param mixed $defaultValue
  349. */
  350. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  351. {
  352. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  353. $this->openAPINullablesSetToNull[] = $variableName;
  354. }
  355. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  356. }
  357. /**
  358. * Show all the invalid properties with reasons.
  359. *
  360. * @return array invalid properties with reasons
  361. */
  362. public function listInvalidProperties()
  363. {
  364. $invalidProperties = [];
  365. $allowedValues = $this->getStatusAllowableValues();
  366. if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) {
  367. $invalidProperties[] = sprintf(
  368. "invalid value '%s' for 'status', must be one of '%s'",
  369. $this->container['status'],
  370. implode("', '", $allowedValues)
  371. );
  372. }
  373. $allowedValues = $this->getTypeAllowableValues();
  374. if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) {
  375. $invalidProperties[] = sprintf(
  376. "invalid value '%s' for 'type', must be one of '%s'",
  377. $this->container['type'],
  378. implode("', '", $allowedValues)
  379. );
  380. }
  381. $allowedValues = $this->getSeverityAllowableValues();
  382. if (!is_null($this->container['severity']) && !in_array($this->container['severity'], $allowedValues, true)) {
  383. $invalidProperties[] = sprintf(
  384. "invalid value '%s' for 'severity', must be one of '%s'",
  385. $this->container['severity'],
  386. implode("', '", $allowedValues)
  387. );
  388. }
  389. return $invalidProperties;
  390. }
  391. /**
  392. * Validate all the properties in the model
  393. * return true if all passed
  394. *
  395. * @return bool True if all properties are valid
  396. */
  397. public function valid()
  398. {
  399. return count($this->listInvalidProperties()) === 0;
  400. }
  401. /**
  402. * Gets title
  403. *
  404. * @return string|null
  405. */
  406. public function getTitle()
  407. {
  408. return $this->container['title'];
  409. }
  410. /**
  411. * Sets title
  412. *
  413. * @param string|null $title 标题(只限话题)
  414. *
  415. * @return self
  416. */
  417. public function setTitle($title)
  418. {
  419. if (is_null($title)) {
  420. throw new \InvalidArgumentException('non-nullable title cannot be null');
  421. }
  422. $this->container['title'] = $title;
  423. return $this;
  424. }
  425. /**
  426. * Gets content
  427. *
  428. * @return string|null
  429. */
  430. public function getContent()
  431. {
  432. return $this->container['content'];
  433. }
  434. /**
  435. * Sets content
  436. *
  437. * @param string|null $content 正文(markdown)
  438. *
  439. * @return self
  440. */
  441. public function setContent($content)
  442. {
  443. if (is_null($content)) {
  444. throw new \InvalidArgumentException('non-nullable content cannot be null');
  445. }
  446. $this->container['content'] = $content;
  447. return $this;
  448. }
  449. /**
  450. * Gets status
  451. *
  452. * @return string|null
  453. */
  454. public function getStatus()
  455. {
  456. return $this->container['status'];
  457. }
  458. /**
  459. * Sets status
  460. *
  461. * @param string|null $status 状态(只限话题)
  462. *
  463. * @return self
  464. */
  465. public function setStatus($status)
  466. {
  467. if (is_null($status)) {
  468. throw new \InvalidArgumentException('non-nullable status cannot be null');
  469. }
  470. $allowedValues = $this->getStatusAllowableValues();
  471. if (!in_array($status, $allowedValues, true)) {
  472. throw new \InvalidArgumentException(
  473. sprintf(
  474. "Invalid value '%s' for 'status', must be one of '%s'",
  475. $status,
  476. implode("', '", $allowedValues)
  477. )
  478. );
  479. }
  480. $this->container['status'] = $status;
  481. return $this;
  482. }
  483. /**
  484. * Gets type
  485. *
  486. * @return string|null
  487. */
  488. public function getType()
  489. {
  490. return $this->container['type'];
  491. }
  492. /**
  493. * Sets type
  494. *
  495. * @param string|null $type 类型(只限话题;评论线程与批注不能互转)
  496. *
  497. * @return self
  498. */
  499. public function setType($type)
  500. {
  501. if (is_null($type)) {
  502. throw new \InvalidArgumentException('non-nullable type cannot be null');
  503. }
  504. $allowedValues = $this->getTypeAllowableValues();
  505. if (!in_array($type, $allowedValues, true)) {
  506. throw new \InvalidArgumentException(
  507. sprintf(
  508. "Invalid value '%s' for 'type', must be one of '%s'",
  509. $type,
  510. implode("', '", $allowedValues)
  511. )
  512. );
  513. }
  514. $this->container['type'] = $type;
  515. return $this;
  516. }
  517. /**
  518. * Gets severity
  519. *
  520. * @return string|null
  521. */
  522. public function getSeverity()
  523. {
  524. return $this->container['severity'];
  525. }
  526. /**
  527. * Sets severity
  528. *
  529. * @param string|null $severity 严重程度(只限话题),null 表示清空
  530. *
  531. * @return self
  532. */
  533. public function setSeverity($severity)
  534. {
  535. if (is_null($severity)) {
  536. throw new \InvalidArgumentException('non-nullable severity cannot be null');
  537. }
  538. $allowedValues = $this->getSeverityAllowableValues();
  539. if (!in_array($severity, $allowedValues, true)) {
  540. throw new \InvalidArgumentException(
  541. sprintf(
  542. "Invalid value '%s' for 'severity', must be one of '%s'",
  543. $severity,
  544. implode("', '", $allowedValues)
  545. )
  546. );
  547. }
  548. $this->container['severity'] = $severity;
  549. return $this;
  550. }
  551. /**
  552. * Gets pos_start
  553. *
  554. * @return int|null
  555. */
  556. public function getPosStart()
  557. {
  558. return $this->container['pos_start'];
  559. }
  560. /**
  561. * Sets pos_start
  562. *
  563. * @param int|null $pos_start 锚点起始偏移(只限批注)
  564. *
  565. * @return self
  566. */
  567. public function setPosStart($pos_start)
  568. {
  569. if (is_null($pos_start)) {
  570. throw new \InvalidArgumentException('non-nullable pos_start cannot be null');
  571. }
  572. $this->container['pos_start'] = $pos_start;
  573. return $this;
  574. }
  575. /**
  576. * Gets pos_end
  577. *
  578. * @return int|null
  579. */
  580. public function getPosEnd()
  581. {
  582. return $this->container['pos_end'];
  583. }
  584. /**
  585. * Sets pos_end
  586. *
  587. * @param int|null $pos_end 锚点结束偏移(只限批注)
  588. *
  589. * @return self
  590. */
  591. public function setPosEnd($pos_end)
  592. {
  593. if (is_null($pos_end)) {
  594. throw new \InvalidArgumentException('non-nullable pos_end cannot be null');
  595. }
  596. $this->container['pos_end'] = $pos_end;
  597. return $this;
  598. }
  599. /**
  600. * Gets quote_exact
  601. *
  602. * @return string|null
  603. */
  604. public function getQuoteExact()
  605. {
  606. return $this->container['quote_exact'];
  607. }
  608. /**
  609. * Sets quote_exact
  610. *
  611. * @param string|null $quote_exact 锚定的原文片段(只限批注)
  612. *
  613. * @return self
  614. */
  615. public function setQuoteExact($quote_exact)
  616. {
  617. if (is_null($quote_exact)) {
  618. throw new \InvalidArgumentException('non-nullable quote_exact cannot be null');
  619. }
  620. $this->container['quote_exact'] = $quote_exact;
  621. return $this;
  622. }
  623. /**
  624. * Gets quote_prefix
  625. *
  626. * @return string|null
  627. */
  628. public function getQuotePrefix()
  629. {
  630. return $this->container['quote_prefix'];
  631. }
  632. /**
  633. * Sets quote_prefix
  634. *
  635. * @param string|null $quote_prefix 锚定片段前的上下文(只限批注)
  636. *
  637. * @return self
  638. */
  639. public function setQuotePrefix($quote_prefix)
  640. {
  641. if (is_null($quote_prefix)) {
  642. throw new \InvalidArgumentException('non-nullable quote_prefix cannot be null');
  643. }
  644. $this->container['quote_prefix'] = $quote_prefix;
  645. return $this;
  646. }
  647. /**
  648. * Gets quote_suffix
  649. *
  650. * @return string|null
  651. */
  652. public function getQuoteSuffix()
  653. {
  654. return $this->container['quote_suffix'];
  655. }
  656. /**
  657. * Sets quote_suffix
  658. *
  659. * @param string|null $quote_suffix 锚定片段后的上下文(只限批注)
  660. *
  661. * @return self
  662. */
  663. public function setQuoteSuffix($quote_suffix)
  664. {
  665. if (is_null($quote_suffix)) {
  666. throw new \InvalidArgumentException('non-nullable quote_suffix cannot be null');
  667. }
  668. $this->container['quote_suffix'] = $quote_suffix;
  669. return $this;
  670. }
  671. /**
  672. * Returns true if offset exists. False otherwise.
  673. *
  674. * @param integer|string $offset Offset
  675. *
  676. * @return boolean
  677. */
  678. public function offsetExists(mixed $offset): bool
  679. {
  680. return isset($this->container[$offset]);
  681. }
  682. /**
  683. * Gets offset.
  684. *
  685. * @param integer|string $offset Offset
  686. *
  687. * @return mixed|null
  688. */
  689. #[\ReturnTypeWillChange]
  690. public function offsetGet(mixed $offset)
  691. {
  692. return $this->container[$offset] ?? null;
  693. }
  694. /**
  695. * Sets value based on offset.
  696. *
  697. * @param int|null $offset Offset
  698. * @param mixed $value Value to be set
  699. *
  700. * @return void
  701. */
  702. public function offsetSet($offset, $value): void
  703. {
  704. if (is_null($offset)) {
  705. $this->container[] = $value;
  706. } else {
  707. $this->container[$offset] = $value;
  708. }
  709. }
  710. /**
  711. * Unsets offset.
  712. *
  713. * @param integer|string $offset Offset
  714. *
  715. * @return void
  716. */
  717. public function offsetUnset(mixed $offset): void
  718. {
  719. unset($this->container[$offset]);
  720. }
  721. /**
  722. * Serializes the object to a value that can be serialized natively by json_encode().
  723. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  724. *
  725. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  726. * of any type other than a resource.
  727. */
  728. #[\ReturnTypeWillChange]
  729. public function jsonSerialize()
  730. {
  731. return ObjectSerializer::sanitizeForSerialization($this);
  732. }
  733. /**
  734. * Gets the string presentation of the object
  735. *
  736. * @return string
  737. */
  738. public function __toString()
  739. {
  740. return json_encode(
  741. ObjectSerializer::sanitizeForSerialization($this),
  742. JSON_PRETTY_PRINT
  743. );
  744. }
  745. /**
  746. * Gets a header-safe presentation of the object
  747. *
  748. * @return string
  749. */
  750. public function toHeaderValue()
  751. {
  752. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  753. }
  754. }