PatchApiV3DiscussionsDiscussionRequest.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  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. ];
  59. /**
  60. * Array of property to format mappings. Used for (de)serialization
  61. *
  62. * @var string[]
  63. * @phpstan-var array<string, string|null>
  64. * @psalm-var array<string, string|null>
  65. */
  66. protected static $openAPIFormats = [
  67. 'title' => null,
  68. 'content' => null,
  69. 'status' => null,
  70. 'type' => null,
  71. 'severity' => null
  72. ];
  73. /**
  74. * Array of nullable properties. Used for (de)serialization
  75. *
  76. * @var boolean[]
  77. */
  78. protected static array $openAPINullables = [
  79. 'title' => false,
  80. 'content' => false,
  81. 'status' => false,
  82. 'type' => false,
  83. 'severity' => false
  84. ];
  85. /**
  86. * If a nullable field gets set to null, insert it here
  87. *
  88. * @var boolean[]
  89. */
  90. protected array $openAPINullablesSetToNull = [];
  91. /**
  92. * Array of property to type mappings. Used for (de)serialization
  93. *
  94. * @return array
  95. */
  96. public static function openAPITypes()
  97. {
  98. return self::$openAPITypes;
  99. }
  100. /**
  101. * Array of property to format mappings. Used for (de)serialization
  102. *
  103. * @return array
  104. */
  105. public static function openAPIFormats()
  106. {
  107. return self::$openAPIFormats;
  108. }
  109. /**
  110. * Array of nullable properties
  111. *
  112. * @return array
  113. */
  114. protected static function openAPINullables(): array
  115. {
  116. return self::$openAPINullables;
  117. }
  118. /**
  119. * Array of nullable field names deliberately set to null
  120. *
  121. * @return boolean[]
  122. */
  123. private function getOpenAPINullablesSetToNull(): array
  124. {
  125. return $this->openAPINullablesSetToNull;
  126. }
  127. /**
  128. * Setter - Array of nullable field names deliberately set to null
  129. *
  130. * @param boolean[] $openAPINullablesSetToNull
  131. */
  132. private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
  133. {
  134. $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
  135. }
  136. /**
  137. * Checks if a property is nullable
  138. *
  139. * @param string $property
  140. * @return bool
  141. */
  142. public static function isNullable(string $property): bool
  143. {
  144. return self::openAPINullables()[$property] ?? false;
  145. }
  146. /**
  147. * Checks if a nullable property is set to null.
  148. *
  149. * @param string $property
  150. * @return bool
  151. */
  152. public function isNullableSetToNull(string $property): bool
  153. {
  154. return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
  155. }
  156. /**
  157. * Array of attributes where the key is the local name,
  158. * and the value is the original name
  159. *
  160. * @var string[]
  161. */
  162. protected static $attributeMap = [
  163. 'title' => 'title',
  164. 'content' => 'content',
  165. 'status' => 'status',
  166. 'type' => 'type',
  167. 'severity' => 'severity'
  168. ];
  169. /**
  170. * Array of attributes to setter functions (for deserialization of responses)
  171. *
  172. * @var string[]
  173. */
  174. protected static $setters = [
  175. 'title' => 'setTitle',
  176. 'content' => 'setContent',
  177. 'status' => 'setStatus',
  178. 'type' => 'setType',
  179. 'severity' => 'setSeverity'
  180. ];
  181. /**
  182. * Array of attributes to getter functions (for serialization of requests)
  183. *
  184. * @var string[]
  185. */
  186. protected static $getters = [
  187. 'title' => 'getTitle',
  188. 'content' => 'getContent',
  189. 'status' => 'getStatus',
  190. 'type' => 'getType',
  191. 'severity' => 'getSeverity'
  192. ];
  193. /**
  194. * Array of attributes where the key is the local name,
  195. * and the value is the original name
  196. *
  197. * @return array
  198. */
  199. public static function attributeMap()
  200. {
  201. return self::$attributeMap;
  202. }
  203. /**
  204. * Array of attributes to setter functions (for deserialization of responses)
  205. *
  206. * @return array
  207. */
  208. public static function setters()
  209. {
  210. return self::$setters;
  211. }
  212. /**
  213. * Array of attributes to getter functions (for serialization of requests)
  214. *
  215. * @return array
  216. */
  217. public static function getters()
  218. {
  219. return self::$getters;
  220. }
  221. /**
  222. * The original name of the model.
  223. *
  224. * @return string
  225. */
  226. public function getModelName()
  227. {
  228. return self::$openAPIModelName;
  229. }
  230. public const STATUS_ACTIVE = 'active';
  231. public const STATUS_CLOSE = 'close';
  232. public const TYPE_DISCUSSION = 'discussion';
  233. public const TYPE_QA = 'qa';
  234. public const TYPE_HELP = 'help';
  235. public const TYPE_ISSUE = 'issue';
  236. public const SEVERITY_ERROR = 'error';
  237. public const SEVERITY_WARNING = 'warning';
  238. public const SEVERITY_INFO = 'info';
  239. public const SEVERITY_URGENT = 'urgent';
  240. public const SEVERITY_NORMAL = 'normal';
  241. /**
  242. * Gets allowable values of the enum
  243. *
  244. * @return string[]
  245. */
  246. public function getStatusAllowableValues()
  247. {
  248. return [
  249. self::STATUS_ACTIVE,
  250. self::STATUS_CLOSE,
  251. ];
  252. }
  253. /**
  254. * Gets allowable values of the enum
  255. *
  256. * @return string[]
  257. */
  258. public function getTypeAllowableValues()
  259. {
  260. return [
  261. self::TYPE_DISCUSSION,
  262. self::TYPE_QA,
  263. self::TYPE_HELP,
  264. self::TYPE_ISSUE,
  265. ];
  266. }
  267. /**
  268. * Gets allowable values of the enum
  269. *
  270. * @return string[]
  271. */
  272. public function getSeverityAllowableValues()
  273. {
  274. return [
  275. self::SEVERITY_ERROR,
  276. self::SEVERITY_WARNING,
  277. self::SEVERITY_INFO,
  278. self::SEVERITY_URGENT,
  279. self::SEVERITY_NORMAL,
  280. ];
  281. }
  282. /**
  283. * Associative array for storing property values
  284. *
  285. * @var mixed[]
  286. */
  287. protected $container = [];
  288. /**
  289. * Constructor
  290. *
  291. * @param mixed[]|null $data Associated array of property values
  292. * initializing the model
  293. */
  294. public function __construct(?array $data = null)
  295. {
  296. $this->setIfExists('title', $data ?? [], null);
  297. $this->setIfExists('content', $data ?? [], null);
  298. $this->setIfExists('status', $data ?? [], null);
  299. $this->setIfExists('type', $data ?? [], null);
  300. $this->setIfExists('severity', $data ?? [], null);
  301. }
  302. /**
  303. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  304. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  305. * $this->openAPINullablesSetToNull array
  306. *
  307. * @param string $variableName
  308. * @param array $fields
  309. * @param mixed $defaultValue
  310. */
  311. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  312. {
  313. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  314. $this->openAPINullablesSetToNull[] = $variableName;
  315. }
  316. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  317. }
  318. /**
  319. * Show all the invalid properties with reasons.
  320. *
  321. * @return array invalid properties with reasons
  322. */
  323. public function listInvalidProperties()
  324. {
  325. $invalidProperties = [];
  326. $allowedValues = $this->getStatusAllowableValues();
  327. if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) {
  328. $invalidProperties[] = sprintf(
  329. "invalid value '%s' for 'status', must be one of '%s'",
  330. $this->container['status'],
  331. implode("', '", $allowedValues)
  332. );
  333. }
  334. $allowedValues = $this->getTypeAllowableValues();
  335. if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) {
  336. $invalidProperties[] = sprintf(
  337. "invalid value '%s' for 'type', must be one of '%s'",
  338. $this->container['type'],
  339. implode("', '", $allowedValues)
  340. );
  341. }
  342. $allowedValues = $this->getSeverityAllowableValues();
  343. if (!is_null($this->container['severity']) && !in_array($this->container['severity'], $allowedValues, true)) {
  344. $invalidProperties[] = sprintf(
  345. "invalid value '%s' for 'severity', must be one of '%s'",
  346. $this->container['severity'],
  347. implode("', '", $allowedValues)
  348. );
  349. }
  350. return $invalidProperties;
  351. }
  352. /**
  353. * Validate all the properties in the model
  354. * return true if all passed
  355. *
  356. * @return bool True if all properties are valid
  357. */
  358. public function valid()
  359. {
  360. return count($this->listInvalidProperties()) === 0;
  361. }
  362. /**
  363. * Gets title
  364. *
  365. * @return string|null
  366. */
  367. public function getTitle()
  368. {
  369. return $this->container['title'];
  370. }
  371. /**
  372. * Sets title
  373. *
  374. * @param string|null $title 标题(只限话题)
  375. *
  376. * @return self
  377. */
  378. public function setTitle($title)
  379. {
  380. if (is_null($title)) {
  381. throw new \InvalidArgumentException('non-nullable title cannot be null');
  382. }
  383. $this->container['title'] = $title;
  384. return $this;
  385. }
  386. /**
  387. * Gets content
  388. *
  389. * @return string|null
  390. */
  391. public function getContent()
  392. {
  393. return $this->container['content'];
  394. }
  395. /**
  396. * Sets content
  397. *
  398. * @param string|null $content 正文(markdown)
  399. *
  400. * @return self
  401. */
  402. public function setContent($content)
  403. {
  404. if (is_null($content)) {
  405. throw new \InvalidArgumentException('non-nullable content cannot be null');
  406. }
  407. $this->container['content'] = $content;
  408. return $this;
  409. }
  410. /**
  411. * Gets status
  412. *
  413. * @return string|null
  414. */
  415. public function getStatus()
  416. {
  417. return $this->container['status'];
  418. }
  419. /**
  420. * Sets status
  421. *
  422. * @param string|null $status 状态(只限话题)
  423. *
  424. * @return self
  425. */
  426. public function setStatus($status)
  427. {
  428. if (is_null($status)) {
  429. throw new \InvalidArgumentException('non-nullable status cannot be null');
  430. }
  431. $allowedValues = $this->getStatusAllowableValues();
  432. if (!in_array($status, $allowedValues, true)) {
  433. throw new \InvalidArgumentException(
  434. sprintf(
  435. "Invalid value '%s' for 'status', must be one of '%s'",
  436. $status,
  437. implode("', '", $allowedValues)
  438. )
  439. );
  440. }
  441. $this->container['status'] = $status;
  442. return $this;
  443. }
  444. /**
  445. * Gets type
  446. *
  447. * @return string|null
  448. */
  449. public function getType()
  450. {
  451. return $this->container['type'];
  452. }
  453. /**
  454. * Sets type
  455. *
  456. * @param string|null $type 话题类型(只限话题)
  457. *
  458. * @return self
  459. */
  460. public function setType($type)
  461. {
  462. if (is_null($type)) {
  463. throw new \InvalidArgumentException('non-nullable type cannot be null');
  464. }
  465. $allowedValues = $this->getTypeAllowableValues();
  466. if (!in_array($type, $allowedValues, true)) {
  467. throw new \InvalidArgumentException(
  468. sprintf(
  469. "Invalid value '%s' for 'type', must be one of '%s'",
  470. $type,
  471. implode("', '", $allowedValues)
  472. )
  473. );
  474. }
  475. $this->container['type'] = $type;
  476. return $this;
  477. }
  478. /**
  479. * Gets severity
  480. *
  481. * @return string|null
  482. */
  483. public function getSeverity()
  484. {
  485. return $this->container['severity'];
  486. }
  487. /**
  488. * Sets severity
  489. *
  490. * @param string|null $severity 严重程度(只限话题),null 表示清空
  491. *
  492. * @return self
  493. */
  494. public function setSeverity($severity)
  495. {
  496. if (is_null($severity)) {
  497. throw new \InvalidArgumentException('non-nullable severity cannot be null');
  498. }
  499. $allowedValues = $this->getSeverityAllowableValues();
  500. if (!in_array($severity, $allowedValues, true)) {
  501. throw new \InvalidArgumentException(
  502. sprintf(
  503. "Invalid value '%s' for 'severity', must be one of '%s'",
  504. $severity,
  505. implode("', '", $allowedValues)
  506. )
  507. );
  508. }
  509. $this->container['severity'] = $severity;
  510. return $this;
  511. }
  512. /**
  513. * Returns true if offset exists. False otherwise.
  514. *
  515. * @param integer|string $offset Offset
  516. *
  517. * @return boolean
  518. */
  519. public function offsetExists(mixed $offset): bool
  520. {
  521. return isset($this->container[$offset]);
  522. }
  523. /**
  524. * Gets offset.
  525. *
  526. * @param integer|string $offset Offset
  527. *
  528. * @return mixed|null
  529. */
  530. #[\ReturnTypeWillChange]
  531. public function offsetGet(mixed $offset)
  532. {
  533. return $this->container[$offset] ?? null;
  534. }
  535. /**
  536. * Sets value based on offset.
  537. *
  538. * @param int|null $offset Offset
  539. * @param mixed $value Value to be set
  540. *
  541. * @return void
  542. */
  543. public function offsetSet($offset, $value): void
  544. {
  545. if (is_null($offset)) {
  546. $this->container[] = $value;
  547. } else {
  548. $this->container[$offset] = $value;
  549. }
  550. }
  551. /**
  552. * Unsets offset.
  553. *
  554. * @param integer|string $offset Offset
  555. *
  556. * @return void
  557. */
  558. public function offsetUnset(mixed $offset): void
  559. {
  560. unset($this->container[$offset]);
  561. }
  562. /**
  563. * Serializes the object to a value that can be serialized natively by json_encode().
  564. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  565. *
  566. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  567. * of any type other than a resource.
  568. */
  569. #[\ReturnTypeWillChange]
  570. public function jsonSerialize()
  571. {
  572. return ObjectSerializer::sanitizeForSerialization($this);
  573. }
  574. /**
  575. * Gets the string presentation of the object
  576. *
  577. * @return string
  578. */
  579. public function __toString()
  580. {
  581. return json_encode(
  582. ObjectSerializer::sanitizeForSerialization($this),
  583. JSON_PRETTY_PRINT
  584. );
  585. }
  586. /**
  587. * Gets a header-safe presentation of the object
  588. *
  589. * @return string
  590. */
  591. public function toHeaderValue()
  592. {
  593. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  594. }
  595. }