PostApiV3MeReactionsRequest.php 15 KB

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