GetApiV3AdminCreditAccounts200ResponseDataInner.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. <?php
  2. /**
  3. * GetApiV3AdminCreditAccounts200ResponseDataInner
  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. * GetApiV3AdminCreditAccounts200ResponseDataInner 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 GetApiV3AdminCreditAccounts200ResponseDataInner 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 = 'get_api_v3_admin_credit_accounts_200_response_data_inner';
  47. /**
  48. * Array of property to type mappings. Used for (de)serialization
  49. *
  50. * @var string[]
  51. */
  52. protected static $openAPITypes = [
  53. 'account_type' => 'string',
  54. 'account_id' => 'string',
  55. 'user' => '\WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser',
  56. 'earned_balance' => 'int',
  57. 'earned_total' => 'int',
  58. 'adjusted_total' => 'int',
  59. 'spent_total' => 'int',
  60. 'free_used_today' => 'int',
  61. 'daily_free' => 'int',
  62. 'last_activity_at' => 'string'
  63. ];
  64. /**
  65. * Array of property to format mappings. Used for (de)serialization
  66. *
  67. * @var string[]
  68. * @phpstan-var array<string, string|null>
  69. * @psalm-var array<string, string|null>
  70. */
  71. protected static $openAPIFormats = [
  72. 'account_type' => null,
  73. 'account_id' => null,
  74. 'user' => null,
  75. 'earned_balance' => null,
  76. 'earned_total' => null,
  77. 'adjusted_total' => null,
  78. 'spent_total' => null,
  79. 'free_used_today' => null,
  80. 'daily_free' => null,
  81. 'last_activity_at' => null
  82. ];
  83. /**
  84. * Array of nullable properties. Used for (de)serialization
  85. *
  86. * @var boolean[]
  87. */
  88. protected static array $openAPINullables = [
  89. 'account_type' => false,
  90. 'account_id' => false,
  91. 'user' => true,
  92. 'earned_balance' => false,
  93. 'earned_total' => false,
  94. 'adjusted_total' => false,
  95. 'spent_total' => false,
  96. 'free_used_today' => false,
  97. 'daily_free' => false,
  98. 'last_activity_at' => true
  99. ];
  100. /**
  101. * If a nullable field gets set to null, insert it here
  102. *
  103. * @var boolean[]
  104. */
  105. protected array $openAPINullablesSetToNull = [];
  106. /**
  107. * Array of property to type mappings. Used for (de)serialization
  108. *
  109. * @return array
  110. */
  111. public static function openAPITypes()
  112. {
  113. return self::$openAPITypes;
  114. }
  115. /**
  116. * Array of property to format mappings. Used for (de)serialization
  117. *
  118. * @return array
  119. */
  120. public static function openAPIFormats()
  121. {
  122. return self::$openAPIFormats;
  123. }
  124. /**
  125. * Array of nullable properties
  126. *
  127. * @return array
  128. */
  129. protected static function openAPINullables(): array
  130. {
  131. return self::$openAPINullables;
  132. }
  133. /**
  134. * Array of nullable field names deliberately set to null
  135. *
  136. * @return boolean[]
  137. */
  138. private function getOpenAPINullablesSetToNull(): array
  139. {
  140. return $this->openAPINullablesSetToNull;
  141. }
  142. /**
  143. * Setter - Array of nullable field names deliberately set to null
  144. *
  145. * @param boolean[] $openAPINullablesSetToNull
  146. */
  147. private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
  148. {
  149. $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
  150. }
  151. /**
  152. * Checks if a property is nullable
  153. *
  154. * @param string $property
  155. * @return bool
  156. */
  157. public static function isNullable(string $property): bool
  158. {
  159. return self::openAPINullables()[$property] ?? false;
  160. }
  161. /**
  162. * Checks if a nullable property is set to null.
  163. *
  164. * @param string $property
  165. * @return bool
  166. */
  167. public function isNullableSetToNull(string $property): bool
  168. {
  169. return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
  170. }
  171. /**
  172. * Array of attributes where the key is the local name,
  173. * and the value is the original name
  174. *
  175. * @var string[]
  176. */
  177. protected static $attributeMap = [
  178. 'account_type' => 'account_type',
  179. 'account_id' => 'account_id',
  180. 'user' => 'user',
  181. 'earned_balance' => 'earned_balance',
  182. 'earned_total' => 'earned_total',
  183. 'adjusted_total' => 'adjusted_total',
  184. 'spent_total' => 'spent_total',
  185. 'free_used_today' => 'free_used_today',
  186. 'daily_free' => 'daily_free',
  187. 'last_activity_at' => 'last_activity_at'
  188. ];
  189. /**
  190. * Array of attributes to setter functions (for deserialization of responses)
  191. *
  192. * @var string[]
  193. */
  194. protected static $setters = [
  195. 'account_type' => 'setAccountType',
  196. 'account_id' => 'setAccountId',
  197. 'user' => 'setUser',
  198. 'earned_balance' => 'setEarnedBalance',
  199. 'earned_total' => 'setEarnedTotal',
  200. 'adjusted_total' => 'setAdjustedTotal',
  201. 'spent_total' => 'setSpentTotal',
  202. 'free_used_today' => 'setFreeUsedToday',
  203. 'daily_free' => 'setDailyFree',
  204. 'last_activity_at' => 'setLastActivityAt'
  205. ];
  206. /**
  207. * Array of attributes to getter functions (for serialization of requests)
  208. *
  209. * @var string[]
  210. */
  211. protected static $getters = [
  212. 'account_type' => 'getAccountType',
  213. 'account_id' => 'getAccountId',
  214. 'user' => 'getUser',
  215. 'earned_balance' => 'getEarnedBalance',
  216. 'earned_total' => 'getEarnedTotal',
  217. 'adjusted_total' => 'getAdjustedTotal',
  218. 'spent_total' => 'getSpentTotal',
  219. 'free_used_today' => 'getFreeUsedToday',
  220. 'daily_free' => 'getDailyFree',
  221. 'last_activity_at' => 'getLastActivityAt'
  222. ];
  223. /**
  224. * Array of attributes where the key is the local name,
  225. * and the value is the original name
  226. *
  227. * @return array
  228. */
  229. public static function attributeMap()
  230. {
  231. return self::$attributeMap;
  232. }
  233. /**
  234. * Array of attributes to setter functions (for deserialization of responses)
  235. *
  236. * @return array
  237. */
  238. public static function setters()
  239. {
  240. return self::$setters;
  241. }
  242. /**
  243. * Array of attributes to getter functions (for serialization of requests)
  244. *
  245. * @return array
  246. */
  247. public static function getters()
  248. {
  249. return self::$getters;
  250. }
  251. /**
  252. * The original name of the model.
  253. *
  254. * @return string
  255. */
  256. public function getModelName()
  257. {
  258. return self::$openAPIModelName;
  259. }
  260. public const ACCOUNT_TYPE_USER = 'user';
  261. public const ACCOUNT_TYPE_GUEST = 'guest';
  262. /**
  263. * Gets allowable values of the enum
  264. *
  265. * @return string[]
  266. */
  267. public function getAccountTypeAllowableValues()
  268. {
  269. return [
  270. self::ACCOUNT_TYPE_USER,
  271. self::ACCOUNT_TYPE_GUEST,
  272. ];
  273. }
  274. /**
  275. * Associative array for storing property values
  276. *
  277. * @var mixed[]
  278. */
  279. protected $container = [];
  280. /**
  281. * Constructor
  282. *
  283. * @param mixed[]|null $data Associated array of property values
  284. * initializing the model
  285. */
  286. public function __construct(?array $data = null)
  287. {
  288. $this->setIfExists('account_type', $data ?? [], null);
  289. $this->setIfExists('account_id', $data ?? [], null);
  290. $this->setIfExists('user', $data ?? [], null);
  291. $this->setIfExists('earned_balance', $data ?? [], null);
  292. $this->setIfExists('earned_total', $data ?? [], null);
  293. $this->setIfExists('adjusted_total', $data ?? [], null);
  294. $this->setIfExists('spent_total', $data ?? [], null);
  295. $this->setIfExists('free_used_today', $data ?? [], null);
  296. $this->setIfExists('daily_free', $data ?? [], null);
  297. $this->setIfExists('last_activity_at', $data ?? [], null);
  298. }
  299. /**
  300. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  301. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  302. * $this->openAPINullablesSetToNull array
  303. *
  304. * @param string $variableName
  305. * @param array $fields
  306. * @param mixed $defaultValue
  307. */
  308. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  309. {
  310. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  311. $this->openAPINullablesSetToNull[] = $variableName;
  312. }
  313. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  314. }
  315. /**
  316. * Show all the invalid properties with reasons.
  317. *
  318. * @return array invalid properties with reasons
  319. */
  320. public function listInvalidProperties()
  321. {
  322. $invalidProperties = [];
  323. $allowedValues = $this->getAccountTypeAllowableValues();
  324. if (!is_null($this->container['account_type']) && !in_array($this->container['account_type'], $allowedValues, true)) {
  325. $invalidProperties[] = sprintf(
  326. "invalid value '%s' for 'account_type', must be one of '%s'",
  327. $this->container['account_type'],
  328. implode("', '", $allowedValues)
  329. );
  330. }
  331. return $invalidProperties;
  332. }
  333. /**
  334. * Validate all the properties in the model
  335. * return true if all passed
  336. *
  337. * @return bool True if all properties are valid
  338. */
  339. public function valid()
  340. {
  341. return count($this->listInvalidProperties()) === 0;
  342. }
  343. /**
  344. * Gets account_type
  345. *
  346. * @return string|null
  347. */
  348. public function getAccountType()
  349. {
  350. return $this->container['account_type'];
  351. }
  352. /**
  353. * Sets account_type
  354. *
  355. * @param string|null $account_type account_type
  356. *
  357. * @return self
  358. */
  359. public function setAccountType($account_type)
  360. {
  361. if (is_null($account_type)) {
  362. throw new \InvalidArgumentException('non-nullable account_type cannot be null');
  363. }
  364. $allowedValues = $this->getAccountTypeAllowableValues();
  365. if (!in_array($account_type, $allowedValues, true)) {
  366. throw new \InvalidArgumentException(
  367. sprintf(
  368. "Invalid value '%s' for 'account_type', must be one of '%s'",
  369. $account_type,
  370. implode("', '", $allowedValues)
  371. )
  372. );
  373. }
  374. $this->container['account_type'] = $account_type;
  375. return $this;
  376. }
  377. /**
  378. * Gets account_id
  379. *
  380. * @return string|null
  381. */
  382. public function getAccountId()
  383. {
  384. return $this->container['account_id'];
  385. }
  386. /**
  387. * Sets account_id
  388. *
  389. * @param string|null $account_id account_id
  390. *
  391. * @return self
  392. */
  393. public function setAccountId($account_id)
  394. {
  395. if (is_null($account_id)) {
  396. throw new \InvalidArgumentException('non-nullable account_id cannot be null');
  397. }
  398. $this->container['account_id'] = $account_id;
  399. return $this;
  400. }
  401. /**
  402. * Gets user
  403. *
  404. * @return \WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser|null
  405. */
  406. public function getUser()
  407. {
  408. return $this->container['user'];
  409. }
  410. /**
  411. * Sets user
  412. *
  413. * @param \WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser|null $user user
  414. *
  415. * @return self
  416. */
  417. public function setUser($user)
  418. {
  419. if (is_null($user)) {
  420. array_push($this->openAPINullablesSetToNull, 'user');
  421. } else {
  422. $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
  423. $index = array_search('user', $nullablesSetToNull);
  424. if ($index !== FALSE) {
  425. unset($nullablesSetToNull[$index]);
  426. $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
  427. }
  428. }
  429. $this->container['user'] = $user;
  430. return $this;
  431. }
  432. /**
  433. * Gets earned_balance
  434. *
  435. * @return int|null
  436. */
  437. public function getEarnedBalance()
  438. {
  439. return $this->container['earned_balance'];
  440. }
  441. /**
  442. * Sets earned_balance
  443. *
  444. * @param int|null $earned_balance earned_balance
  445. *
  446. * @return self
  447. */
  448. public function setEarnedBalance($earned_balance)
  449. {
  450. if (is_null($earned_balance)) {
  451. throw new \InvalidArgumentException('non-nullable earned_balance cannot be null');
  452. }
  453. $this->container['earned_balance'] = $earned_balance;
  454. return $this;
  455. }
  456. /**
  457. * Gets earned_total
  458. *
  459. * @return int|null
  460. */
  461. public function getEarnedTotal()
  462. {
  463. return $this->container['earned_total'];
  464. }
  465. /**
  466. * Sets earned_total
  467. *
  468. * @param int|null $earned_total earned_total
  469. *
  470. * @return self
  471. */
  472. public function setEarnedTotal($earned_total)
  473. {
  474. if (is_null($earned_total)) {
  475. throw new \InvalidArgumentException('non-nullable earned_total cannot be null');
  476. }
  477. $this->container['earned_total'] = $earned_total;
  478. return $this;
  479. }
  480. /**
  481. * Gets adjusted_total
  482. *
  483. * @return int|null
  484. */
  485. public function getAdjustedTotal()
  486. {
  487. return $this->container['adjusted_total'];
  488. }
  489. /**
  490. * Sets adjusted_total
  491. *
  492. * @param int|null $adjusted_total adjusted_total
  493. *
  494. * @return self
  495. */
  496. public function setAdjustedTotal($adjusted_total)
  497. {
  498. if (is_null($adjusted_total)) {
  499. throw new \InvalidArgumentException('non-nullable adjusted_total cannot be null');
  500. }
  501. $this->container['adjusted_total'] = $adjusted_total;
  502. return $this;
  503. }
  504. /**
  505. * Gets spent_total
  506. *
  507. * @return int|null
  508. */
  509. public function getSpentTotal()
  510. {
  511. return $this->container['spent_total'];
  512. }
  513. /**
  514. * Sets spent_total
  515. *
  516. * @param int|null $spent_total spent_total
  517. *
  518. * @return self
  519. */
  520. public function setSpentTotal($spent_total)
  521. {
  522. if (is_null($spent_total)) {
  523. throw new \InvalidArgumentException('non-nullable spent_total cannot be null');
  524. }
  525. $this->container['spent_total'] = $spent_total;
  526. return $this;
  527. }
  528. /**
  529. * Gets free_used_today
  530. *
  531. * @return int|null
  532. */
  533. public function getFreeUsedToday()
  534. {
  535. return $this->container['free_used_today'];
  536. }
  537. /**
  538. * Sets free_used_today
  539. *
  540. * @param int|null $free_used_today free_used_today
  541. *
  542. * @return self
  543. */
  544. public function setFreeUsedToday($free_used_today)
  545. {
  546. if (is_null($free_used_today)) {
  547. throw new \InvalidArgumentException('non-nullable free_used_today cannot be null');
  548. }
  549. $this->container['free_used_today'] = $free_used_today;
  550. return $this;
  551. }
  552. /**
  553. * Gets daily_free
  554. *
  555. * @return int|null
  556. */
  557. public function getDailyFree()
  558. {
  559. return $this->container['daily_free'];
  560. }
  561. /**
  562. * Sets daily_free
  563. *
  564. * @param int|null $daily_free daily_free
  565. *
  566. * @return self
  567. */
  568. public function setDailyFree($daily_free)
  569. {
  570. if (is_null($daily_free)) {
  571. throw new \InvalidArgumentException('non-nullable daily_free cannot be null');
  572. }
  573. $this->container['daily_free'] = $daily_free;
  574. return $this;
  575. }
  576. /**
  577. * Gets last_activity_at
  578. *
  579. * @return string|null
  580. */
  581. public function getLastActivityAt()
  582. {
  583. return $this->container['last_activity_at'];
  584. }
  585. /**
  586. * Sets last_activity_at
  587. *
  588. * @param string|null $last_activity_at last_activity_at
  589. *
  590. * @return self
  591. */
  592. public function setLastActivityAt($last_activity_at)
  593. {
  594. if (is_null($last_activity_at)) {
  595. array_push($this->openAPINullablesSetToNull, 'last_activity_at');
  596. } else {
  597. $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
  598. $index = array_search('last_activity_at', $nullablesSetToNull);
  599. if ($index !== FALSE) {
  600. unset($nullablesSetToNull[$index]);
  601. $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
  602. }
  603. }
  604. $this->container['last_activity_at'] = $last_activity_at;
  605. return $this;
  606. }
  607. /**
  608. * Returns true if offset exists. False otherwise.
  609. *
  610. * @param integer|string $offset Offset
  611. *
  612. * @return boolean
  613. */
  614. public function offsetExists(mixed $offset): bool
  615. {
  616. return isset($this->container[$offset]);
  617. }
  618. /**
  619. * Gets offset.
  620. *
  621. * @param integer|string $offset Offset
  622. *
  623. * @return mixed|null
  624. */
  625. #[\ReturnTypeWillChange]
  626. public function offsetGet(mixed $offset)
  627. {
  628. return $this->container[$offset] ?? null;
  629. }
  630. /**
  631. * Sets value based on offset.
  632. *
  633. * @param int|null $offset Offset
  634. * @param mixed $value Value to be set
  635. *
  636. * @return void
  637. */
  638. public function offsetSet($offset, $value): void
  639. {
  640. if (is_null($offset)) {
  641. $this->container[] = $value;
  642. } else {
  643. $this->container[$offset] = $value;
  644. }
  645. }
  646. /**
  647. * Unsets offset.
  648. *
  649. * @param integer|string $offset Offset
  650. *
  651. * @return void
  652. */
  653. public function offsetUnset(mixed $offset): void
  654. {
  655. unset($this->container[$offset]);
  656. }
  657. /**
  658. * Serializes the object to a value that can be serialized natively by json_encode().
  659. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  660. *
  661. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  662. * of any type other than a resource.
  663. */
  664. #[\ReturnTypeWillChange]
  665. public function jsonSerialize()
  666. {
  667. return ObjectSerializer::sanitizeForSerialization($this);
  668. }
  669. /**
  670. * Gets the string presentation of the object
  671. *
  672. * @return string
  673. */
  674. public function __toString()
  675. {
  676. return json_encode(
  677. ObjectSerializer::sanitizeForSerialization($this),
  678. JSON_PRETTY_PRINT
  679. );
  680. }
  681. /**
  682. * Gets a header-safe presentation of the object
  683. *
  684. * @return string
  685. */
  686. public function toHeaderValue()
  687. {
  688. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  689. }
  690. }