<?php

/**
 * GetAccountResponse.
 *
 * PHP version 8.1
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 */

/**
 * Binance Spot REST API.
 *
 * OpenAPI Specifications for the Binance Spot REST API  API documents:   - [Github rest-api documentation file](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md)   - [General API information for rest-api on website](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-api-information)
 *
 * The version of the OpenAPI document: 1.0.0
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.12.0
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace Binance\Client\Spot\Model;

use Binance\Common\Dtos\ModelInterface;
use Binance\Common\ObjectSerializer;

/**
 * GetAccountResponse Class Doc Comment.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 *
 * @implements \ArrayAccess<string, mixed>
 */
class GetAccountResponse implements ModelInterface, \ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

    /**
     * The original name of the model.
     *
     * @var string
     */
    protected static $openAPIModelName = 'getAccountResponse';

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'makerCommission' => 'int',
        'takerCommission' => 'int',
        'buyerCommission' => 'int',
        'sellerCommission' => 'int',
        'commissionRates' => '\Binance\Client\Spot\Model\GetAccountResponseCommissionRates',
        'canTrade' => 'bool',
        'canWithdraw' => 'bool',
        'canDeposit' => 'bool',
        'brokered' => 'bool',
        'requireSelfTradePrevention' => 'bool',
        'preventSor' => 'bool',
        'updateTime' => 'int',
        'accountType' => 'string',
        'balances' => '\Binance\Client\Spot\Model\GetAccountResponseBalancesInner[]',
        'permissions' => 'string[]',
        'uid' => 'int',
    ];

    /**
     * Array of property to format mappings. Used for (de)serialization.
     *
     * @var string[]
     *
     * @phpstan-var array<string, string|null>
     *
     * @psalm-var array<string, string|null>
     */
    protected static $openAPIFormats = [
        'makerCommission' => 'int64',
        'takerCommission' => 'int64',
        'buyerCommission' => 'int64',
        'sellerCommission' => 'int64',
        'commissionRates' => null,
        'canTrade' => null,
        'canWithdraw' => null,
        'canDeposit' => null,
        'brokered' => null,
        'requireSelfTradePrevention' => null,
        'preventSor' => null,
        'updateTime' => 'int64',
        'accountType' => null,
        'balances' => null,
        'permissions' => null,
        'uid' => 'int64',
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'makerCommission' => false,
        'takerCommission' => false,
        'buyerCommission' => false,
        'sellerCommission' => false,
        'commissionRates' => false,
        'canTrade' => false,
        'canWithdraw' => false,
        'canDeposit' => false,
        'brokered' => false,
        'requireSelfTradePrevention' => false,
        'preventSor' => false,
        'updateTime' => false,
        'accountType' => false,
        'balances' => false,
        'permissions' => false,
        'uid' => false,
    ];

    /**
     * If a nullable field gets set to null, insert it here.
     *
     * @var bool[]
     */
    protected array $openAPINullablesSetToNull = [];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name.
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'makerCommission' => 'makerCommission',
        'takerCommission' => 'takerCommission',
        'buyerCommission' => 'buyerCommission',
        'sellerCommission' => 'sellerCommission',
        'commissionRates' => 'commissionRates',
        'canTrade' => 'canTrade',
        'canWithdraw' => 'canWithdraw',
        'canDeposit' => 'canDeposit',
        'brokered' => 'brokered',
        'requireSelfTradePrevention' => 'requireSelfTradePrevention',
        'preventSor' => 'preventSor',
        'updateTime' => 'updateTime',
        'accountType' => 'accountType',
        'balances' => 'balances',
        'permissions' => 'permissions',
        'uid' => 'uid',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'makerCommission' => 'setMakerCommission',
        'takerCommission' => 'setTakerCommission',
        'buyerCommission' => 'setBuyerCommission',
        'sellerCommission' => 'setSellerCommission',
        'commissionRates' => 'setCommissionRates',
        'canTrade' => 'setCanTrade',
        'canWithdraw' => 'setCanWithdraw',
        'canDeposit' => 'setCanDeposit',
        'brokered' => 'setBrokered',
        'requireSelfTradePrevention' => 'setRequireSelfTradePrevention',
        'preventSor' => 'setPreventSor',
        'updateTime' => 'setUpdateTime',
        'accountType' => 'setAccountType',
        'balances' => 'setBalances',
        'permissions' => 'setPermissions',
        'uid' => 'setUid',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'makerCommission' => 'getMakerCommission',
        'takerCommission' => 'getTakerCommission',
        'buyerCommission' => 'getBuyerCommission',
        'sellerCommission' => 'getSellerCommission',
        'commissionRates' => 'getCommissionRates',
        'canTrade' => 'getCanTrade',
        'canWithdraw' => 'getCanWithdraw',
        'canDeposit' => 'getCanDeposit',
        'brokered' => 'getBrokered',
        'requireSelfTradePrevention' => 'getRequireSelfTradePrevention',
        'preventSor' => 'getPreventSor',
        'updateTime' => 'getUpdateTime',
        'accountType' => 'getAccountType',
        'balances' => 'getBalances',
        'permissions' => 'getPermissions',
        'uid' => 'getUid',
    ];

    /**
     * Associative array for storing property values.
     *
     * @var mixed[]
     */
    protected $container = [];

    /**
     * Constructor.
     *
     * @param null|mixed[] $data Associated array of property values
     *                           initializing the model
     */
    public function __construct(?array $data = null)
    {
        $this->setIfExists('makerCommission', $data ?? [], null);
        $this->setIfExists('takerCommission', $data ?? [], null);
        $this->setIfExists('buyerCommission', $data ?? [], null);
        $this->setIfExists('sellerCommission', $data ?? [], null);
        $this->setIfExists('commissionRates', $data ?? [], null);
        $this->setIfExists('canTrade', $data ?? [], null);
        $this->setIfExists('canWithdraw', $data ?? [], null);
        $this->setIfExists('canDeposit', $data ?? [], null);
        $this->setIfExists('brokered', $data ?? [], null);
        $this->setIfExists('requireSelfTradePrevention', $data ?? [], null);
        $this->setIfExists('preventSor', $data ?? [], null);
        $this->setIfExists('updateTime', $data ?? [], null);
        $this->setIfExists('accountType', $data ?? [], null);
        $this->setIfExists('balances', $data ?? [], null);
        $this->setIfExists('permissions', $data ?? [], null);
        $this->setIfExists('uid', $data ?? [], null);
    }

    /**
     * Gets the string presentation of the object.
     *
     * @return string
     */
    public function __toString()
    {
        return json_encode(
            ObjectSerializer::sanitizeForSerialization($this),
            JSON_PRETTY_PRINT
        );
    }

    /**
     * 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;
    }

    /**
     * If oneOf schema, get the possible response types.
     */
    public static function getComposedSchemas(): array
    {
        return [
        ];
    }

    /**
     * Return true if the model is an array.
     */
    public static function isArray(): bool
    {
        return false;
    }

    /**
     * Checks if a property is nullable.
     */
    public static function isNullable(string $property): bool
    {
        return self::openAPINullables()[$property] ?? false;
    }

    /**
     * Checks if a nullable property is set to null.
     */
    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.
     *
     * @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;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        return [];
    }

    /**
     * Validate all the properties in the model
     * return true if all passed.
     *
     * @return bool True if all properties are valid
     */
    public function valid()
    {
        return 0 === count($this->listInvalidProperties());
    }

    /**
     * Gets makerCommission.
     *
     * @return null|int
     */
    public function getMakerCommission()
    {
        return $this->container['makerCommission'];
    }

    /**
     * Sets makerCommission.
     *
     * @param null|int $makerCommission makerCommission
     *
     * @return self
     */
    public function setMakerCommission($makerCommission)
    {
        if (is_null($makerCommission)) {
            throw new \InvalidArgumentException('non-nullable makerCommission cannot be null');
        }
        $this->container['makerCommission'] = $makerCommission;

        return $this;
    }

    /**
     * Gets takerCommission.
     *
     * @return null|int
     */
    public function getTakerCommission()
    {
        return $this->container['takerCommission'];
    }

    /**
     * Sets takerCommission.
     *
     * @param null|int $takerCommission takerCommission
     *
     * @return self
     */
    public function setTakerCommission($takerCommission)
    {
        if (is_null($takerCommission)) {
            throw new \InvalidArgumentException('non-nullable takerCommission cannot be null');
        }
        $this->container['takerCommission'] = $takerCommission;

        return $this;
    }

    /**
     * Gets buyerCommission.
     *
     * @return null|int
     */
    public function getBuyerCommission()
    {
        return $this->container['buyerCommission'];
    }

    /**
     * Sets buyerCommission.
     *
     * @param null|int $buyerCommission buyerCommission
     *
     * @return self
     */
    public function setBuyerCommission($buyerCommission)
    {
        if (is_null($buyerCommission)) {
            throw new \InvalidArgumentException('non-nullable buyerCommission cannot be null');
        }
        $this->container['buyerCommission'] = $buyerCommission;

        return $this;
    }

    /**
     * Gets sellerCommission.
     *
     * @return null|int
     */
    public function getSellerCommission()
    {
        return $this->container['sellerCommission'];
    }

    /**
     * Sets sellerCommission.
     *
     * @param null|int $sellerCommission sellerCommission
     *
     * @return self
     */
    public function setSellerCommission($sellerCommission)
    {
        if (is_null($sellerCommission)) {
            throw new \InvalidArgumentException('non-nullable sellerCommission cannot be null');
        }
        $this->container['sellerCommission'] = $sellerCommission;

        return $this;
    }

    /**
     * Gets commissionRates.
     *
     * @return null|GetAccountResponseCommissionRates
     */
    public function getCommissionRates()
    {
        return $this->container['commissionRates'];
    }

    /**
     * Sets commissionRates.
     *
     * @param null|GetAccountResponseCommissionRates $commissionRates commissionRates
     *
     * @return self
     */
    public function setCommissionRates($commissionRates)
    {
        if (is_null($commissionRates)) {
            throw new \InvalidArgumentException('non-nullable commissionRates cannot be null');
        }
        $this->container['commissionRates'] = $commissionRates;

        return $this;
    }

    /**
     * Gets canTrade.
     *
     * @return null|bool
     */
    public function getCanTrade()
    {
        return $this->container['canTrade'];
    }

    /**
     * Sets canTrade.
     *
     * @param null|bool $canTrade canTrade
     *
     * @return self
     */
    public function setCanTrade($canTrade)
    {
        if (is_null($canTrade)) {
            throw new \InvalidArgumentException('non-nullable canTrade cannot be null');
        }
        $this->container['canTrade'] = $canTrade;

        return $this;
    }

    /**
     * Gets canWithdraw.
     *
     * @return null|bool
     */
    public function getCanWithdraw()
    {
        return $this->container['canWithdraw'];
    }

    /**
     * Sets canWithdraw.
     *
     * @param null|bool $canWithdraw canWithdraw
     *
     * @return self
     */
    public function setCanWithdraw($canWithdraw)
    {
        if (is_null($canWithdraw)) {
            throw new \InvalidArgumentException('non-nullable canWithdraw cannot be null');
        }
        $this->container['canWithdraw'] = $canWithdraw;

        return $this;
    }

    /**
     * Gets canDeposit.
     *
     * @return null|bool
     */
    public function getCanDeposit()
    {
        return $this->container['canDeposit'];
    }

    /**
     * Sets canDeposit.
     *
     * @param null|bool $canDeposit canDeposit
     *
     * @return self
     */
    public function setCanDeposit($canDeposit)
    {
        if (is_null($canDeposit)) {
            throw new \InvalidArgumentException('non-nullable canDeposit cannot be null');
        }
        $this->container['canDeposit'] = $canDeposit;

        return $this;
    }

    /**
     * Gets brokered.
     *
     * @return null|bool
     */
    public function getBrokered()
    {
        return $this->container['brokered'];
    }

    /**
     * Sets brokered.
     *
     * @param null|bool $brokered brokered
     *
     * @return self
     */
    public function setBrokered($brokered)
    {
        if (is_null($brokered)) {
            throw new \InvalidArgumentException('non-nullable brokered cannot be null');
        }
        $this->container['brokered'] = $brokered;

        return $this;
    }

    /**
     * Gets requireSelfTradePrevention.
     *
     * @return null|bool
     */
    public function getRequireSelfTradePrevention()
    {
        return $this->container['requireSelfTradePrevention'];
    }

    /**
     * Sets requireSelfTradePrevention.
     *
     * @param null|bool $requireSelfTradePrevention requireSelfTradePrevention
     *
     * @return self
     */
    public function setRequireSelfTradePrevention($requireSelfTradePrevention)
    {
        if (is_null($requireSelfTradePrevention)) {
            throw new \InvalidArgumentException('non-nullable requireSelfTradePrevention cannot be null');
        }
        $this->container['requireSelfTradePrevention'] = $requireSelfTradePrevention;

        return $this;
    }

    /**
     * Gets preventSor.
     *
     * @return null|bool
     */
    public function getPreventSor()
    {
        return $this->container['preventSor'];
    }

    /**
     * Sets preventSor.
     *
     * @param null|bool $preventSor preventSor
     *
     * @return self
     */
    public function setPreventSor($preventSor)
    {
        if (is_null($preventSor)) {
            throw new \InvalidArgumentException('non-nullable preventSor cannot be null');
        }
        $this->container['preventSor'] = $preventSor;

        return $this;
    }

    /**
     * Gets updateTime.
     *
     * @return null|int
     */
    public function getUpdateTime()
    {
        return $this->container['updateTime'];
    }

    /**
     * Sets updateTime.
     *
     * @param null|int $updateTime updateTime
     *
     * @return self
     */
    public function setUpdateTime($updateTime)
    {
        if (is_null($updateTime)) {
            throw new \InvalidArgumentException('non-nullable updateTime cannot be null');
        }
        $this->container['updateTime'] = $updateTime;

        return $this;
    }

    /**
     * Gets accountType.
     *
     * @return null|string
     */
    public function getAccountType()
    {
        return $this->container['accountType'];
    }

    /**
     * Sets accountType.
     *
     * @param null|string $accountType accountType
     *
     * @return self
     */
    public function setAccountType($accountType)
    {
        if (is_null($accountType)) {
            throw new \InvalidArgumentException('non-nullable accountType cannot be null');
        }
        $this->container['accountType'] = $accountType;

        return $this;
    }

    /**
     * Gets balances.
     *
     * @return null|GetAccountResponseBalancesInner[]
     */
    public function getBalances()
    {
        return $this->container['balances'];
    }

    /**
     * Sets balances.
     *
     * @param null|GetAccountResponseBalancesInner[] $balances balances
     *
     * @return self
     */
    public function setBalances($balances)
    {
        if (is_null($balances)) {
            throw new \InvalidArgumentException('non-nullable balances cannot be null');
        }
        $this->container['balances'] = $balances;

        return $this;
    }

    /**
     * Gets permissions.
     *
     * @return null|string[]
     */
    public function getPermissions()
    {
        return $this->container['permissions'];
    }

    /**
     * Sets permissions.
     *
     * @param null|string[] $permissions permissions
     *
     * @return self
     */
    public function setPermissions($permissions)
    {
        if (is_null($permissions)) {
            throw new \InvalidArgumentException('non-nullable permissions cannot be null');
        }
        $this->container['permissions'] = $permissions;

        return $this;
    }

    /**
     * Gets uid.
     *
     * @return null|int
     */
    public function getUid()
    {
        return $this->container['uid'];
    }

    /**
     * Sets uid.
     *
     * @param null|int $uid uid
     *
     * @return self
     */
    public function setUid($uid)
    {
        if (is_null($uid)) {
            throw new \InvalidArgumentException('non-nullable uid cannot be null');
        }
        $this->container['uid'] = $uid;

        return $this;
    }

    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param int $offset Offset
     */
    public function offsetExists($offset): bool
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param int $offset Offset
     *
     * @return null|mixed
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($offset)
    {
        return $this->container[$offset] ?? null;
    }

    /**
     * Sets value based on offset.
     *
     * @param null|int $offset Offset
     * @param mixed    $value  Value to be set
     */
    public function offsetSet($offset, $value): void
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param int $offset Offset
     */
    public function offsetUnset($offset): void
    {
        unset($this->container[$offset]);
    }

    /**
     * Serializes the object to a value that can be serialized natively by json_encode().
     *
     * @see 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 a header-safe presentation of the object.
     *
     * @return string
     */
    public function toHeaderValue()
    {
        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }

    /**
     * Array of nullable properties.
     */
    protected static function openAPINullables(): array
    {
        return self::$openAPINullables;
    }

    /**
     * Array of nullable field names deliberately set to null.
     *
     * @return bool[]
     */
    private function getOpenAPINullablesSetToNull(): array
    {
        return $this->openAPINullablesSetToNull;
    }

    /**
     * Setter - Array of nullable field names deliberately set to null.
     *
     * @param bool[] $openAPINullablesSetToNull
     */
    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
    {
        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
    }

    /**
     * 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 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;
    }
}
