*/ class PostApiV3AdminCreditAdjustments200ResponseData implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; /** * The original name of the model. * * @var string */ protected static $openAPIModelName = 'post_api_v3_admin_credit_adjustments_200_response_data'; /** * Array of property to type mappings. Used for (de)serialization * * @var string[] */ protected static $openAPITypes = [ 'account_type' => 'string', 'account_id' => 'string', 'user' => '\WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser', 'delta' => 'int', 'kind' => 'string', 'bucket' => 'string', 'source' => 'string', 'ref' => 'string', 'day' => 'string', 'policy_version' => 'int', 'client_ip' => 'string', 'note' => 'string', 'operator' => '\WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser', 'created_at' => 'string', 'updated_at' => 'string' ]; /** * Array of property to format mappings. Used for (de)serialization * * @var string[] * @phpstan-var array * @psalm-var array */ protected static $openAPIFormats = [ 'account_type' => null, 'account_id' => null, 'user' => null, 'delta' => null, 'kind' => null, 'bucket' => null, 'source' => null, 'ref' => null, 'day' => null, 'policy_version' => null, 'client_ip' => null, 'note' => null, 'operator' => null, 'created_at' => null, 'updated_at' => null ]; /** * Array of nullable properties. Used for (de)serialization * * @var boolean[] */ protected static array $openAPINullables = [ 'account_type' => false, 'account_id' => false, 'user' => true, 'delta' => false, 'kind' => false, 'bucket' => false, 'source' => false, 'ref' => false, 'day' => false, 'policy_version' => false, 'client_ip' => true, 'note' => true, 'operator' => true, 'created_at' => false, 'updated_at' => false ]; /** * If a nullable field gets set to null, insert it here * * @var boolean[] */ protected array $openAPINullablesSetToNull = []; /** * Array of property to type mappings. Used for (de)serialization * * @return array */ public static function openAPITypes() { return self::$openAPITypes; } /** * Array of property to format mappings. Used for (de)serialization * * @return array */ public static function openAPIFormats() { return self::$openAPIFormats; } /** * Array of nullable properties * * @return array */ protected static function openAPINullables(): array { return self::$openAPINullables; } /** * Array of nullable field names deliberately set to null * * @return boolean[] */ private function getOpenAPINullablesSetToNull(): array { return $this->openAPINullablesSetToNull; } /** * Setter - Array of nullable field names deliberately set to null * * @param boolean[] $openAPINullablesSetToNull */ private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void { $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; } /** * Checks if a property is nullable * * @param string $property * @return bool */ public static function isNullable(string $property): bool { return self::openAPINullables()[$property] ?? false; } /** * Checks if a nullable property is set to null. * * @param string $property * @return bool */ public function isNullableSetToNull(string $property): bool { return in_array($property, $this->getOpenAPINullablesSetToNull(), true); } /** * Array of attributes where the key is the local name, * and the value is the original name * * @var string[] */ protected static $attributeMap = [ 'account_type' => 'account_type', 'account_id' => 'account_id', 'user' => 'user', 'delta' => 'delta', 'kind' => 'kind', 'bucket' => 'bucket', 'source' => 'source', 'ref' => 'ref', 'day' => 'day', 'policy_version' => 'policy_version', 'client_ip' => 'client_ip', 'note' => 'note', 'operator' => 'operator', 'created_at' => 'created_at', 'updated_at' => 'updated_at' ]; /** * Array of attributes to setter functions (for deserialization of responses) * * @var string[] */ protected static $setters = [ 'account_type' => 'setAccountType', 'account_id' => 'setAccountId', 'user' => 'setUser', 'delta' => 'setDelta', 'kind' => 'setKind', 'bucket' => 'setBucket', 'source' => 'setSource', 'ref' => 'setRef', 'day' => 'setDay', 'policy_version' => 'setPolicyVersion', 'client_ip' => 'setClientIp', 'note' => 'setNote', 'operator' => 'setOperator', 'created_at' => 'setCreatedAt', 'updated_at' => 'setUpdatedAt' ]; /** * Array of attributes to getter functions (for serialization of requests) * * @var string[] */ protected static $getters = [ 'account_type' => 'getAccountType', 'account_id' => 'getAccountId', 'user' => 'getUser', 'delta' => 'getDelta', 'kind' => 'getKind', 'bucket' => 'getBucket', 'source' => 'getSource', 'ref' => 'getRef', 'day' => 'getDay', 'policy_version' => 'getPolicyVersion', 'client_ip' => 'getClientIp', 'note' => 'getNote', 'operator' => 'getOperator', 'created_at' => 'getCreatedAt', 'updated_at' => 'getUpdatedAt' ]; /** * Array of attributes where the key is the local name, * and the value is the original name * * @return array */ public static function attributeMap() { return self::$attributeMap; } /** * Array of attributes to setter functions (for deserialization of responses) * * @return array */ public static function setters() { return self::$setters; } /** * Array of attributes to getter functions (for serialization of requests) * * @return array */ public static function getters() { return self::$getters; } /** * The original name of the model. * * @return string */ public function getModelName() { return self::$openAPIModelName; } public const ACCOUNT_TYPE_USER = 'user'; public const ACCOUNT_TYPE_GUEST = 'guest'; public const KIND_EARN = 'earn'; public const KIND_SPEND = 'spend'; public const KIND_REFUND = 'refund'; public const KIND_ADJUST = 'adjust'; public const BUCKET_FREE = 'free'; public const BUCKET_EARNED = 'earned'; public const SOURCE_READING = 'reading'; public const SOURCE_EDITING = 'editing'; public const SOURCE_AGENT_RUN = 'agent_run'; public const SOURCE_ADMIN = 'admin'; /** * Gets allowable values of the enum * * @return string[] */ public function getAccountTypeAllowableValues() { return [ self::ACCOUNT_TYPE_USER, self::ACCOUNT_TYPE_GUEST, ]; } /** * Gets allowable values of the enum * * @return string[] */ public function getKindAllowableValues() { return [ self::KIND_EARN, self::KIND_SPEND, self::KIND_REFUND, self::KIND_ADJUST, ]; } /** * Gets allowable values of the enum * * @return string[] */ public function getBucketAllowableValues() { return [ self::BUCKET_FREE, self::BUCKET_EARNED, ]; } /** * Gets allowable values of the enum * * @return string[] */ public function getSourceAllowableValues() { return [ self::SOURCE_READING, self::SOURCE_EDITING, self::SOURCE_AGENT_RUN, self::SOURCE_ADMIN, ]; } /** * Associative array for storing property values * * @var mixed[] */ protected $container = []; /** * Constructor * * @param mixed[]|null $data Associated array of property values * initializing the model */ public function __construct(?array $data = null) { $this->setIfExists('account_type', $data ?? [], null); $this->setIfExists('account_id', $data ?? [], null); $this->setIfExists('user', $data ?? [], null); $this->setIfExists('delta', $data ?? [], null); $this->setIfExists('kind', $data ?? [], null); $this->setIfExists('bucket', $data ?? [], null); $this->setIfExists('source', $data ?? [], null); $this->setIfExists('ref', $data ?? [], null); $this->setIfExists('day', $data ?? [], null); $this->setIfExists('policy_version', $data ?? [], null); $this->setIfExists('client_ip', $data ?? [], null); $this->setIfExists('note', $data ?? [], null); $this->setIfExists('operator', $data ?? [], null); $this->setIfExists('created_at', $data ?? [], null); $this->setIfExists('updated_at', $data ?? [], null); } /** * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the * $this->openAPINullablesSetToNull array * * @param string $variableName * @param array $fields * @param mixed $defaultValue */ private function setIfExists(string $variableName, array $fields, $defaultValue): void { if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { $this->openAPINullablesSetToNull[] = $variableName; } $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** * Show all the invalid properties with reasons. * * @return array invalid properties with reasons */ public function listInvalidProperties() { $invalidProperties = []; $allowedValues = $this->getAccountTypeAllowableValues(); if (!is_null($this->container['account_type']) && !in_array($this->container['account_type'], $allowedValues, true)) { $invalidProperties[] = sprintf( "invalid value '%s' for 'account_type', must be one of '%s'", $this->container['account_type'], implode("', '", $allowedValues) ); } $allowedValues = $this->getKindAllowableValues(); if (!is_null($this->container['kind']) && !in_array($this->container['kind'], $allowedValues, true)) { $invalidProperties[] = sprintf( "invalid value '%s' for 'kind', must be one of '%s'", $this->container['kind'], implode("', '", $allowedValues) ); } $allowedValues = $this->getBucketAllowableValues(); if (!is_null($this->container['bucket']) && !in_array($this->container['bucket'], $allowedValues, true)) { $invalidProperties[] = sprintf( "invalid value '%s' for 'bucket', must be one of '%s'", $this->container['bucket'], implode("', '", $allowedValues) ); } $allowedValues = $this->getSourceAllowableValues(); if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) { $invalidProperties[] = sprintf( "invalid value '%s' for 'source', must be one of '%s'", $this->container['source'], implode("', '", $allowedValues) ); } return $invalidProperties; } /** * Validate all the properties in the model * return true if all passed * * @return bool True if all properties are valid */ public function valid() { return count($this->listInvalidProperties()) === 0; } /** * Gets account_type * * @return string|null */ public function getAccountType() { return $this->container['account_type']; } /** * Sets account_type * * @param string|null $account_type account_type * * @return self */ public function setAccountType($account_type) { if (is_null($account_type)) { throw new \InvalidArgumentException('non-nullable account_type cannot be null'); } $allowedValues = $this->getAccountTypeAllowableValues(); if (!in_array($account_type, $allowedValues, true)) { throw new \InvalidArgumentException( sprintf( "Invalid value '%s' for 'account_type', must be one of '%s'", $account_type, implode("', '", $allowedValues) ) ); } $this->container['account_type'] = $account_type; return $this; } /** * Gets account_id * * @return string|null */ public function getAccountId() { return $this->container['account_id']; } /** * Sets account_id * * @param string|null $account_id account_id * * @return self */ public function setAccountId($account_id) { if (is_null($account_id)) { throw new \InvalidArgumentException('non-nullable account_id cannot be null'); } $this->container['account_id'] = $account_id; return $this; } /** * Gets user * * @return \WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser|null */ public function getUser() { return $this->container['user']; } /** * Sets user * * @param \WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser|null $user user * * @return self */ public function setUser($user) { if (is_null($user)) { array_push($this->openAPINullablesSetToNull, 'user'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); $index = array_search('user', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } $this->container['user'] = $user; return $this; } /** * Gets delta * * @return int|null */ public function getDelta() { return $this->container['delta']; } /** * Sets delta * * @param int|null $delta delta * * @return self */ public function setDelta($delta) { if (is_null($delta)) { throw new \InvalidArgumentException('non-nullable delta cannot be null'); } $this->container['delta'] = $delta; return $this; } /** * Gets kind * * @return string|null */ public function getKind() { return $this->container['kind']; } /** * Sets kind * * @param string|null $kind kind * * @return self */ public function setKind($kind) { if (is_null($kind)) { throw new \InvalidArgumentException('non-nullable kind cannot be null'); } $allowedValues = $this->getKindAllowableValues(); if (!in_array($kind, $allowedValues, true)) { throw new \InvalidArgumentException( sprintf( "Invalid value '%s' for 'kind', must be one of '%s'", $kind, implode("', '", $allowedValues) ) ); } $this->container['kind'] = $kind; return $this; } /** * Gets bucket * * @return string|null */ public function getBucket() { return $this->container['bucket']; } /** * Sets bucket * * @param string|null $bucket bucket * * @return self */ public function setBucket($bucket) { if (is_null($bucket)) { throw new \InvalidArgumentException('non-nullable bucket cannot be null'); } $allowedValues = $this->getBucketAllowableValues(); if (!in_array($bucket, $allowedValues, true)) { throw new \InvalidArgumentException( sprintf( "Invalid value '%s' for 'bucket', must be one of '%s'", $bucket, implode("', '", $allowedValues) ) ); } $this->container['bucket'] = $bucket; return $this; } /** * Gets source * * @return string|null */ public function getSource() { return $this->container['source']; } /** * Sets source * * @param string|null $source source * * @return self */ public function setSource($source) { if (is_null($source)) { throw new \InvalidArgumentException('non-nullable source cannot be null'); } $allowedValues = $this->getSourceAllowableValues(); if (!in_array($source, $allowedValues, true)) { throw new \InvalidArgumentException( sprintf( "Invalid value '%s' for 'source', must be one of '%s'", $source, implode("', '", $allowedValues) ) ); } $this->container['source'] = $source; return $this; } /** * Gets ref * * @return string|null */ public function getRef() { return $this->container['ref']; } /** * Sets ref * * @param string|null $ref ref * * @return self */ public function setRef($ref) { if (is_null($ref)) { throw new \InvalidArgumentException('non-nullable ref cannot be null'); } $this->container['ref'] = $ref; return $this; } /** * Gets day * * @return string|null */ public function getDay() { return $this->container['day']; } /** * Sets day * * @param string|null $day day * * @return self */ public function setDay($day) { if (is_null($day)) { throw new \InvalidArgumentException('non-nullable day cannot be null'); } $this->container['day'] = $day; return $this; } /** * Gets policy_version * * @return int|null */ public function getPolicyVersion() { return $this->container['policy_version']; } /** * Sets policy_version * * @param int|null $policy_version policy_version * * @return self */ public function setPolicyVersion($policy_version) { if (is_null($policy_version)) { throw new \InvalidArgumentException('non-nullable policy_version cannot be null'); } $this->container['policy_version'] = $policy_version; return $this; } /** * Gets client_ip * * @return string|null */ public function getClientIp() { return $this->container['client_ip']; } /** * Sets client_ip * * @param string|null $client_ip client_ip * * @return self */ public function setClientIp($client_ip) { if (is_null($client_ip)) { array_push($this->openAPINullablesSetToNull, 'client_ip'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); $index = array_search('client_ip', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } $this->container['client_ip'] = $client_ip; return $this; } /** * Gets note * * @return string|null */ public function getNote() { return $this->container['note']; } /** * Sets note * * @param string|null $note note * * @return self */ public function setNote($note) { if (is_null($note)) { array_push($this->openAPINullablesSetToNull, 'note'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); $index = array_search('note', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } $this->container['note'] = $note; return $this; } /** * Gets operator * * @return \WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser|null */ public function getOperator() { return $this->container['operator']; } /** * Sets operator * * @param \WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser|null $operator operator * * @return self */ public function setOperator($operator) { if (is_null($operator)) { array_push($this->openAPINullablesSetToNull, 'operator'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); $index = array_search('operator', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } $this->container['operator'] = $operator; return $this; } /** * Gets created_at * * @return string|null */ public function getCreatedAt() { return $this->container['created_at']; } /** * Sets created_at * * @param string|null $created_at created_at * * @return self */ public function setCreatedAt($created_at) { if (is_null($created_at)) { throw new \InvalidArgumentException('non-nullable created_at cannot be null'); } $this->container['created_at'] = $created_at; return $this; } /** * Gets updated_at * * @return string|null */ public function getUpdatedAt() { return $this->container['updated_at']; } /** * Sets updated_at * * @param string|null $updated_at updated_at * * @return self */ public function setUpdatedAt($updated_at) { if (is_null($updated_at)) { throw new \InvalidArgumentException('non-nullable updated_at cannot be null'); } $this->container['updated_at'] = $updated_at; return $this; } /** * Returns true if offset exists. False otherwise. * * @param integer|string $offset Offset * * @return boolean */ public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } /** * Gets offset. * * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } /** * Sets value based on offset. * * @param int|null $offset Offset * @param mixed $value Value to be set * * @return void */ public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; } else { $this->container[$offset] = $value; } } /** * Unsets offset. * * @param integer|string $offset Offset * * @return void */ public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } /** * Serializes the object to a value that can be serialized natively by json_encode(). * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php * * @return mixed Returns data which can be serialized by json_encode(), which is a value * of any type other than a resource. */ #[\ReturnTypeWillChange] public function jsonSerialize() { return ObjectSerializer::sanitizeForSerialization($this); } /** * Gets the string presentation of the object * * @return string */ public function __toString() { return json_encode( ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT ); } /** * Gets a header-safe presentation of the object * * @return string */ public function toHeaderValue() { return json_encode(ObjectSerializer::sanitizeForSerialization($this)); } }