PatchApiV3GroupsGroupMembersMemberRequest.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <?php
  2. /**
  3. * PatchApiV3GroupsGroupMembersMemberRequest
  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. * PatchApiV3GroupsGroupMembersMemberRequest 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 PatchApiV3GroupsGroupMembersMemberRequest 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 = 'patch_api_v3_groups_group_members_member__request';
  47. /**
  48. * Array of property to type mappings. Used for (de)serialization
  49. *
  50. * @var string[]
  51. */
  52. protected static $openAPITypes = [
  53. 'role' => 'string'
  54. ];
  55. /**
  56. * Array of property to format mappings. Used for (de)serialization
  57. *
  58. * @var string[]
  59. * @phpstan-var array<string, string|null>
  60. * @psalm-var array<string, string|null>
  61. */
  62. protected static $openAPIFormats = [
  63. 'role' => null
  64. ];
  65. /**
  66. * Array of nullable properties. Used for (de)serialization
  67. *
  68. * @var boolean[]
  69. */
  70. protected static array $openAPINullables = [
  71. 'role' => false
  72. ];
  73. /**
  74. * If a nullable field gets set to null, insert it here
  75. *
  76. * @var boolean[]
  77. */
  78. protected array $openAPINullablesSetToNull = [];
  79. /**
  80. * Array of property to type mappings. Used for (de)serialization
  81. *
  82. * @return array
  83. */
  84. public static function openAPITypes()
  85. {
  86. return self::$openAPITypes;
  87. }
  88. /**
  89. * Array of property to format mappings. Used for (de)serialization
  90. *
  91. * @return array
  92. */
  93. public static function openAPIFormats()
  94. {
  95. return self::$openAPIFormats;
  96. }
  97. /**
  98. * Array of nullable properties
  99. *
  100. * @return array
  101. */
  102. protected static function openAPINullables(): array
  103. {
  104. return self::$openAPINullables;
  105. }
  106. /**
  107. * Array of nullable field names deliberately set to null
  108. *
  109. * @return boolean[]
  110. */
  111. private function getOpenAPINullablesSetToNull(): array
  112. {
  113. return $this->openAPINullablesSetToNull;
  114. }
  115. /**
  116. * Setter - Array of nullable field names deliberately set to null
  117. *
  118. * @param boolean[] $openAPINullablesSetToNull
  119. */
  120. private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
  121. {
  122. $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
  123. }
  124. /**
  125. * Checks if a property is nullable
  126. *
  127. * @param string $property
  128. * @return bool
  129. */
  130. public static function isNullable(string $property): bool
  131. {
  132. return self::openAPINullables()[$property] ?? false;
  133. }
  134. /**
  135. * Checks if a nullable property is set to null.
  136. *
  137. * @param string $property
  138. * @return bool
  139. */
  140. public function isNullableSetToNull(string $property): bool
  141. {
  142. return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
  143. }
  144. /**
  145. * Array of attributes where the key is the local name,
  146. * and the value is the original name
  147. *
  148. * @var string[]
  149. */
  150. protected static $attributeMap = [
  151. 'role' => 'role'
  152. ];
  153. /**
  154. * Array of attributes to setter functions (for deserialization of responses)
  155. *
  156. * @var string[]
  157. */
  158. protected static $setters = [
  159. 'role' => 'setRole'
  160. ];
  161. /**
  162. * Array of attributes to getter functions (for serialization of requests)
  163. *
  164. * @var string[]
  165. */
  166. protected static $getters = [
  167. 'role' => 'getRole'
  168. ];
  169. /**
  170. * Array of attributes where the key is the local name,
  171. * and the value is the original name
  172. *
  173. * @return array
  174. */
  175. public static function attributeMap()
  176. {
  177. return self::$attributeMap;
  178. }
  179. /**
  180. * Array of attributes to setter functions (for deserialization of responses)
  181. *
  182. * @return array
  183. */
  184. public static function setters()
  185. {
  186. return self::$setters;
  187. }
  188. /**
  189. * Array of attributes to getter functions (for serialization of requests)
  190. *
  191. * @return array
  192. */
  193. public static function getters()
  194. {
  195. return self::$getters;
  196. }
  197. /**
  198. * The original name of the model.
  199. *
  200. * @return string
  201. */
  202. public function getModelName()
  203. {
  204. return self::$openAPIModelName;
  205. }
  206. public const ROLE_MANAGER = 'manager';
  207. public const ROLE_EDITOR = 'editor';
  208. public const ROLE_READER = 'reader';
  209. /**
  210. * Gets allowable values of the enum
  211. *
  212. * @return string[]
  213. */
  214. public function getRoleAllowableValues()
  215. {
  216. return [
  217. self::ROLE_MANAGER,
  218. self::ROLE_EDITOR,
  219. self::ROLE_READER,
  220. ];
  221. }
  222. /**
  223. * Associative array for storing property values
  224. *
  225. * @var mixed[]
  226. */
  227. protected $container = [];
  228. /**
  229. * Constructor
  230. *
  231. * @param mixed[]|null $data Associated array of property values
  232. * initializing the model
  233. */
  234. public function __construct(?array $data = null)
  235. {
  236. $this->setIfExists('role', $data ?? [], null);
  237. }
  238. /**
  239. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  240. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  241. * $this->openAPINullablesSetToNull array
  242. *
  243. * @param string $variableName
  244. * @param array $fields
  245. * @param mixed $defaultValue
  246. */
  247. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  248. {
  249. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  250. $this->openAPINullablesSetToNull[] = $variableName;
  251. }
  252. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  253. }
  254. /**
  255. * Show all the invalid properties with reasons.
  256. *
  257. * @return array invalid properties with reasons
  258. */
  259. public function listInvalidProperties()
  260. {
  261. $invalidProperties = [];
  262. $allowedValues = $this->getRoleAllowableValues();
  263. if (!is_null($this->container['role']) && !in_array($this->container['role'], $allowedValues, true)) {
  264. $invalidProperties[] = sprintf(
  265. "invalid value '%s' for 'role', must be one of '%s'",
  266. $this->container['role'],
  267. implode("', '", $allowedValues)
  268. );
  269. }
  270. return $invalidProperties;
  271. }
  272. /**
  273. * Validate all the properties in the model
  274. * return true if all passed
  275. *
  276. * @return bool True if all properties are valid
  277. */
  278. public function valid()
  279. {
  280. return count($this->listInvalidProperties()) === 0;
  281. }
  282. /**
  283. * Gets role
  284. *
  285. * @return string|null
  286. */
  287. public function getRole()
  288. {
  289. return $this->container['role'];
  290. }
  291. /**
  292. * Sets role
  293. *
  294. * @param string|null $role 角色
  295. *
  296. * @return self
  297. */
  298. public function setRole($role)
  299. {
  300. if (is_null($role)) {
  301. throw new \InvalidArgumentException('non-nullable role cannot be null');
  302. }
  303. $allowedValues = $this->getRoleAllowableValues();
  304. if (!in_array($role, $allowedValues, true)) {
  305. throw new \InvalidArgumentException(
  306. sprintf(
  307. "Invalid value '%s' for 'role', must be one of '%s'",
  308. $role,
  309. implode("', '", $allowedValues)
  310. )
  311. );
  312. }
  313. $this->container['role'] = $role;
  314. return $this;
  315. }
  316. /**
  317. * Returns true if offset exists. False otherwise.
  318. *
  319. * @param integer|string $offset Offset
  320. *
  321. * @return boolean
  322. */
  323. public function offsetExists(mixed $offset): bool
  324. {
  325. return isset($this->container[$offset]);
  326. }
  327. /**
  328. * Gets offset.
  329. *
  330. * @param integer|string $offset Offset
  331. *
  332. * @return mixed|null
  333. */
  334. #[\ReturnTypeWillChange]
  335. public function offsetGet(mixed $offset)
  336. {
  337. return $this->container[$offset] ?? null;
  338. }
  339. /**
  340. * Sets value based on offset.
  341. *
  342. * @param int|null $offset Offset
  343. * @param mixed $value Value to be set
  344. *
  345. * @return void
  346. */
  347. public function offsetSet($offset, $value): void
  348. {
  349. if (is_null($offset)) {
  350. $this->container[] = $value;
  351. } else {
  352. $this->container[$offset] = $value;
  353. }
  354. }
  355. /**
  356. * Unsets offset.
  357. *
  358. * @param integer|string $offset Offset
  359. *
  360. * @return void
  361. */
  362. public function offsetUnset(mixed $offset): void
  363. {
  364. unset($this->container[$offset]);
  365. }
  366. /**
  367. * Serializes the object to a value that can be serialized natively by json_encode().
  368. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  369. *
  370. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  371. * of any type other than a resource.
  372. */
  373. #[\ReturnTypeWillChange]
  374. public function jsonSerialize()
  375. {
  376. return ObjectSerializer::sanitizeForSerialization($this);
  377. }
  378. /**
  379. * Gets the string presentation of the object
  380. *
  381. * @return string
  382. */
  383. public function __toString()
  384. {
  385. return json_encode(
  386. ObjectSerializer::sanitizeForSerialization($this),
  387. JSON_PRETTY_PRINT
  388. );
  389. }
  390. /**
  391. * Gets a header-safe presentation of the object
  392. *
  393. * @return string
  394. */
  395. public function toHeaderValue()
  396. {
  397. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  398. }
  399. }