<?php

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

/**
 * Binance Sub Account REST API.
 *
 * OpenAPI Specification for the Binance Sub Account 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\SubAccount\Model;

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

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'coin' => 'string',
        'name' => 'string',
        'totalBalance' => 'string',
        'availableBalance' => 'string',
        'inOrder' => 'string',
        'btcValue' => 'string',
    ];

    /**
     * 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 = [
        'coin' => null,
        'name' => null,
        'totalBalance' => null,
        'availableBalance' => null,
        'inOrder' => null,
        'btcValue' => null,
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'coin' => false,
        'name' => false,
        'totalBalance' => false,
        'availableBalance' => false,
        'inOrder' => false,
        'btcValue' => 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 = [
        'coin' => 'coin',
        'name' => 'name',
        'totalBalance' => 'totalBalance',
        'availableBalance' => 'availableBalance',
        'inOrder' => 'inOrder',
        'btcValue' => 'btcValue',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'coin' => 'setCoin',
        'name' => 'setName',
        'totalBalance' => 'setTotalBalance',
        'availableBalance' => 'setAvailableBalance',
        'inOrder' => 'setInOrder',
        'btcValue' => 'setBtcValue',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'coin' => 'getCoin',
        'name' => 'getName',
        'totalBalance' => 'getTotalBalance',
        'availableBalance' => 'getAvailableBalance',
        'inOrder' => 'getInOrder',
        'btcValue' => 'getBtcValue',
    ];

    /**
     * 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('coin', $data ?? [], null);
        $this->setIfExists('name', $data ?? [], null);
        $this->setIfExists('totalBalance', $data ?? [], null);
        $this->setIfExists('availableBalance', $data ?? [], null);
        $this->setIfExists('inOrder', $data ?? [], null);
        $this->setIfExists('btcValue', $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 coin.
     *
     * @return null|string
     */
    public function getCoin()
    {
        return $this->container['coin'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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