2
0

PatchApiV3ChannelsChannelRequest.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. <?php
  2. /**
  3. * PatchApiV3ChannelsChannelRequest
  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: 1.0.0
  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. * PatchApiV3ChannelsChannelRequest 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 PatchApiV3ChannelsChannelRequest 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_channels_channel__request';
  47. /**
  48. * Array of property to type mappings. Used for (de)serialization
  49. *
  50. * @var string[]
  51. */
  52. protected static $openAPITypes = [
  53. 'name' => 'string',
  54. 'type' => 'string',
  55. 'lang' => 'string',
  56. 'summary' => 'string',
  57. 'status' => 'int',
  58. 'source_type' => 'string',
  59. 'source_id' => 'string',
  60. 'config' => 'object'
  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. 'name' => null,
  71. 'type' => null,
  72. 'lang' => null,
  73. 'summary' => null,
  74. 'status' => null,
  75. 'source_type' => null,
  76. 'source_id' => null,
  77. 'config' => null
  78. ];
  79. /**
  80. * Array of nullable properties. Used for (de)serialization
  81. *
  82. * @var boolean[]
  83. */
  84. protected static array $openAPINullables = [
  85. 'name' => false,
  86. 'type' => false,
  87. 'lang' => false,
  88. 'summary' => false,
  89. 'status' => false,
  90. 'source_type' => false,
  91. 'source_id' => false,
  92. 'config' => 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. 'name' => 'name',
  173. 'type' => 'type',
  174. 'lang' => 'lang',
  175. 'summary' => 'summary',
  176. 'status' => 'status',
  177. 'source_type' => 'source_type',
  178. 'source_id' => 'source_id',
  179. 'config' => 'config'
  180. ];
  181. /**
  182. * Array of attributes to setter functions (for deserialization of responses)
  183. *
  184. * @var string[]
  185. */
  186. protected static $setters = [
  187. 'name' => 'setName',
  188. 'type' => 'setType',
  189. 'lang' => 'setLang',
  190. 'summary' => 'setSummary',
  191. 'status' => 'setStatus',
  192. 'source_type' => 'setSourceType',
  193. 'source_id' => 'setSourceId',
  194. 'config' => 'setConfig'
  195. ];
  196. /**
  197. * Array of attributes to getter functions (for serialization of requests)
  198. *
  199. * @var string[]
  200. */
  201. protected static $getters = [
  202. 'name' => 'getName',
  203. 'type' => 'getType',
  204. 'lang' => 'getLang',
  205. 'summary' => 'getSummary',
  206. 'status' => 'getStatus',
  207. 'source_type' => 'getSourceType',
  208. 'source_id' => 'getSourceId',
  209. 'config' => 'getConfig'
  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 TYPE_TRANSLATION = 'translation';
  249. public const TYPE_NISSAYA = 'nissaya';
  250. public const TYPE_ORIGINAL = 'original';
  251. public const TYPE_WBW = 'wbw';
  252. public const TYPE_COMMENTARY = 'commentary';
  253. public const TYPE_SIMILAR = 'similar';
  254. public const SOURCE_TYPE_ORIGINAL = 'original';
  255. public const SOURCE_TYPE_REPRINT = 'reprint';
  256. public const SOURCE_TYPE_AI = 'ai';
  257. /**
  258. * Gets allowable values of the enum
  259. *
  260. * @return string[]
  261. */
  262. public function getTypeAllowableValues()
  263. {
  264. return [
  265. self::TYPE_TRANSLATION,
  266. self::TYPE_NISSAYA,
  267. self::TYPE_ORIGINAL,
  268. self::TYPE_WBW,
  269. self::TYPE_COMMENTARY,
  270. self::TYPE_SIMILAR,
  271. ];
  272. }
  273. /**
  274. * Gets allowable values of the enum
  275. *
  276. * @return string[]
  277. */
  278. public function getSourceTypeAllowableValues()
  279. {
  280. return [
  281. self::SOURCE_TYPE_ORIGINAL,
  282. self::SOURCE_TYPE_REPRINT,
  283. self::SOURCE_TYPE_AI,
  284. ];
  285. }
  286. /**
  287. * Associative array for storing property values
  288. *
  289. * @var mixed[]
  290. */
  291. protected $container = [];
  292. /**
  293. * Constructor
  294. *
  295. * @param mixed[]|null $data Associated array of property values
  296. * initializing the model
  297. */
  298. public function __construct(?array $data = null)
  299. {
  300. $this->setIfExists('name', $data ?? [], null);
  301. $this->setIfExists('type', $data ?? [], null);
  302. $this->setIfExists('lang', $data ?? [], null);
  303. $this->setIfExists('summary', $data ?? [], null);
  304. $this->setIfExists('status', $data ?? [], null);
  305. $this->setIfExists('source_type', $data ?? [], null);
  306. $this->setIfExists('source_id', $data ?? [], null);
  307. $this->setIfExists('config', $data ?? [], null);
  308. }
  309. /**
  310. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  311. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  312. * $this->openAPINullablesSetToNull array
  313. *
  314. * @param string $variableName
  315. * @param array $fields
  316. * @param mixed $defaultValue
  317. */
  318. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  319. {
  320. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  321. $this->openAPINullablesSetToNull[] = $variableName;
  322. }
  323. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  324. }
  325. /**
  326. * Show all the invalid properties with reasons.
  327. *
  328. * @return array invalid properties with reasons
  329. */
  330. public function listInvalidProperties()
  331. {
  332. $invalidProperties = [];
  333. $allowedValues = $this->getTypeAllowableValues();
  334. if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) {
  335. $invalidProperties[] = sprintf(
  336. "invalid value '%s' for 'type', must be one of '%s'",
  337. $this->container['type'],
  338. implode("', '", $allowedValues)
  339. );
  340. }
  341. $allowedValues = $this->getSourceTypeAllowableValues();
  342. if (!is_null($this->container['source_type']) && !in_array($this->container['source_type'], $allowedValues, true)) {
  343. $invalidProperties[] = sprintf(
  344. "invalid value '%s' for 'source_type', must be one of '%s'",
  345. $this->container['source_type'],
  346. implode("', '", $allowedValues)
  347. );
  348. }
  349. return $invalidProperties;
  350. }
  351. /**
  352. * Validate all the properties in the model
  353. * return true if all passed
  354. *
  355. * @return bool True if all properties are valid
  356. */
  357. public function valid()
  358. {
  359. return count($this->listInvalidProperties()) === 0;
  360. }
  361. /**
  362. * Gets name
  363. *
  364. * @return string|null
  365. */
  366. public function getName()
  367. {
  368. return $this->container['name'];
  369. }
  370. /**
  371. * Sets name
  372. *
  373. * @param string|null $name 名字,最长 128;同一 studio 内不能重名
  374. *
  375. * @return self
  376. */
  377. public function setName($name)
  378. {
  379. if (is_null($name)) {
  380. throw new \InvalidArgumentException('non-nullable name cannot be null');
  381. }
  382. $this->container['name'] = $name;
  383. return $this;
  384. }
  385. /**
  386. * Gets type
  387. *
  388. * @return string|null
  389. */
  390. public function getType()
  391. {
  392. return $this->container['type'];
  393. }
  394. /**
  395. * Sets type
  396. *
  397. * @param string|null $type 类型
  398. *
  399. * @return self
  400. */
  401. public function setType($type)
  402. {
  403. if (is_null($type)) {
  404. throw new \InvalidArgumentException('non-nullable type cannot be null');
  405. }
  406. $allowedValues = $this->getTypeAllowableValues();
  407. if (!in_array($type, $allowedValues, true)) {
  408. throw new \InvalidArgumentException(
  409. sprintf(
  410. "Invalid value '%s' for 'type', must be one of '%s'",
  411. $type,
  412. implode("', '", $allowedValues)
  413. )
  414. );
  415. }
  416. $this->container['type'] = $type;
  417. return $this;
  418. }
  419. /**
  420. * Gets lang
  421. *
  422. * @return string|null
  423. */
  424. public function getLang()
  425. {
  426. return $this->container['lang'];
  427. }
  428. /**
  429. * Sets lang
  430. *
  431. * @param string|null $lang 语言,最长 16
  432. *
  433. * @return self
  434. */
  435. public function setLang($lang)
  436. {
  437. if (is_null($lang)) {
  438. throw new \InvalidArgumentException('non-nullable lang cannot be null');
  439. }
  440. $this->container['lang'] = $lang;
  441. return $this;
  442. }
  443. /**
  444. * Gets summary
  445. *
  446. * @return string|null
  447. */
  448. public function getSummary()
  449. {
  450. return $this->container['summary'];
  451. }
  452. /**
  453. * Sets summary
  454. *
  455. * @param string|null $summary 简介,最长 1024
  456. *
  457. * @return self
  458. */
  459. public function setSummary($summary)
  460. {
  461. if (is_null($summary)) {
  462. throw new \InvalidArgumentException('non-nullable summary cannot be null');
  463. }
  464. $this->container['summary'] = $summary;
  465. return $this;
  466. }
  467. /**
  468. * Gets status
  469. *
  470. * @return int|null
  471. */
  472. public function getStatus()
  473. {
  474. return $this->container['status'];
  475. }
  476. /**
  477. * Sets status
  478. *
  479. * @param int|null $status 10 私有、20 公开不列出(拿到链接能看,不进任何公开列表)、30 公开
  480. *
  481. * @return self
  482. */
  483. public function setStatus($status)
  484. {
  485. if (is_null($status)) {
  486. throw new \InvalidArgumentException('non-nullable status cannot be null');
  487. }
  488. $this->container['status'] = $status;
  489. return $this;
  490. }
  491. /**
  492. * Gets source_type
  493. *
  494. * @return string|null
  495. */
  496. public function getSourceType()
  497. {
  498. return $this->container['source_type'];
  499. }
  500. /**
  501. * Sets source_type
  502. *
  503. * @param string|null $source_type 来源
  504. *
  505. * @return self
  506. */
  507. public function setSourceType($source_type)
  508. {
  509. if (is_null($source_type)) {
  510. throw new \InvalidArgumentException('non-nullable source_type cannot be null');
  511. }
  512. $allowedValues = $this->getSourceTypeAllowableValues();
  513. if (!in_array($source_type, $allowedValues, true)) {
  514. throw new \InvalidArgumentException(
  515. sprintf(
  516. "Invalid value '%s' for 'source_type', must be one of '%s'",
  517. $source_type,
  518. implode("', '", $allowedValues)
  519. )
  520. );
  521. }
  522. $this->container['source_type'] = $source_type;
  523. return $this;
  524. }
  525. /**
  526. * Gets source_id
  527. *
  528. * @return string|null
  529. */
  530. public function getSourceId()
  531. {
  532. return $this->container['source_id'];
  533. }
  534. /**
  535. * Sets source_id
  536. *
  537. * @param string|null $source_id 来源 id
  538. *
  539. * @return self
  540. */
  541. public function setSourceId($source_id)
  542. {
  543. if (is_null($source_id)) {
  544. throw new \InvalidArgumentException('non-nullable source_id cannot be null');
  545. }
  546. $this->container['source_id'] = $source_id;
  547. return $this;
  548. }
  549. /**
  550. * Gets config
  551. *
  552. * @return object|null
  553. */
  554. public function getConfig()
  555. {
  556. return $this->container['config'];
  557. }
  558. /**
  559. * Sets config
  560. *
  561. * @param object|null $config 配置
  562. *
  563. * @return self
  564. */
  565. public function setConfig($config)
  566. {
  567. if (is_null($config)) {
  568. throw new \InvalidArgumentException('non-nullable config cannot be null');
  569. }
  570. $this->container['config'] = $config;
  571. return $this;
  572. }
  573. /**
  574. * Returns true if offset exists. False otherwise.
  575. *
  576. * @param integer|string $offset Offset
  577. *
  578. * @return boolean
  579. */
  580. public function offsetExists(mixed $offset): bool
  581. {
  582. return isset($this->container[$offset]);
  583. }
  584. /**
  585. * Gets offset.
  586. *
  587. * @param integer|string $offset Offset
  588. *
  589. * @return mixed|null
  590. */
  591. #[\ReturnTypeWillChange]
  592. public function offsetGet(mixed $offset)
  593. {
  594. return $this->container[$offset] ?? null;
  595. }
  596. /**
  597. * Sets value based on offset.
  598. *
  599. * @param int|null $offset Offset
  600. * @param mixed $value Value to be set
  601. *
  602. * @return void
  603. */
  604. public function offsetSet($offset, $value): void
  605. {
  606. if (is_null($offset)) {
  607. $this->container[] = $value;
  608. } else {
  609. $this->container[$offset] = $value;
  610. }
  611. }
  612. /**
  613. * Unsets offset.
  614. *
  615. * @param integer|string $offset Offset
  616. *
  617. * @return void
  618. */
  619. public function offsetUnset(mixed $offset): void
  620. {
  621. unset($this->container[$offset]);
  622. }
  623. /**
  624. * Serializes the object to a value that can be serialized natively by json_encode().
  625. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  626. *
  627. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  628. * of any type other than a resource.
  629. */
  630. #[\ReturnTypeWillChange]
  631. public function jsonSerialize()
  632. {
  633. return ObjectSerializer::sanitizeForSerialization($this);
  634. }
  635. /**
  636. * Gets the string presentation of the object
  637. *
  638. * @return string
  639. */
  640. public function __toString()
  641. {
  642. return json_encode(
  643. ObjectSerializer::sanitizeForSerialization($this),
  644. JSON_PRETTY_PRINT
  645. );
  646. }
  647. /**
  648. * Gets a header-safe presentation of the object
  649. *
  650. * @return string
  651. */
  652. public function toHeaderValue()
  653. {
  654. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  655. }
  656. }