<?php

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

/**
 * Binance Derivatives Trading COIN Futures REST API.
 *
 * OpenAPI Specification for the Binance Derivatives Trading COIN Futures 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\DerivativesTradingCoinFutures\Model;

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

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'symbol' => 'string',
        'positionAmt' => 'string',
        'entryPrice' => 'string',
        'breakEvenPrice' => 'string',
        'markPrice' => 'string',
        'unRealizedProfit' => 'string',
        'liquidationPrice' => 'string',
        'leverage' => 'string',
        'maxQty' => 'string',
        'marginType' => 'string',
        'isolatedMargin' => 'string',
        'isAutoAddMargin' => 'string',
        'positionSide' => 'string',
        'updateTime' => '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 = [
        'symbol' => null,
        'positionAmt' => null,
        'entryPrice' => null,
        'breakEvenPrice' => null,
        'markPrice' => null,
        'unRealizedProfit' => null,
        'liquidationPrice' => null,
        'leverage' => null,
        'maxQty' => null,
        'marginType' => null,
        'isolatedMargin' => null,
        'isAutoAddMargin' => null,
        'positionSide' => null,
        'updateTime' => 'int64',
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'symbol' => false,
        'positionAmt' => false,
        'entryPrice' => false,
        'breakEvenPrice' => false,
        'markPrice' => false,
        'unRealizedProfit' => false,
        'liquidationPrice' => false,
        'leverage' => false,
        'maxQty' => false,
        'marginType' => false,
        'isolatedMargin' => false,
        'isAutoAddMargin' => false,
        'positionSide' => false,
        'updateTime' => 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 = [
        'symbol' => 'symbol',
        'positionAmt' => 'positionAmt',
        'entryPrice' => 'entryPrice',
        'breakEvenPrice' => 'breakEvenPrice',
        'markPrice' => 'markPrice',
        'unRealizedProfit' => 'unRealizedProfit',
        'liquidationPrice' => 'liquidationPrice',
        'leverage' => 'leverage',
        'maxQty' => 'maxQty',
        'marginType' => 'marginType',
        'isolatedMargin' => 'isolatedMargin',
        'isAutoAddMargin' => 'isAutoAddMargin',
        'positionSide' => 'positionSide',
        'updateTime' => 'updateTime',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'symbol' => 'setSymbol',
        'positionAmt' => 'setPositionAmt',
        'entryPrice' => 'setEntryPrice',
        'breakEvenPrice' => 'setBreakEvenPrice',
        'markPrice' => 'setMarkPrice',
        'unRealizedProfit' => 'setUnRealizedProfit',
        'liquidationPrice' => 'setLiquidationPrice',
        'leverage' => 'setLeverage',
        'maxQty' => 'setMaxQty',
        'marginType' => 'setMarginType',
        'isolatedMargin' => 'setIsolatedMargin',
        'isAutoAddMargin' => 'setIsAutoAddMargin',
        'positionSide' => 'setPositionSide',
        'updateTime' => 'setUpdateTime',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'symbol' => 'getSymbol',
        'positionAmt' => 'getPositionAmt',
        'entryPrice' => 'getEntryPrice',
        'breakEvenPrice' => 'getBreakEvenPrice',
        'markPrice' => 'getMarkPrice',
        'unRealizedProfit' => 'getUnRealizedProfit',
        'liquidationPrice' => 'getLiquidationPrice',
        'leverage' => 'getLeverage',
        'maxQty' => 'getMaxQty',
        'marginType' => 'getMarginType',
        'isolatedMargin' => 'getIsolatedMargin',
        'isAutoAddMargin' => 'getIsAutoAddMargin',
        'positionSide' => 'getPositionSide',
        'updateTime' => 'getUpdateTime',
    ];

    /**
     * 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('symbol', $data ?? [], null);
        $this->setIfExists('positionAmt', $data ?? [], null);
        $this->setIfExists('entryPrice', $data ?? [], null);
        $this->setIfExists('breakEvenPrice', $data ?? [], null);
        $this->setIfExists('markPrice', $data ?? [], null);
        $this->setIfExists('unRealizedProfit', $data ?? [], null);
        $this->setIfExists('liquidationPrice', $data ?? [], null);
        $this->setIfExists('leverage', $data ?? [], null);
        $this->setIfExists('maxQty', $data ?? [], null);
        $this->setIfExists('marginType', $data ?? [], null);
        $this->setIfExists('isolatedMargin', $data ?? [], null);
        $this->setIfExists('isAutoAddMargin', $data ?? [], null);
        $this->setIfExists('positionSide', $data ?? [], null);
        $this->setIfExists('updateTime', $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 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 positionAmt.
     *
     * @return null|string
     */
    public function getPositionAmt()
    {
        return $this->container['positionAmt'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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

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