<?php

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

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

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

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'id' => 'string',
        'currency' => 'string',
        'symbol' => 'string',
        'exercisePrice' => 'string',
        'markPrice' => 'string',
        'quantity' => 'string',
        'amount' => 'string',
        'fee' => 'string',
        'createDate' => 'int',
        'priceScale' => 'int',
        'quantityScale' => 'int',
        'optionSide' => 'string',
        'positionSide' => 'string',
        'quoteAsset' => '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 = [
        'id' => null,
        'currency' => null,
        'symbol' => null,
        'exercisePrice' => null,
        'markPrice' => null,
        'quantity' => null,
        'amount' => null,
        'fee' => null,
        'createDate' => 'int64',
        'priceScale' => 'int64',
        'quantityScale' => 'int64',
        'optionSide' => null,
        'positionSide' => null,
        'quoteAsset' => null,
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'id' => false,
        'currency' => false,
        'symbol' => false,
        'exercisePrice' => false,
        'markPrice' => false,
        'quantity' => false,
        'amount' => false,
        'fee' => false,
        'createDate' => false,
        'priceScale' => false,
        'quantityScale' => false,
        'optionSide' => false,
        'positionSide' => false,
        'quoteAsset' => 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 = [
        'id' => 'id',
        'currency' => 'currency',
        'symbol' => 'symbol',
        'exercisePrice' => 'exercisePrice',
        'markPrice' => 'markPrice',
        'quantity' => 'quantity',
        'amount' => 'amount',
        'fee' => 'fee',
        'createDate' => 'createDate',
        'priceScale' => 'priceScale',
        'quantityScale' => 'quantityScale',
        'optionSide' => 'optionSide',
        'positionSide' => 'positionSide',
        'quoteAsset' => 'quoteAsset',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'id' => 'setId',
        'currency' => 'setCurrency',
        'symbol' => 'setSymbol',
        'exercisePrice' => 'setExercisePrice',
        'markPrice' => 'setMarkPrice',
        'quantity' => 'setQuantity',
        'amount' => 'setAmount',
        'fee' => 'setFee',
        'createDate' => 'setCreateDate',
        'priceScale' => 'setPriceScale',
        'quantityScale' => 'setQuantityScale',
        'optionSide' => 'setOptionSide',
        'positionSide' => 'setPositionSide',
        'quoteAsset' => 'setQuoteAsset',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'id' => 'getId',
        'currency' => 'getCurrency',
        'symbol' => 'getSymbol',
        'exercisePrice' => 'getExercisePrice',
        'markPrice' => 'getMarkPrice',
        'quantity' => 'getQuantity',
        'amount' => 'getAmount',
        'fee' => 'getFee',
        'createDate' => 'getCreateDate',
        'priceScale' => 'getPriceScale',
        'quantityScale' => 'getQuantityScale',
        'optionSide' => 'getOptionSide',
        'positionSide' => 'getPositionSide',
        'quoteAsset' => 'getQuoteAsset',
    ];

    /**
     * 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('id', $data ?? [], null);
        $this->setIfExists('currency', $data ?? [], null);
        $this->setIfExists('symbol', $data ?? [], null);
        $this->setIfExists('exercisePrice', $data ?? [], null);
        $this->setIfExists('markPrice', $data ?? [], null);
        $this->setIfExists('quantity', $data ?? [], null);
        $this->setIfExists('amount', $data ?? [], null);
        $this->setIfExists('fee', $data ?? [], null);
        $this->setIfExists('createDate', $data ?? [], null);
        $this->setIfExists('priceScale', $data ?? [], null);
        $this->setIfExists('quantityScale', $data ?? [], null);
        $this->setIfExists('optionSide', $data ?? [], null);
        $this->setIfExists('positionSide', $data ?? [], null);
        $this->setIfExists('quoteAsset', $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 id.
     *
     * @return null|string
     */
    public function getId()
    {
        return $this->container['id'];
    }

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

        return $this;
    }

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

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

        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 exercisePrice.
     *
     * @return null|string
     */
    public function getExercisePrice()
    {
        return $this->container['exercisePrice'];
    }

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

        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 quantity.
     *
     * @return null|string
     */
    public function getQuantity()
    {
        return $this->container['quantity'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        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 quoteAsset.
     *
     * @return null|string
     */
    public function getQuoteAsset()
    {
        return $this->container['quoteAsset'];
    }

    /**
     * Sets quoteAsset.
     *
     * @param null|string $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;
    }

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