<?php

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

/**
 * Binance Margin Trading REST API.
 *
 * OpenAPI Specification for the Binance Margin Trading REST API
 *
 * 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\MarginTrading\Model;

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

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'baseAsset' => '\Binance\Client\MarginTrading\Model\QueryIsolatedMarginAccountInfoResponseAssetsInnerBaseAsset',
        'quoteAsset' => '\Binance\Client\MarginTrading\Model\QueryIsolatedMarginAccountInfoResponseAssetsInnerQuoteAsset',
        'symbol' => 'string',
        'isolatedCreated' => 'bool',
        'enabled' => 'bool',
        'marginLevel' => 'string',
        'marginLevelStatus' => 'string',
        'marginRatio' => 'string',
        'indexPrice' => 'string',
        'liquidatePrice' => 'string',
        'liquidateRate' => 'string',
        'tradeEnabled' => 'bool',
    ];

    /**
     * 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 = [
        'baseAsset' => null,
        'quoteAsset' => null,
        'symbol' => null,
        'isolatedCreated' => null,
        'enabled' => null,
        'marginLevel' => null,
        'marginLevelStatus' => null,
        'marginRatio' => null,
        'indexPrice' => null,
        'liquidatePrice' => null,
        'liquidateRate' => null,
        'tradeEnabled' => null,
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'baseAsset' => false,
        'quoteAsset' => false,
        'symbol' => false,
        'isolatedCreated' => false,
        'enabled' => false,
        'marginLevel' => false,
        'marginLevelStatus' => false,
        'marginRatio' => false,
        'indexPrice' => false,
        'liquidatePrice' => false,
        'liquidateRate' => false,
        'tradeEnabled' => 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 = [
        'baseAsset' => 'baseAsset',
        'quoteAsset' => 'quoteAsset',
        'symbol' => 'symbol',
        'isolatedCreated' => 'isolatedCreated',
        'enabled' => 'enabled',
        'marginLevel' => 'marginLevel',
        'marginLevelStatus' => 'marginLevelStatus',
        'marginRatio' => 'marginRatio',
        'indexPrice' => 'indexPrice',
        'liquidatePrice' => 'liquidatePrice',
        'liquidateRate' => 'liquidateRate',
        'tradeEnabled' => 'tradeEnabled',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'baseAsset' => 'setBaseAsset',
        'quoteAsset' => 'setQuoteAsset',
        'symbol' => 'setSymbol',
        'isolatedCreated' => 'setIsolatedCreated',
        'enabled' => 'setEnabled',
        'marginLevel' => 'setMarginLevel',
        'marginLevelStatus' => 'setMarginLevelStatus',
        'marginRatio' => 'setMarginRatio',
        'indexPrice' => 'setIndexPrice',
        'liquidatePrice' => 'setLiquidatePrice',
        'liquidateRate' => 'setLiquidateRate',
        'tradeEnabled' => 'setTradeEnabled',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'baseAsset' => 'getBaseAsset',
        'quoteAsset' => 'getQuoteAsset',
        'symbol' => 'getSymbol',
        'isolatedCreated' => 'getIsolatedCreated',
        'enabled' => 'getEnabled',
        'marginLevel' => 'getMarginLevel',
        'marginLevelStatus' => 'getMarginLevelStatus',
        'marginRatio' => 'getMarginRatio',
        'indexPrice' => 'getIndexPrice',
        'liquidatePrice' => 'getLiquidatePrice',
        'liquidateRate' => 'getLiquidateRate',
        'tradeEnabled' => 'getTradeEnabled',
    ];

    /**
     * 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('baseAsset', $data ?? [], null);
        $this->setIfExists('quoteAsset', $data ?? [], null);
        $this->setIfExists('symbol', $data ?? [], null);
        $this->setIfExists('isolatedCreated', $data ?? [], null);
        $this->setIfExists('enabled', $data ?? [], null);
        $this->setIfExists('marginLevel', $data ?? [], null);
        $this->setIfExists('marginLevelStatus', $data ?? [], null);
        $this->setIfExists('marginRatio', $data ?? [], null);
        $this->setIfExists('indexPrice', $data ?? [], null);
        $this->setIfExists('liquidatePrice', $data ?? [], null);
        $this->setIfExists('liquidateRate', $data ?? [], null);
        $this->setIfExists('tradeEnabled', $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 baseAsset.
     *
     * @return null|QueryIsolatedMarginAccountInfoResponseAssetsInnerBaseAsset
     */
    public function getBaseAsset()
    {
        return $this->container['baseAsset'];
    }

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

        return $this;
    }

    /**
     * Gets quoteAsset.
     *
     * @return null|QueryIsolatedMarginAccountInfoResponseAssetsInnerQuoteAsset
     */
    public function getQuoteAsset()
    {
        return $this->container['quoteAsset'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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