PostApiV3AgentGrantsRequest.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <?php
  2. /**
  3. * PostApiV3AgentGrantsRequest
  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.10.15
  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. * PostApiV3AgentGrantsRequest 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 PostApiV3AgentGrantsRequest 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_agent_grants_request';
  47. /**
  48. * Array of property to type mappings. Used for (de)serialization
  49. *
  50. * @var string[]
  51. */
  52. protected static $openAPITypes = [
  53. 'ai_model' => 'string',
  54. 'target_type' => 'string',
  55. 'target_id' => 'string',
  56. 'book' => 'int'
  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. 'ai_model' => null,
  67. 'target_type' => null,
  68. 'target_id' => null,
  69. 'book' => null
  70. ];
  71. /**
  72. * Array of nullable properties. Used for (de)serialization
  73. *
  74. * @var boolean[]
  75. */
  76. protected static array $openAPINullables = [
  77. 'ai_model' => false,
  78. 'target_type' => false,
  79. 'target_id' => false,
  80. 'book' => 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. 'ai_model' => 'ai_model',
  161. 'target_type' => 'target_type',
  162. 'target_id' => 'target_id',
  163. 'book' => 'book'
  164. ];
  165. /**
  166. * Array of attributes to setter functions (for deserialization of responses)
  167. *
  168. * @var string[]
  169. */
  170. protected static $setters = [
  171. 'ai_model' => 'setAiModel',
  172. 'target_type' => 'setTargetType',
  173. 'target_id' => 'setTargetId',
  174. 'book' => 'setBook'
  175. ];
  176. /**
  177. * Array of attributes to getter functions (for serialization of requests)
  178. *
  179. * @var string[]
  180. */
  181. protected static $getters = [
  182. 'ai_model' => 'getAiModel',
  183. 'target_type' => 'getTargetType',
  184. 'target_id' => 'getTargetId',
  185. 'book' => 'getBook'
  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 TARGET_TYPE_CHANNEL = 'channel';
  225. /**
  226. * Gets allowable values of the enum
  227. *
  228. * @return string[]
  229. */
  230. public function getTargetTypeAllowableValues()
  231. {
  232. return [
  233. self::TARGET_TYPE_CHANNEL,
  234. ];
  235. }
  236. /**
  237. * Associative array for storing property values
  238. *
  239. * @var mixed[]
  240. */
  241. protected $container = [];
  242. /**
  243. * Constructor
  244. *
  245. * @param mixed[]|null $data Associated array of property values
  246. * initializing the model
  247. */
  248. public function __construct(?array $data = null)
  249. {
  250. $this->setIfExists('ai_model', $data ?? [], null);
  251. $this->setIfExists('target_type', $data ?? [], null);
  252. $this->setIfExists('target_id', $data ?? [], null);
  253. $this->setIfExists('book', $data ?? [], 0);
  254. }
  255. /**
  256. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  257. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  258. * $this->openAPINullablesSetToNull array
  259. *
  260. * @param string $variableName
  261. * @param array $fields
  262. * @param mixed $defaultValue
  263. */
  264. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  265. {
  266. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  267. $this->openAPINullablesSetToNull[] = $variableName;
  268. }
  269. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  270. }
  271. /**
  272. * Show all the invalid properties with reasons.
  273. *
  274. * @return array invalid properties with reasons
  275. */
  276. public function listInvalidProperties()
  277. {
  278. $invalidProperties = [];
  279. if ($this->container['ai_model'] === null) {
  280. $invalidProperties[] = "'ai_model' can't be null";
  281. }
  282. if ($this->container['target_type'] === null) {
  283. $invalidProperties[] = "'target_type' can't be null";
  284. }
  285. $allowedValues = $this->getTargetTypeAllowableValues();
  286. if (!is_null($this->container['target_type']) && !in_array($this->container['target_type'], $allowedValues, true)) {
  287. $invalidProperties[] = sprintf(
  288. "invalid value '%s' for 'target_type', must be one of '%s'",
  289. $this->container['target_type'],
  290. implode("', '", $allowedValues)
  291. );
  292. }
  293. if ($this->container['target_id'] === null) {
  294. $invalidProperties[] = "'target_id' can't be null";
  295. }
  296. return $invalidProperties;
  297. }
  298. /**
  299. * Validate all the properties in the model
  300. * return true if all passed
  301. *
  302. * @return bool True if all properties are valid
  303. */
  304. public function valid()
  305. {
  306. return count($this->listInvalidProperties()) === 0;
  307. }
  308. /**
  309. * Gets ai_model
  310. *
  311. * @return string
  312. */
  313. public function getAiModel()
  314. {
  315. return $this->container['ai_model'];
  316. }
  317. /**
  318. * Sets ai_model
  319. *
  320. * @param string $ai_model 被授权的 AI 模型 uid
  321. *
  322. * @return self
  323. */
  324. public function setAiModel($ai_model)
  325. {
  326. if (is_null($ai_model)) {
  327. throw new \InvalidArgumentException('non-nullable ai_model cannot be null');
  328. }
  329. $this->container['ai_model'] = $ai_model;
  330. return $this;
  331. }
  332. /**
  333. * Gets target_type
  334. *
  335. * @return string
  336. */
  337. public function getTargetType()
  338. {
  339. return $this->container['target_type'];
  340. }
  341. /**
  342. * Sets target_type
  343. *
  344. * @param string $target_type 授权范围的类型
  345. *
  346. * @return self
  347. */
  348. public function setTargetType($target_type)
  349. {
  350. if (is_null($target_type)) {
  351. throw new \InvalidArgumentException('non-nullable target_type cannot be null');
  352. }
  353. $allowedValues = $this->getTargetTypeAllowableValues();
  354. if (!in_array($target_type, $allowedValues, true)) {
  355. throw new \InvalidArgumentException(
  356. sprintf(
  357. "Invalid value '%s' for 'target_type', must be one of '%s'",
  358. $target_type,
  359. implode("', '", $allowedValues)
  360. )
  361. );
  362. }
  363. $this->container['target_type'] = $target_type;
  364. return $this;
  365. }
  366. /**
  367. * Gets target_id
  368. *
  369. * @return string
  370. */
  371. public function getTargetId()
  372. {
  373. return $this->container['target_id'];
  374. }
  375. /**
  376. * Sets target_id
  377. *
  378. * @param string $target_id channel 的 uid
  379. *
  380. * @return self
  381. */
  382. public function setTargetId($target_id)
  383. {
  384. if (is_null($target_id)) {
  385. throw new \InvalidArgumentException('non-nullable target_id cannot be null');
  386. }
  387. $this->container['target_id'] = $target_id;
  388. return $this;
  389. }
  390. /**
  391. * Gets book
  392. *
  393. * @return int|null
  394. */
  395. public function getBook()
  396. {
  397. return $this->container['book'];
  398. }
  399. /**
  400. * Sets book
  401. *
  402. * @param int|null $book 限定 book,0 或不传表示不限
  403. *
  404. * @return self
  405. */
  406. public function setBook($book)
  407. {
  408. if (is_null($book)) {
  409. throw new \InvalidArgumentException('non-nullable book cannot be null');
  410. }
  411. $this->container['book'] = $book;
  412. return $this;
  413. }
  414. /**
  415. * Returns true if offset exists. False otherwise.
  416. *
  417. * @param integer|string $offset Offset
  418. *
  419. * @return boolean
  420. */
  421. public function offsetExists(mixed $offset): bool
  422. {
  423. return isset($this->container[$offset]);
  424. }
  425. /**
  426. * Gets offset.
  427. *
  428. * @param integer|string $offset Offset
  429. *
  430. * @return mixed|null
  431. */
  432. #[\ReturnTypeWillChange]
  433. public function offsetGet(mixed $offset)
  434. {
  435. return $this->container[$offset] ?? null;
  436. }
  437. /**
  438. * Sets value based on offset.
  439. *
  440. * @param int|null $offset Offset
  441. * @param mixed $value Value to be set
  442. *
  443. * @return void
  444. */
  445. public function offsetSet($offset, $value): void
  446. {
  447. if (is_null($offset)) {
  448. $this->container[] = $value;
  449. } else {
  450. $this->container[$offset] = $value;
  451. }
  452. }
  453. /**
  454. * Unsets offset.
  455. *
  456. * @param integer|string $offset Offset
  457. *
  458. * @return void
  459. */
  460. public function offsetUnset(mixed $offset): void
  461. {
  462. unset($this->container[$offset]);
  463. }
  464. /**
  465. * Serializes the object to a value that can be serialized natively by json_encode().
  466. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  467. *
  468. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  469. * of any type other than a resource.
  470. */
  471. #[\ReturnTypeWillChange]
  472. public function jsonSerialize()
  473. {
  474. return ObjectSerializer::sanitizeForSerialization($this);
  475. }
  476. /**
  477. * Gets the string presentation of the object
  478. *
  479. * @return string
  480. */
  481. public function __toString()
  482. {
  483. return json_encode(
  484. ObjectSerializer::sanitizeForSerialization($this),
  485. JSON_PRETTY_PRINT
  486. );
  487. }
  488. /**
  489. * Gets a header-safe presentation of the object
  490. *
  491. * @return string
  492. */
  493. public function toHeaderValue()
  494. {
  495. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  496. }
  497. }