PostApiV3StudiosStudioChannelsRequest.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. <?php
  2. /**
  3. * PostApiV3StudiosStudioChannelsRequest
  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. * PostApiV3StudiosStudioChannelsRequest 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 PostApiV3StudiosStudioChannelsRequest 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_studios_studio_channels_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. ];
  61. /**
  62. * Array of property to format mappings. Used for (de)serialization
  63. *
  64. * @var string[]
  65. * @phpstan-var array<string, string|null>
  66. * @psalm-var array<string, string|null>
  67. */
  68. protected static $openAPIFormats = [
  69. 'name' => null,
  70. 'type' => null,
  71. 'lang' => null,
  72. 'summary' => null,
  73. 'status' => null,
  74. 'source_type' => null,
  75. 'source_id' => null
  76. ];
  77. /**
  78. * Array of nullable properties. Used for (de)serialization
  79. *
  80. * @var boolean[]
  81. */
  82. protected static array $openAPINullables = [
  83. 'name' => false,
  84. 'type' => false,
  85. 'lang' => false,
  86. 'summary' => false,
  87. 'status' => false,
  88. 'source_type' => false,
  89. 'source_id' => false
  90. ];
  91. /**
  92. * If a nullable field gets set to null, insert it here
  93. *
  94. * @var boolean[]
  95. */
  96. protected array $openAPINullablesSetToNull = [];
  97. /**
  98. * Array of property to type mappings. Used for (de)serialization
  99. *
  100. * @return array
  101. */
  102. public static function openAPITypes()
  103. {
  104. return self::$openAPITypes;
  105. }
  106. /**
  107. * Array of property to format mappings. Used for (de)serialization
  108. *
  109. * @return array
  110. */
  111. public static function openAPIFormats()
  112. {
  113. return self::$openAPIFormats;
  114. }
  115. /**
  116. * Array of nullable properties
  117. *
  118. * @return array
  119. */
  120. protected static function openAPINullables(): array
  121. {
  122. return self::$openAPINullables;
  123. }
  124. /**
  125. * Array of nullable field names deliberately set to null
  126. *
  127. * @return boolean[]
  128. */
  129. private function getOpenAPINullablesSetToNull(): array
  130. {
  131. return $this->openAPINullablesSetToNull;
  132. }
  133. /**
  134. * Setter - Array of nullable field names deliberately set to null
  135. *
  136. * @param boolean[] $openAPINullablesSetToNull
  137. */
  138. private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
  139. {
  140. $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
  141. }
  142. /**
  143. * Checks if a property is nullable
  144. *
  145. * @param string $property
  146. * @return bool
  147. */
  148. public static function isNullable(string $property): bool
  149. {
  150. return self::openAPINullables()[$property] ?? false;
  151. }
  152. /**
  153. * Checks if a nullable property is set to null.
  154. *
  155. * @param string $property
  156. * @return bool
  157. */
  158. public function isNullableSetToNull(string $property): bool
  159. {
  160. return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
  161. }
  162. /**
  163. * Array of attributes where the key is the local name,
  164. * and the value is the original name
  165. *
  166. * @var string[]
  167. */
  168. protected static $attributeMap = [
  169. 'name' => 'name',
  170. 'type' => 'type',
  171. 'lang' => 'lang',
  172. 'summary' => 'summary',
  173. 'status' => 'status',
  174. 'source_type' => 'source_type',
  175. 'source_id' => 'source_id'
  176. ];
  177. /**
  178. * Array of attributes to setter functions (for deserialization of responses)
  179. *
  180. * @var string[]
  181. */
  182. protected static $setters = [
  183. 'name' => 'setName',
  184. 'type' => 'setType',
  185. 'lang' => 'setLang',
  186. 'summary' => 'setSummary',
  187. 'status' => 'setStatus',
  188. 'source_type' => 'setSourceType',
  189. 'source_id' => 'setSourceId'
  190. ];
  191. /**
  192. * Array of attributes to getter functions (for serialization of requests)
  193. *
  194. * @var string[]
  195. */
  196. protected static $getters = [
  197. 'name' => 'getName',
  198. 'type' => 'getType',
  199. 'lang' => 'getLang',
  200. 'summary' => 'getSummary',
  201. 'status' => 'getStatus',
  202. 'source_type' => 'getSourceType',
  203. 'source_id' => 'getSourceId'
  204. ];
  205. /**
  206. * Array of attributes where the key is the local name,
  207. * and the value is the original name
  208. *
  209. * @return array
  210. */
  211. public static function attributeMap()
  212. {
  213. return self::$attributeMap;
  214. }
  215. /**
  216. * Array of attributes to setter functions (for deserialization of responses)
  217. *
  218. * @return array
  219. */
  220. public static function setters()
  221. {
  222. return self::$setters;
  223. }
  224. /**
  225. * Array of attributes to getter functions (for serialization of requests)
  226. *
  227. * @return array
  228. */
  229. public static function getters()
  230. {
  231. return self::$getters;
  232. }
  233. /**
  234. * The original name of the model.
  235. *
  236. * @return string
  237. */
  238. public function getModelName()
  239. {
  240. return self::$openAPIModelName;
  241. }
  242. public const TYPE_TRANSLATION = 'translation';
  243. public const TYPE_NISSAYA = 'nissaya';
  244. public const TYPE_ORIGINAL = 'original';
  245. public const TYPE_WBW = 'wbw';
  246. public const TYPE_COMMENTARY = 'commentary';
  247. public const TYPE_SIMILAR = 'similar';
  248. public const SOURCE_TYPE_ORIGINAL = 'original';
  249. public const SOURCE_TYPE_REPRINT = 'reprint';
  250. public const SOURCE_TYPE_AI = 'ai';
  251. /**
  252. * Gets allowable values of the enum
  253. *
  254. * @return string[]
  255. */
  256. public function getTypeAllowableValues()
  257. {
  258. return [
  259. self::TYPE_TRANSLATION,
  260. self::TYPE_NISSAYA,
  261. self::TYPE_ORIGINAL,
  262. self::TYPE_WBW,
  263. self::TYPE_COMMENTARY,
  264. self::TYPE_SIMILAR,
  265. ];
  266. }
  267. /**
  268. * Gets allowable values of the enum
  269. *
  270. * @return string[]
  271. */
  272. public function getSourceTypeAllowableValues()
  273. {
  274. return [
  275. self::SOURCE_TYPE_ORIGINAL,
  276. self::SOURCE_TYPE_REPRINT,
  277. self::SOURCE_TYPE_AI,
  278. ];
  279. }
  280. /**
  281. * Associative array for storing property values
  282. *
  283. * @var mixed[]
  284. */
  285. protected $container = [];
  286. /**
  287. * Constructor
  288. *
  289. * @param mixed[]|null $data Associated array of property values
  290. * initializing the model
  291. */
  292. public function __construct(?array $data = null)
  293. {
  294. $this->setIfExists('name', $data ?? [], null);
  295. $this->setIfExists('type', $data ?? [], null);
  296. $this->setIfExists('lang', $data ?? [], null);
  297. $this->setIfExists('summary', $data ?? [], null);
  298. $this->setIfExists('status', $data ?? [], 10);
  299. $this->setIfExists('source_type', $data ?? [], null);
  300. $this->setIfExists('source_id', $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. if ($this->container['name'] === null) {
  327. $invalidProperties[] = "'name' can't be null";
  328. }
  329. if ($this->container['type'] === null) {
  330. $invalidProperties[] = "'type' can't be null";
  331. }
  332. $allowedValues = $this->getTypeAllowableValues();
  333. if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) {
  334. $invalidProperties[] = sprintf(
  335. "invalid value '%s' for 'type', must be one of '%s'",
  336. $this->container['type'],
  337. implode("', '", $allowedValues)
  338. );
  339. }
  340. if ($this->container['lang'] === null) {
  341. $invalidProperties[] = "'lang' can't be null";
  342. }
  343. $allowedValues = $this->getSourceTypeAllowableValues();
  344. if (!is_null($this->container['source_type']) && !in_array($this->container['source_type'], $allowedValues, true)) {
  345. $invalidProperties[] = sprintf(
  346. "invalid value '%s' for 'source_type', must be one of '%s'",
  347. $this->container['source_type'],
  348. implode("', '", $allowedValues)
  349. );
  350. }
  351. return $invalidProperties;
  352. }
  353. /**
  354. * Validate all the properties in the model
  355. * return true if all passed
  356. *
  357. * @return bool True if all properties are valid
  358. */
  359. public function valid()
  360. {
  361. return count($this->listInvalidProperties()) === 0;
  362. }
  363. /**
  364. * Gets name
  365. *
  366. * @return string
  367. */
  368. public function getName()
  369. {
  370. return $this->container['name'];
  371. }
  372. /**
  373. * Sets name
  374. *
  375. * @param string $name 名字,最长 128
  376. *
  377. * @return self
  378. */
  379. public function setName($name)
  380. {
  381. if (is_null($name)) {
  382. throw new \InvalidArgumentException('non-nullable name cannot be null');
  383. }
  384. $this->container['name'] = $name;
  385. return $this;
  386. }
  387. /**
  388. * Gets type
  389. *
  390. * @return string
  391. */
  392. public function getType()
  393. {
  394. return $this->container['type'];
  395. }
  396. /**
  397. * Sets type
  398. *
  399. * @param string $type 类型
  400. *
  401. * @return self
  402. */
  403. public function setType($type)
  404. {
  405. if (is_null($type)) {
  406. throw new \InvalidArgumentException('non-nullable type cannot be null');
  407. }
  408. $allowedValues = $this->getTypeAllowableValues();
  409. if (!in_array($type, $allowedValues, true)) {
  410. throw new \InvalidArgumentException(
  411. sprintf(
  412. "Invalid value '%s' for 'type', must be one of '%s'",
  413. $type,
  414. implode("', '", $allowedValues)
  415. )
  416. );
  417. }
  418. $this->container['type'] = $type;
  419. return $this;
  420. }
  421. /**
  422. * Gets lang
  423. *
  424. * @return string
  425. */
  426. public function getLang()
  427. {
  428. return $this->container['lang'];
  429. }
  430. /**
  431. * Sets lang
  432. *
  433. * @param string $lang 语言,最长 16
  434. *
  435. * @return self
  436. */
  437. public function setLang($lang)
  438. {
  439. if (is_null($lang)) {
  440. throw new \InvalidArgumentException('non-nullable lang cannot be null');
  441. }
  442. $this->container['lang'] = $lang;
  443. return $this;
  444. }
  445. /**
  446. * Gets summary
  447. *
  448. * @return string|null
  449. */
  450. public function getSummary()
  451. {
  452. return $this->container['summary'];
  453. }
  454. /**
  455. * Sets summary
  456. *
  457. * @param string|null $summary 简介,最长 1024
  458. *
  459. * @return self
  460. */
  461. public function setSummary($summary)
  462. {
  463. if (is_null($summary)) {
  464. throw new \InvalidArgumentException('non-nullable summary cannot be null');
  465. }
  466. $this->container['summary'] = $summary;
  467. return $this;
  468. }
  469. /**
  470. * Gets status
  471. *
  472. * @return int|null
  473. */
  474. public function getStatus()
  475. {
  476. return $this->container['status'];
  477. }
  478. /**
  479. * Sets status
  480. *
  481. * @param int|null $status 10 私有、20 公开不列出(拿到链接能看,不进任何公开列表)、30 公开
  482. *
  483. * @return self
  484. */
  485. public function setStatus($status)
  486. {
  487. if (is_null($status)) {
  488. throw new \InvalidArgumentException('non-nullable status cannot be null');
  489. }
  490. $this->container['status'] = $status;
  491. return $this;
  492. }
  493. /**
  494. * Gets source_type
  495. *
  496. * @return string|null
  497. */
  498. public function getSourceType()
  499. {
  500. return $this->container['source_type'];
  501. }
  502. /**
  503. * Sets source_type
  504. *
  505. * @param string|null $source_type 来源
  506. *
  507. * @return self
  508. */
  509. public function setSourceType($source_type)
  510. {
  511. if (is_null($source_type)) {
  512. throw new \InvalidArgumentException('non-nullable source_type cannot be null');
  513. }
  514. $allowedValues = $this->getSourceTypeAllowableValues();
  515. if (!in_array($source_type, $allowedValues, true)) {
  516. throw new \InvalidArgumentException(
  517. sprintf(
  518. "Invalid value '%s' for 'source_type', must be one of '%s'",
  519. $source_type,
  520. implode("', '", $allowedValues)
  521. )
  522. );
  523. }
  524. $this->container['source_type'] = $source_type;
  525. return $this;
  526. }
  527. /**
  528. * Gets source_id
  529. *
  530. * @return string|null
  531. */
  532. public function getSourceId()
  533. {
  534. return $this->container['source_id'];
  535. }
  536. /**
  537. * Sets source_id
  538. *
  539. * @param string|null $source_id 来源 id
  540. *
  541. * @return self
  542. */
  543. public function setSourceId($source_id)
  544. {
  545. if (is_null($source_id)) {
  546. throw new \InvalidArgumentException('non-nullable source_id cannot be null');
  547. }
  548. $this->container['source_id'] = $source_id;
  549. return $this;
  550. }
  551. /**
  552. * Returns true if offset exists. False otherwise.
  553. *
  554. * @param integer|string $offset Offset
  555. *
  556. * @return boolean
  557. */
  558. public function offsetExists(mixed $offset): bool
  559. {
  560. return isset($this->container[$offset]);
  561. }
  562. /**
  563. * Gets offset.
  564. *
  565. * @param integer|string $offset Offset
  566. *
  567. * @return mixed|null
  568. */
  569. #[\ReturnTypeWillChange]
  570. public function offsetGet(mixed $offset)
  571. {
  572. return $this->container[$offset] ?? null;
  573. }
  574. /**
  575. * Sets value based on offset.
  576. *
  577. * @param int|null $offset Offset
  578. * @param mixed $value Value to be set
  579. *
  580. * @return void
  581. */
  582. public function offsetSet($offset, $value): void
  583. {
  584. if (is_null($offset)) {
  585. $this->container[] = $value;
  586. } else {
  587. $this->container[$offset] = $value;
  588. }
  589. }
  590. /**
  591. * Unsets offset.
  592. *
  593. * @param integer|string $offset Offset
  594. *
  595. * @return void
  596. */
  597. public function offsetUnset(mixed $offset): void
  598. {
  599. unset($this->container[$offset]);
  600. }
  601. /**
  602. * Serializes the object to a value that can be serialized natively by json_encode().
  603. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  604. *
  605. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  606. * of any type other than a resource.
  607. */
  608. #[\ReturnTypeWillChange]
  609. public function jsonSerialize()
  610. {
  611. return ObjectSerializer::sanitizeForSerialization($this);
  612. }
  613. /**
  614. * Gets the string presentation of the object
  615. *
  616. * @return string
  617. */
  618. public function __toString()
  619. {
  620. return json_encode(
  621. ObjectSerializer::sanitizeForSerialization($this),
  622. JSON_PRETTY_PRINT
  623. );
  624. }
  625. /**
  626. * Gets a header-safe presentation of the object
  627. *
  628. * @return string
  629. */
  630. public function toHeaderValue()
  631. {
  632. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  633. }
  634. }