PostApiV3DiscussionsBatchCountRequest.php 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <?php
  2. /**
  3. * PostApiV3DiscussionsBatchCountRequest
  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. * PostApiV3DiscussionsBatchCountRequest 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 PostApiV3DiscussionsBatchCountRequest 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_discussions_batch_count_request';
  47. /**
  48. * Array of property to type mappings. Used for (de)serialization
  49. *
  50. * @var string[]
  51. */
  52. protected static $openAPITypes = [
  53. 'targets' => '\WikipaliApi\Model\PostApiV3DiscussionsBatchCountRequestTargetsInner[]'
  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. 'targets' => null
  64. ];
  65. /**
  66. * Array of nullable properties. Used for (de)serialization
  67. *
  68. * @var boolean[]
  69. */
  70. protected static array $openAPINullables = [
  71. 'targets' => 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. 'targets' => 'targets'
  152. ];
  153. /**
  154. * Array of attributes to setter functions (for deserialization of responses)
  155. *
  156. * @var string[]
  157. */
  158. protected static $setters = [
  159. 'targets' => 'setTargets'
  160. ];
  161. /**
  162. * Array of attributes to getter functions (for serialization of requests)
  163. *
  164. * @var string[]
  165. */
  166. protected static $getters = [
  167. 'targets' => 'getTargets'
  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. /**
  207. * Associative array for storing property values
  208. *
  209. * @var mixed[]
  210. */
  211. protected $container = [];
  212. /**
  213. * Constructor
  214. *
  215. * @param mixed[]|null $data Associated array of property values
  216. * initializing the model
  217. */
  218. public function __construct(?array $data = null)
  219. {
  220. $this->setIfExists('targets', $data ?? [], null);
  221. }
  222. /**
  223. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  224. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  225. * $this->openAPINullablesSetToNull array
  226. *
  227. * @param string $variableName
  228. * @param array $fields
  229. * @param mixed $defaultValue
  230. */
  231. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  232. {
  233. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  234. $this->openAPINullablesSetToNull[] = $variableName;
  235. }
  236. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  237. }
  238. /**
  239. * Show all the invalid properties with reasons.
  240. *
  241. * @return array invalid properties with reasons
  242. */
  243. public function listInvalidProperties()
  244. {
  245. $invalidProperties = [];
  246. if ($this->container['targets'] === null) {
  247. $invalidProperties[] = "'targets' can't be null";
  248. }
  249. return $invalidProperties;
  250. }
  251. /**
  252. * Validate all the properties in the model
  253. * return true if all passed
  254. *
  255. * @return bool True if all properties are valid
  256. */
  257. public function valid()
  258. {
  259. return count($this->listInvalidProperties()) === 0;
  260. }
  261. /**
  262. * Gets targets
  263. *
  264. * @return \WikipaliApi\Model\PostApiV3DiscussionsBatchCountRequestTargetsInner[]
  265. */
  266. public function getTargets()
  267. {
  268. return $this->container['targets'];
  269. }
  270. /**
  271. * Sets targets
  272. *
  273. * @param \WikipaliApi\Model\PostApiV3DiscussionsBatchCountRequestTargetsInner[] $targets 讨论对象列表,每项 {type, id},最多 500 个
  274. *
  275. * @return self
  276. */
  277. public function setTargets($targets)
  278. {
  279. if (is_null($targets)) {
  280. throw new \InvalidArgumentException('non-nullable targets cannot be null');
  281. }
  282. $this->container['targets'] = $targets;
  283. return $this;
  284. }
  285. /**
  286. * Returns true if offset exists. False otherwise.
  287. *
  288. * @param integer|string $offset Offset
  289. *
  290. * @return boolean
  291. */
  292. public function offsetExists(mixed $offset): bool
  293. {
  294. return isset($this->container[$offset]);
  295. }
  296. /**
  297. * Gets offset.
  298. *
  299. * @param integer|string $offset Offset
  300. *
  301. * @return mixed|null
  302. */
  303. #[\ReturnTypeWillChange]
  304. public function offsetGet(mixed $offset)
  305. {
  306. return $this->container[$offset] ?? null;
  307. }
  308. /**
  309. * Sets value based on offset.
  310. *
  311. * @param int|null $offset Offset
  312. * @param mixed $value Value to be set
  313. *
  314. * @return void
  315. */
  316. public function offsetSet($offset, $value): void
  317. {
  318. if (is_null($offset)) {
  319. $this->container[] = $value;
  320. } else {
  321. $this->container[$offset] = $value;
  322. }
  323. }
  324. /**
  325. * Unsets offset.
  326. *
  327. * @param integer|string $offset Offset
  328. *
  329. * @return void
  330. */
  331. public function offsetUnset(mixed $offset): void
  332. {
  333. unset($this->container[$offset]);
  334. }
  335. /**
  336. * Serializes the object to a value that can be serialized natively by json_encode().
  337. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  338. *
  339. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  340. * of any type other than a resource.
  341. */
  342. #[\ReturnTypeWillChange]
  343. public function jsonSerialize()
  344. {
  345. return ObjectSerializer::sanitizeForSerialization($this);
  346. }
  347. /**
  348. * Gets the string presentation of the object
  349. *
  350. * @return string
  351. */
  352. public function __toString()
  353. {
  354. return json_encode(
  355. ObjectSerializer::sanitizeForSerialization($this),
  356. JSON_PRETTY_PRINT
  357. );
  358. }
  359. /**
  360. * Gets a header-safe presentation of the object
  361. *
  362. * @return string
  363. */
  364. public function toHeaderValue()
  365. {
  366. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  367. }
  368. }