PostApiV3DiscussionsRequest.php 19 KB

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