PostApiV3TipitakaExportsRequest.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. <?php
  2. /**
  3. * PostApiV3TipitakaExportsRequest
  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. * PostApiV3TipitakaExportsRequest 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 PostApiV3TipitakaExportsRequest 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_tipitaka_exports_request';
  47. /**
  48. * Array of property to type mappings. Used for (de)serialization
  49. *
  50. * @var string[]
  51. */
  52. protected static $openAPITypes = [
  53. 'channel' => 'string',
  54. 'work' => 'int',
  55. 'book' => 'int',
  56. 'para' => 'int',
  57. 'category' => 'int',
  58. 'format' => 'string'
  59. ];
  60. /**
  61. * Array of property to format mappings. Used for (de)serialization
  62. *
  63. * @var string[]
  64. * @phpstan-var array<string, string|null>
  65. * @psalm-var array<string, string|null>
  66. */
  67. protected static $openAPIFormats = [
  68. 'channel' => null,
  69. 'work' => null,
  70. 'book' => null,
  71. 'para' => null,
  72. 'category' => null,
  73. 'format' => null
  74. ];
  75. /**
  76. * Array of nullable properties. Used for (de)serialization
  77. *
  78. * @var boolean[]
  79. */
  80. protected static array $openAPINullables = [
  81. 'channel' => false,
  82. 'work' => false,
  83. 'book' => false,
  84. 'para' => false,
  85. 'category' => false,
  86. 'format' => false
  87. ];
  88. /**
  89. * If a nullable field gets set to null, insert it here
  90. *
  91. * @var boolean[]
  92. */
  93. protected array $openAPINullablesSetToNull = [];
  94. /**
  95. * Array of property to type mappings. Used for (de)serialization
  96. *
  97. * @return array
  98. */
  99. public static function openAPITypes()
  100. {
  101. return self::$openAPITypes;
  102. }
  103. /**
  104. * Array of property to format mappings. Used for (de)serialization
  105. *
  106. * @return array
  107. */
  108. public static function openAPIFormats()
  109. {
  110. return self::$openAPIFormats;
  111. }
  112. /**
  113. * Array of nullable properties
  114. *
  115. * @return array
  116. */
  117. protected static function openAPINullables(): array
  118. {
  119. return self::$openAPINullables;
  120. }
  121. /**
  122. * Array of nullable field names deliberately set to null
  123. *
  124. * @return boolean[]
  125. */
  126. private function getOpenAPINullablesSetToNull(): array
  127. {
  128. return $this->openAPINullablesSetToNull;
  129. }
  130. /**
  131. * Setter - Array of nullable field names deliberately set to null
  132. *
  133. * @param boolean[] $openAPINullablesSetToNull
  134. */
  135. private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
  136. {
  137. $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
  138. }
  139. /**
  140. * Checks if a property is nullable
  141. *
  142. * @param string $property
  143. * @return bool
  144. */
  145. public static function isNullable(string $property): bool
  146. {
  147. return self::openAPINullables()[$property] ?? false;
  148. }
  149. /**
  150. * Checks if a nullable property is set to null.
  151. *
  152. * @param string $property
  153. * @return bool
  154. */
  155. public function isNullableSetToNull(string $property): bool
  156. {
  157. return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
  158. }
  159. /**
  160. * Array of attributes where the key is the local name,
  161. * and the value is the original name
  162. *
  163. * @var string[]
  164. */
  165. protected static $attributeMap = [
  166. 'channel' => 'channel',
  167. 'work' => 'work',
  168. 'book' => 'book',
  169. 'para' => 'para',
  170. 'category' => 'category',
  171. 'format' => 'format'
  172. ];
  173. /**
  174. * Array of attributes to setter functions (for deserialization of responses)
  175. *
  176. * @var string[]
  177. */
  178. protected static $setters = [
  179. 'channel' => 'setChannel',
  180. 'work' => 'setWork',
  181. 'book' => 'setBook',
  182. 'para' => 'setPara',
  183. 'category' => 'setCategory',
  184. 'format' => 'setFormat'
  185. ];
  186. /**
  187. * Array of attributes to getter functions (for serialization of requests)
  188. *
  189. * @var string[]
  190. */
  191. protected static $getters = [
  192. 'channel' => 'getChannel',
  193. 'work' => 'getWork',
  194. 'book' => 'getBook',
  195. 'para' => 'getPara',
  196. 'category' => 'getCategory',
  197. 'format' => 'getFormat'
  198. ];
  199. /**
  200. * Array of attributes where the key is the local name,
  201. * and the value is the original name
  202. *
  203. * @return array
  204. */
  205. public static function attributeMap()
  206. {
  207. return self::$attributeMap;
  208. }
  209. /**
  210. * Array of attributes to setter functions (for deserialization of responses)
  211. *
  212. * @return array
  213. */
  214. public static function setters()
  215. {
  216. return self::$setters;
  217. }
  218. /**
  219. * Array of attributes to getter functions (for serialization of requests)
  220. *
  221. * @return array
  222. */
  223. public static function getters()
  224. {
  225. return self::$getters;
  226. }
  227. /**
  228. * The original name of the model.
  229. *
  230. * @return string
  231. */
  232. public function getModelName()
  233. {
  234. return self::$openAPIModelName;
  235. }
  236. public const FORMAT_HTML = 'html';
  237. public const FORMAT_MARKDOWN = 'markdown';
  238. public const FORMAT_EPUB = 'epub';
  239. public const FORMAT_DOCX = 'docx';
  240. public const FORMAT_OFFLINE = 'offline';
  241. /**
  242. * Gets allowable values of the enum
  243. *
  244. * @return string[]
  245. */
  246. public function getFormatAllowableValues()
  247. {
  248. return [
  249. self::FORMAT_HTML,
  250. self::FORMAT_MARKDOWN,
  251. self::FORMAT_EPUB,
  252. self::FORMAT_DOCX,
  253. self::FORMAT_OFFLINE,
  254. ];
  255. }
  256. /**
  257. * Associative array for storing property values
  258. *
  259. * @var mixed[]
  260. */
  261. protected $container = [];
  262. /**
  263. * Constructor
  264. *
  265. * @param mixed[]|null $data Associated array of property values
  266. * initializing the model
  267. */
  268. public function __construct(?array $data = null)
  269. {
  270. $this->setIfExists('channel', $data ?? [], null);
  271. $this->setIfExists('work', $data ?? [], null);
  272. $this->setIfExists('book', $data ?? [], null);
  273. $this->setIfExists('para', $data ?? [], null);
  274. $this->setIfExists('category', $data ?? [], null);
  275. $this->setIfExists('format', $data ?? [], null);
  276. }
  277. /**
  278. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  279. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  280. * $this->openAPINullablesSetToNull array
  281. *
  282. * @param string $variableName
  283. * @param array $fields
  284. * @param mixed $defaultValue
  285. */
  286. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  287. {
  288. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  289. $this->openAPINullablesSetToNull[] = $variableName;
  290. }
  291. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  292. }
  293. /**
  294. * Show all the invalid properties with reasons.
  295. *
  296. * @return array invalid properties with reasons
  297. */
  298. public function listInvalidProperties()
  299. {
  300. $invalidProperties = [];
  301. if ($this->container['channel'] === null) {
  302. $invalidProperties[] = "'channel' can't be null";
  303. }
  304. if ($this->container['format'] === null) {
  305. $invalidProperties[] = "'format' can't be null";
  306. }
  307. $allowedValues = $this->getFormatAllowableValues();
  308. if (!is_null($this->container['format']) && !in_array($this->container['format'], $allowedValues, true)) {
  309. $invalidProperties[] = sprintf(
  310. "invalid value '%s' for 'format', must be one of '%s'",
  311. $this->container['format'],
  312. implode("', '", $allowedValues)
  313. );
  314. }
  315. return $invalidProperties;
  316. }
  317. /**
  318. * Validate all the properties in the model
  319. * return true if all passed
  320. *
  321. * @return bool True if all properties are valid
  322. */
  323. public function valid()
  324. {
  325. return count($this->listInvalidProperties()) === 0;
  326. }
  327. /**
  328. * Gets channel
  329. *
  330. * @return string
  331. */
  332. public function getChannel()
  333. {
  334. return $this->container['channel'];
  335. }
  336. /**
  337. * Sets channel
  338. *
  339. * @param string $channel channel uid
  340. *
  341. * @return self
  342. */
  343. public function setChannel($channel)
  344. {
  345. if (is_null($channel)) {
  346. throw new \InvalidArgumentException('non-nullable channel cannot be null');
  347. }
  348. $this->container['channel'] = $channel;
  349. return $this;
  350. }
  351. /**
  352. * Gets work
  353. *
  354. * @return int|null
  355. */
  356. public function getWork()
  357. {
  358. return $this->container['work'];
  359. }
  360. /**
  361. * Sets work
  362. *
  363. * @param int|null $work 作品(library 作品页 URL 里的 sn)。作品、category 只能给一个,都不给 = 整个 channel
  364. *
  365. * @return self
  366. */
  367. public function setWork($work)
  368. {
  369. if (is_null($work)) {
  370. throw new \InvalidArgumentException('non-nullable work cannot be null');
  371. }
  372. $this->container['work'] = $work;
  373. return $this;
  374. }
  375. /**
  376. * Gets book
  377. *
  378. * @return int|null
  379. */
  380. public function getBook()
  381. {
  382. return $this->container['book'];
  383. }
  384. /**
  385. * Sets book
  386. *
  387. * @param int|null $book 用坐标指定作品:book + para 所在的那部作品(mobile 用,它不知道 sn)。与 para 同时给
  388. *
  389. * @return self
  390. */
  391. public function setBook($book)
  392. {
  393. if (is_null($book)) {
  394. throw new \InvalidArgumentException('non-nullable book cannot be null');
  395. }
  396. $this->container['book'] = $book;
  397. return $this;
  398. }
  399. /**
  400. * Gets para
  401. *
  402. * @return int|null
  403. */
  404. public function getPara()
  405. {
  406. return $this->container['para'];
  407. }
  408. /**
  409. * Sets para
  410. *
  411. * @param int|null $para 与 book 同时给,作品里的任一段落号(通常是作品起始段)
  412. *
  413. * @return self
  414. */
  415. public function setPara($para)
  416. {
  417. if (is_null($para)) {
  418. throw new \InvalidArgumentException('non-nullable para cannot be null');
  419. }
  420. $this->container['para'] = $para;
  421. return $this;
  422. }
  423. /**
  424. * Gets category
  425. *
  426. * @return int|null
  427. */
  428. public function getCategory()
  429. {
  430. return $this->container['category'];
  431. }
  432. /**
  433. * Sets category
  434. *
  435. * @param int|null $category 分类 id(library 分类页 URL 里的 id),含后代分类
  436. *
  437. * @return self
  438. */
  439. public function setCategory($category)
  440. {
  441. if (is_null($category)) {
  442. throw new \InvalidArgumentException('non-nullable category cannot be null');
  443. }
  444. $this->container['category'] = $category;
  445. return $this;
  446. }
  447. /**
  448. * Gets format
  449. *
  450. * @return string
  451. */
  452. public function getFormat()
  453. {
  454. return $this->container['format'];
  455. }
  456. /**
  457. * Sets format
  458. *
  459. * @param string $format 文件格式
  460. *
  461. * @return self
  462. */
  463. public function setFormat($format)
  464. {
  465. if (is_null($format)) {
  466. throw new \InvalidArgumentException('non-nullable format cannot be null');
  467. }
  468. $allowedValues = $this->getFormatAllowableValues();
  469. if (!in_array($format, $allowedValues, true)) {
  470. throw new \InvalidArgumentException(
  471. sprintf(
  472. "Invalid value '%s' for 'format', must be one of '%s'",
  473. $format,
  474. implode("', '", $allowedValues)
  475. )
  476. );
  477. }
  478. $this->container['format'] = $format;
  479. return $this;
  480. }
  481. /**
  482. * Returns true if offset exists. False otherwise.
  483. *
  484. * @param integer|string $offset Offset
  485. *
  486. * @return boolean
  487. */
  488. public function offsetExists(mixed $offset): bool
  489. {
  490. return isset($this->container[$offset]);
  491. }
  492. /**
  493. * Gets offset.
  494. *
  495. * @param integer|string $offset Offset
  496. *
  497. * @return mixed|null
  498. */
  499. #[\ReturnTypeWillChange]
  500. public function offsetGet(mixed $offset)
  501. {
  502. return $this->container[$offset] ?? null;
  503. }
  504. /**
  505. * Sets value based on offset.
  506. *
  507. * @param int|null $offset Offset
  508. * @param mixed $value Value to be set
  509. *
  510. * @return void
  511. */
  512. public function offsetSet($offset, $value): void
  513. {
  514. if (is_null($offset)) {
  515. $this->container[] = $value;
  516. } else {
  517. $this->container[$offset] = $value;
  518. }
  519. }
  520. /**
  521. * Unsets offset.
  522. *
  523. * @param integer|string $offset Offset
  524. *
  525. * @return void
  526. */
  527. public function offsetUnset(mixed $offset): void
  528. {
  529. unset($this->container[$offset]);
  530. }
  531. /**
  532. * Serializes the object to a value that can be serialized natively by json_encode().
  533. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  534. *
  535. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  536. * of any type other than a resource.
  537. */
  538. #[\ReturnTypeWillChange]
  539. public function jsonSerialize()
  540. {
  541. return ObjectSerializer::sanitizeForSerialization($this);
  542. }
  543. /**
  544. * Gets the string presentation of the object
  545. *
  546. * @return string
  547. */
  548. public function __toString()
  549. {
  550. return json_encode(
  551. ObjectSerializer::sanitizeForSerialization($this),
  552. JSON_PRETTY_PRINT
  553. );
  554. }
  555. /**
  556. * Gets a header-safe presentation of the object
  557. *
  558. * @return string
  559. */
  560. public function toHeaderValue()
  561. {
  562. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  563. }
  564. }