|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Configuration API |
| 5 | + * |
| 6 | + * The version of the OpenAPI document: 2 |
| 7 | + * Generated by: https://openapi-generator.tech |
| 8 | + * OpenAPI Generator version: 6.0.1 |
| 9 | + * |
| 10 | + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). |
| 11 | + * https://openapi-generator.tech |
| 12 | + * Do not edit the class manually. |
| 13 | + */ |
| 14 | + |
| 15 | + |
| 16 | +namespace Adyen\Model\BalancePlatform; |
| 17 | +use Adyen\Model\BalancePlatform\ObjectSerializer; |
| 18 | + |
| 19 | +/** |
| 20 | + * BalanceWebhookSetting Class Doc Comment |
| 21 | + * |
| 22 | + * @package Adyen |
| 23 | + * @implements ArrayAccess<string, mixed> |
| 24 | + */ |
| 25 | +class BalanceWebhookSetting extends WebhookSetting |
| 26 | +{ |
| 27 | + public const DISCRIMINATOR = null; |
| 28 | + |
| 29 | + /** |
| 30 | + * The original name of the model. |
| 31 | + * |
| 32 | + * @var string |
| 33 | + */ |
| 34 | + protected static $openAPIModelName = 'BalanceWebhookSetting'; |
| 35 | + |
| 36 | + /** |
| 37 | + * Array of property to type mappings. Used for (de)serialization |
| 38 | + * |
| 39 | + * @var string[] |
| 40 | + */ |
| 41 | + protected static $openAPITypes = [ |
| 42 | + 'conditions' => '\Adyen\Model\BalancePlatform\Condition[]' |
| 43 | + ]; |
| 44 | + |
| 45 | + /** |
| 46 | + * Array of property to format mappings. Used for (de)serialization |
| 47 | + * |
| 48 | + * @var string[] |
| 49 | + * @phpstan-var array<string, string|null> |
| 50 | + * @psalm-var array<string, string|null> |
| 51 | + */ |
| 52 | + protected static $openAPIFormats = [ |
| 53 | + 'conditions' => null |
| 54 | + ]; |
| 55 | + |
| 56 | + /** |
| 57 | + * Array of nullable properties. Used for (de)serialization |
| 58 | + * |
| 59 | + * @var boolean[] |
| 60 | + */ |
| 61 | + protected static $openAPINullables = [ |
| 62 | + 'conditions' => false |
| 63 | + ]; |
| 64 | + |
| 65 | + /** |
| 66 | + * If a nullable field gets set to null, insert it here |
| 67 | + * |
| 68 | + * @var boolean[] |
| 69 | + */ |
| 70 | + protected $openAPINullablesSetToNull = []; |
| 71 | + |
| 72 | + /** |
| 73 | + * Array of property to type mappings. Used for (de)serialization |
| 74 | + * |
| 75 | + * @return array |
| 76 | + */ |
| 77 | + public static function openAPITypes() |
| 78 | + { |
| 79 | + return self::$openAPITypes + parent::openAPITypes(); |
| 80 | + } |
| 81 | + |
| 82 | + /** |
| 83 | + * Array of property to format mappings. Used for (de)serialization |
| 84 | + * |
| 85 | + * @return array |
| 86 | + */ |
| 87 | + public static function openAPIFormats() |
| 88 | + { |
| 89 | + return self::$openAPIFormats + parent::openAPIFormats(); |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * Array of nullable properties |
| 94 | + * |
| 95 | + * @return array |
| 96 | + */ |
| 97 | + protected static function openAPINullables(): array |
| 98 | + { |
| 99 | + return self::$openAPINullables + parent::openAPINullables(); |
| 100 | + } |
| 101 | + |
| 102 | + /** |
| 103 | + * Array of nullable field names deliberately set to null |
| 104 | + * |
| 105 | + * @return boolean[] |
| 106 | + */ |
| 107 | + private function getOpenAPINullablesSetToNull(): array |
| 108 | + { |
| 109 | + return $this->openAPINullablesSetToNull; |
| 110 | + } |
| 111 | + |
| 112 | + /** |
| 113 | + * Setter - Array of nullable field names deliberately set to null |
| 114 | + * |
| 115 | + * @param boolean[] $openAPINullablesSetToNull |
| 116 | + */ |
| 117 | + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void |
| 118 | + { |
| 119 | + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; |
| 120 | + } |
| 121 | + |
| 122 | + /** |
| 123 | + * Checks if a property is nullable |
| 124 | + * |
| 125 | + * @param string $property |
| 126 | + * @return bool |
| 127 | + */ |
| 128 | + public static function isNullable(string $property): bool |
| 129 | + { |
| 130 | + return self::openAPINullables()[$property] ?? false; |
| 131 | + } |
| 132 | + |
| 133 | + /** |
| 134 | + * Checks if a nullable property is set to null. |
| 135 | + * |
| 136 | + * @param string $property |
| 137 | + * @return bool |
| 138 | + */ |
| 139 | + public function isNullableSetToNull(string $property): bool |
| 140 | + { |
| 141 | + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); |
| 142 | + } |
| 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 | + 'conditions' => 'conditions' |
| 152 | + ]; |
| 153 | + |
| 154 | + /** |
| 155 | + * Array of attributes to setter functions (for deserialization of responses) |
| 156 | + * |
| 157 | + * @var string[] |
| 158 | + */ |
| 159 | + protected static $setters = [ |
| 160 | + 'conditions' => 'setConditions' |
| 161 | + ]; |
| 162 | + |
| 163 | + /** |
| 164 | + * Array of attributes to getter functions (for serialization of requests) |
| 165 | + * |
| 166 | + * @var string[] |
| 167 | + */ |
| 168 | + protected static $getters = [ |
| 169 | + 'conditions' => 'getConditions' |
| 170 | + ]; |
| 171 | + |
| 172 | + /** |
| 173 | + * Array of attributes where the key is the local name, |
| 174 | + * and the value is the original name |
| 175 | + * |
| 176 | + * @return array |
| 177 | + */ |
| 178 | + public static function attributeMap() |
| 179 | + { |
| 180 | + return parent::attributeMap() + self::$attributeMap; |
| 181 | + } |
| 182 | + |
| 183 | + /** |
| 184 | + * Array of attributes to setter functions (for deserialization of responses) |
| 185 | + * |
| 186 | + * @return array |
| 187 | + */ |
| 188 | + public static function setters() |
| 189 | + { |
| 190 | + return parent::setters() + self::$setters; |
| 191 | + } |
| 192 | + |
| 193 | + /** |
| 194 | + * Array of attributes to getter functions (for serialization of requests) |
| 195 | + * |
| 196 | + * @return array |
| 197 | + */ |
| 198 | + public static function getters() |
| 199 | + { |
| 200 | + return parent::getters() + self::$getters; |
| 201 | + } |
| 202 | + |
| 203 | + /** |
| 204 | + * The original name of the model. |
| 205 | + * |
| 206 | + * @return string |
| 207 | + */ |
| 208 | + public function getModelName() |
| 209 | + { |
| 210 | + return self::$openAPIModelName; |
| 211 | + } |
| 212 | + |
| 213 | + |
| 214 | + |
| 215 | + /** |
| 216 | + * Constructor |
| 217 | + * |
| 218 | + * @param mixed[] $data Associated array of property values |
| 219 | + * initializing the model |
| 220 | + */ |
| 221 | + public function __construct(?array $data = null) |
| 222 | + { |
| 223 | + parent::__construct($data); |
| 224 | + |
| 225 | + $this->setIfExists('conditions', $data ?? [], null); |
| 226 | + } |
| 227 | + |
| 228 | + /** |
| 229 | + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName |
| 230 | + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the |
| 231 | + * $this->openAPINullablesSetToNull array |
| 232 | + * |
| 233 | + * @param string $variableName |
| 234 | + * @param array $fields |
| 235 | + * @param mixed $defaultValue |
| 236 | + */ |
| 237 | + private function setIfExists(string $variableName, array $fields, $defaultValue): void |
| 238 | + { |
| 239 | + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { |
| 240 | + $this->openAPINullablesSetToNull[] = $variableName; |
| 241 | + } |
| 242 | + |
| 243 | + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; |
| 244 | + } |
| 245 | + |
| 246 | + /** |
| 247 | + * Show all the invalid properties with reasons. |
| 248 | + * |
| 249 | + * @return array invalid properties with reasons |
| 250 | + */ |
| 251 | + public function listInvalidProperties() |
| 252 | + { |
| 253 | + $invalidProperties = parent::listInvalidProperties(); |
| 254 | + |
| 255 | + return $invalidProperties; |
| 256 | + } |
| 257 | + |
| 258 | + /** |
| 259 | + * Validate all the properties in the model |
| 260 | + * return true if all passed |
| 261 | + * |
| 262 | + * @return bool True if all properties are valid |
| 263 | + */ |
| 264 | + public function valid() |
| 265 | + { |
| 266 | + return count($this->listInvalidProperties()) === 0; |
| 267 | + } |
| 268 | + |
| 269 | + |
| 270 | + /** |
| 271 | + * Gets conditions |
| 272 | + * |
| 273 | + * @return \Adyen\Model\BalancePlatform\Condition[]|null |
| 274 | + */ |
| 275 | + public function getConditions() |
| 276 | + { |
| 277 | + return $this->container['conditions']; |
| 278 | + } |
| 279 | + |
| 280 | + /** |
| 281 | + * Sets conditions |
| 282 | + * |
| 283 | + * @param \Adyen\Model\BalancePlatform\Condition[]|null $conditions The list of settings and criteria for triggering the [balance webhook](https://docs.adyen.com/api-explorer/balance-webhooks/latest/post/balanceAccount.balance.updated). |
| 284 | + * |
| 285 | + * @return self |
| 286 | + */ |
| 287 | + public function setConditions($conditions) |
| 288 | + { |
| 289 | + $this->container['conditions'] = $conditions; |
| 290 | + |
| 291 | + return $this; |
| 292 | + } |
| 293 | + /** |
| 294 | + * Returns true if offset exists. False otherwise. |
| 295 | + * |
| 296 | + * @param integer $offset Offset |
| 297 | + * |
| 298 | + * @return boolean |
| 299 | + */ |
| 300 | + public function offsetExists($offset): bool |
| 301 | + { |
| 302 | + return isset($this->container[$offset]); |
| 303 | + } |
| 304 | + |
| 305 | + /** |
| 306 | + * Gets offset. |
| 307 | + * |
| 308 | + * @param integer $offset Offset |
| 309 | + * |
| 310 | + * @return mixed|null |
| 311 | + */ |
| 312 | + #[\ReturnTypeWillChange] |
| 313 | + public function offsetGet($offset) |
| 314 | + { |
| 315 | + return $this->container[$offset] ?? null; |
| 316 | + } |
| 317 | + |
| 318 | + /** |
| 319 | + * Sets value based on offset. |
| 320 | + * |
| 321 | + * @param int|null $offset Offset |
| 322 | + * @param mixed $value Value to be set |
| 323 | + * |
| 324 | + * @return void |
| 325 | + */ |
| 326 | + public function offsetSet($offset, $value): void |
| 327 | + { |
| 328 | + if (is_null($offset)) { |
| 329 | + $this->container[] = $value; |
| 330 | + } else { |
| 331 | + $this->container[$offset] = $value; |
| 332 | + } |
| 333 | + } |
| 334 | + |
| 335 | + /** |
| 336 | + * Unsets offset. |
| 337 | + * |
| 338 | + * @param integer $offset Offset |
| 339 | + * |
| 340 | + * @return void |
| 341 | + */ |
| 342 | + public function offsetUnset($offset): void |
| 343 | + { |
| 344 | + unset($this->container[$offset]); |
| 345 | + } |
| 346 | + |
| 347 | + /** |
| 348 | + * Serializes the object to a value that can be serialized natively by json_encode(). |
| 349 | + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php |
| 350 | + * |
| 351 | + * @return mixed Returns data which can be serialized by json_encode(), which is a value |
| 352 | + * of any type other than a resource. |
| 353 | + */ |
| 354 | + #[\ReturnTypeWillChange] |
| 355 | + public function jsonSerialize() |
| 356 | + { |
| 357 | + return ObjectSerializer::sanitizeForSerialization($this); |
| 358 | + } |
| 359 | + |
| 360 | + public function toArray(): array |
| 361 | + { |
| 362 | + $array = []; |
| 363 | + foreach (self::$openAPITypes as $propertyName => $propertyType) { |
| 364 | + $propertyValue = $this[$propertyName]; |
| 365 | + if ($propertyValue !== null) { |
| 366 | + // Check if the property value is an object and has a toArray() method |
| 367 | + if (is_object($propertyValue) && method_exists($propertyValue, 'toArray')) { |
| 368 | + $array[$propertyName] = $propertyValue->toArray(); |
| 369 | + // Check if it's type datetime |
| 370 | + } elseif ($propertyValue instanceof \DateTime) { |
| 371 | + $array[$propertyName] = $propertyValue->format(DATE_ATOM); |
| 372 | + // If it's an array type we should check whether it contains objects and if so call toArray method |
| 373 | + } elseif (is_array($propertyValue)) { |
| 374 | + $array[$propertyName] = array_map(function ($item) { |
| 375 | + return $item instanceof ModelInterface ? $item->toArray() : $item; |
| 376 | + }, $propertyValue); |
| 377 | + } else { |
| 378 | + // Otherwise, directly assign the property value to the array |
| 379 | + $array[$propertyName] = $propertyValue; |
| 380 | + } |
| 381 | + } |
| 382 | + } |
| 383 | + return $array; |
| 384 | + } |
| 385 | + |
| 386 | + /** |
| 387 | + * Gets the string presentation of the object |
| 388 | + * |
| 389 | + * @return string |
| 390 | + */ |
| 391 | + public function __toString() |
| 392 | + { |
| 393 | + return json_encode( |
| 394 | + ObjectSerializer::sanitizeForSerialization($this), |
| 395 | + JSON_PRETTY_PRINT |
| 396 | + ); |
| 397 | + } |
| 398 | +} |
0 commit comments