PostApiV3AgentEventsRequest.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. <?php
  2. /**
  3. * PostApiV3AgentEventsRequest
  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.11.12
  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. * PostApiV3AgentEventsRequest 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 PostApiV3AgentEventsRequest 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_events_request';
  47. /**
  48. * Array of property to type mappings. Used for (de)serialization
  49. *
  50. * @var string[]
  51. */
  52. protected static $openAPITypes = [
  53. 'message_id' => 'string',
  54. 'kind' => 'string',
  55. 'device_id' => 'string',
  56. 'client' => '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. 'message_id' => null,
  67. 'kind' => null,
  68. 'device_id' => null,
  69. 'client' => null
  70. ];
  71. /**
  72. * Array of nullable properties. Used for (de)serialization
  73. *
  74. * @var boolean[]
  75. */
  76. protected static array $openAPINullables = [
  77. 'message_id' => false,
  78. 'kind' => false,
  79. 'device_id' => false,
  80. 'client' => 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. 'message_id' => 'message_id',
  161. 'kind' => 'kind',
  162. 'device_id' => 'device_id',
  163. 'client' => 'client'
  164. ];
  165. /**
  166. * Array of attributes to setter functions (for deserialization of responses)
  167. *
  168. * @var string[]
  169. */
  170. protected static $setters = [
  171. 'message_id' => 'setMessageId',
  172. 'kind' => 'setKind',
  173. 'device_id' => 'setDeviceId',
  174. 'client' => 'setClient'
  175. ];
  176. /**
  177. * Array of attributes to getter functions (for serialization of requests)
  178. *
  179. * @var string[]
  180. */
  181. protected static $getters = [
  182. 'message_id' => 'getMessageId',
  183. 'kind' => 'getKind',
  184. 'device_id' => 'getDeviceId',
  185. 'client' => 'getClient'
  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 KIND_COPY = 'copy';
  225. public const KIND_CITATION_OPEN = 'citation_open';
  226. public const KIND_REGENERATE = 'regenerate';
  227. public const KIND_ASK_SHOWN = 'ask_shown';
  228. public const CLIENT_MOBILE = 'mobile';
  229. public const CLIENT_WEB = 'web';
  230. /**
  231. * Gets allowable values of the enum
  232. *
  233. * @return string[]
  234. */
  235. public function getKindAllowableValues()
  236. {
  237. return [
  238. self::KIND_COPY,
  239. self::KIND_CITATION_OPEN,
  240. self::KIND_REGENERATE,
  241. self::KIND_ASK_SHOWN,
  242. ];
  243. }
  244. /**
  245. * Gets allowable values of the enum
  246. *
  247. * @return string[]
  248. */
  249. public function getClientAllowableValues()
  250. {
  251. return [
  252. self::CLIENT_MOBILE,
  253. self::CLIENT_WEB,
  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('message_id', $data ?? [], null);
  271. $this->setIfExists('kind', $data ?? [], null);
  272. $this->setIfExists('device_id', $data ?? [], null);
  273. $this->setIfExists('client', $data ?? [], null);
  274. }
  275. /**
  276. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  277. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  278. * $this->openAPINullablesSetToNull array
  279. *
  280. * @param string $variableName
  281. * @param array $fields
  282. * @param mixed $defaultValue
  283. */
  284. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  285. {
  286. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  287. $this->openAPINullablesSetToNull[] = $variableName;
  288. }
  289. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  290. }
  291. /**
  292. * Show all the invalid properties with reasons.
  293. *
  294. * @return array invalid properties with reasons
  295. */
  296. public function listInvalidProperties()
  297. {
  298. $invalidProperties = [];
  299. if ($this->container['message_id'] === null) {
  300. $invalidProperties[] = "'message_id' can't be null";
  301. }
  302. if ($this->container['kind'] === null) {
  303. $invalidProperties[] = "'kind' can't be null";
  304. }
  305. $allowedValues = $this->getKindAllowableValues();
  306. if (!is_null($this->container['kind']) && !in_array($this->container['kind'], $allowedValues, true)) {
  307. $invalidProperties[] = sprintf(
  308. "invalid value '%s' for 'kind', must be one of '%s'",
  309. $this->container['kind'],
  310. implode("', '", $allowedValues)
  311. );
  312. }
  313. $allowedValues = $this->getClientAllowableValues();
  314. if (!is_null($this->container['client']) && !in_array($this->container['client'], $allowedValues, true)) {
  315. $invalidProperties[] = sprintf(
  316. "invalid value '%s' for 'client', must be one of '%s'",
  317. $this->container['client'],
  318. implode("', '", $allowedValues)
  319. );
  320. }
  321. return $invalidProperties;
  322. }
  323. /**
  324. * Validate all the properties in the model
  325. * return true if all passed
  326. *
  327. * @return bool True if all properties are valid
  328. */
  329. public function valid()
  330. {
  331. return count($this->listInvalidProperties()) === 0;
  332. }
  333. /**
  334. * Gets message_id
  335. *
  336. * @return string
  337. */
  338. public function getMessageId()
  339. {
  340. return $this->container['message_id'];
  341. }
  342. /**
  343. * Sets message_id
  344. *
  345. * @param string $message_id AG-UI 回答消息 id
  346. *
  347. * @return self
  348. */
  349. public function setMessageId($message_id)
  350. {
  351. if (is_null($message_id)) {
  352. throw new \InvalidArgumentException('non-nullable message_id cannot be null');
  353. }
  354. $this->container['message_id'] = $message_id;
  355. return $this;
  356. }
  357. /**
  358. * Gets kind
  359. *
  360. * @return string
  361. */
  362. public function getKind()
  363. {
  364. return $this->container['kind'];
  365. }
  366. /**
  367. * Sets kind
  368. *
  369. * @param string $kind 信号
  370. *
  371. * @return self
  372. */
  373. public function setKind($kind)
  374. {
  375. if (is_null($kind)) {
  376. throw new \InvalidArgumentException('non-nullable kind cannot be null');
  377. }
  378. $allowedValues = $this->getKindAllowableValues();
  379. if (!in_array($kind, $allowedValues, true)) {
  380. throw new \InvalidArgumentException(
  381. sprintf(
  382. "Invalid value '%s' for 'kind', must be one of '%s'",
  383. $kind,
  384. implode("', '", $allowedValues)
  385. )
  386. );
  387. }
  388. $this->container['kind'] = $kind;
  389. return $this;
  390. }
  391. /**
  392. * Gets device_id
  393. *
  394. * @return string|null
  395. */
  396. public function getDeviceId()
  397. {
  398. return $this->container['device_id'];
  399. }
  400. /**
  401. * Sets device_id
  402. *
  403. * @param string|null $device_id 设备匿名 id(uuid)。未登录时必填
  404. *
  405. * @return self
  406. */
  407. public function setDeviceId($device_id)
  408. {
  409. if (is_null($device_id)) {
  410. throw new \InvalidArgumentException('non-nullable device_id cannot be null');
  411. }
  412. $this->container['device_id'] = $device_id;
  413. return $this;
  414. }
  415. /**
  416. * Gets client
  417. *
  418. * @return string|null
  419. */
  420. public function getClient()
  421. {
  422. return $this->container['client'];
  423. }
  424. /**
  425. * Sets client
  426. *
  427. * @param string|null $client 客户端
  428. *
  429. * @return self
  430. */
  431. public function setClient($client)
  432. {
  433. if (is_null($client)) {
  434. throw new \InvalidArgumentException('non-nullable client cannot be null');
  435. }
  436. $allowedValues = $this->getClientAllowableValues();
  437. if (!in_array($client, $allowedValues, true)) {
  438. throw new \InvalidArgumentException(
  439. sprintf(
  440. "Invalid value '%s' for 'client', must be one of '%s'",
  441. $client,
  442. implode("', '", $allowedValues)
  443. )
  444. );
  445. }
  446. $this->container['client'] = $client;
  447. return $this;
  448. }
  449. /**
  450. * Returns true if offset exists. False otherwise.
  451. *
  452. * @param integer|string $offset Offset
  453. *
  454. * @return boolean
  455. */
  456. public function offsetExists(mixed $offset): bool
  457. {
  458. return isset($this->container[$offset]);
  459. }
  460. /**
  461. * Gets offset.
  462. *
  463. * @param integer|string $offset Offset
  464. *
  465. * @return mixed|null
  466. */
  467. #[\ReturnTypeWillChange]
  468. public function offsetGet(mixed $offset)
  469. {
  470. return $this->container[$offset] ?? null;
  471. }
  472. /**
  473. * Sets value based on offset.
  474. *
  475. * @param int|null $offset Offset
  476. * @param mixed $value Value to be set
  477. *
  478. * @return void
  479. */
  480. public function offsetSet($offset, $value): void
  481. {
  482. if (is_null($offset)) {
  483. $this->container[] = $value;
  484. } else {
  485. $this->container[$offset] = $value;
  486. }
  487. }
  488. /**
  489. * Unsets offset.
  490. *
  491. * @param integer|string $offset Offset
  492. *
  493. * @return void
  494. */
  495. public function offsetUnset(mixed $offset): void
  496. {
  497. unset($this->container[$offset]);
  498. }
  499. /**
  500. * Serializes the object to a value that can be serialized natively by json_encode().
  501. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  502. *
  503. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  504. * of any type other than a resource.
  505. */
  506. #[\ReturnTypeWillChange]
  507. public function jsonSerialize()
  508. {
  509. return ObjectSerializer::sanitizeForSerialization($this);
  510. }
  511. /**
  512. * Gets the string presentation of the object
  513. *
  514. * @return string
  515. */
  516. public function __toString()
  517. {
  518. return json_encode(
  519. ObjectSerializer::sanitizeForSerialization($this),
  520. JSON_PRETTY_PRINT
  521. );
  522. }
  523. /**
  524. * Gets a header-safe presentation of the object
  525. *
  526. * @return string
  527. */
  528. public function toHeaderValue()
  529. {
  530. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  531. }
  532. }