<?php

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

/**
 * Binance Simple Earn REST API.
 *
 * OpenAPI Specification for the Binance Simple Earn 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\SimpleEarn\Model;

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

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'totalAmount' => 'string',
        'tierAnnualPercentageRate' => '\Binance\Client\SimpleEarn\Model\GetFlexibleProductPositionResponseRowsInnerTierAnnualPercentageRate',
        'latestAnnualPercentageRate' => 'string',
        'yesterdayAirdropPercentageRate' => 'string',
        'asset' => 'string',
        'airDropAsset' => 'string',
        'canRedeem' => 'bool',
        'collateralAmount' => 'string',
        'productId' => 'string',
        'yesterdayRealTimeRewards' => 'string',
        'cumulativeBonusRewards' => 'string',
        'cumulativeRealTimeRewards' => 'string',
        'cumulativeTotalRewards' => 'string',
        'autoSubscribe' => '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 = [
        'totalAmount' => null,
        'tierAnnualPercentageRate' => null,
        'latestAnnualPercentageRate' => null,
        'yesterdayAirdropPercentageRate' => null,
        'asset' => null,
        'airDropAsset' => null,
        'canRedeem' => null,
        'collateralAmount' => null,
        'productId' => null,
        'yesterdayRealTimeRewards' => null,
        'cumulativeBonusRewards' => null,
        'cumulativeRealTimeRewards' => null,
        'cumulativeTotalRewards' => null,
        'autoSubscribe' => null,
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'totalAmount' => false,
        'tierAnnualPercentageRate' => false,
        'latestAnnualPercentageRate' => false,
        'yesterdayAirdropPercentageRate' => false,
        'asset' => false,
        'airDropAsset' => false,
        'canRedeem' => false,
        'collateralAmount' => false,
        'productId' => false,
        'yesterdayRealTimeRewards' => false,
        'cumulativeBonusRewards' => false,
        'cumulativeRealTimeRewards' => false,
        'cumulativeTotalRewards' => false,
        'autoSubscribe' => 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 = [
        'totalAmount' => 'totalAmount',
        'tierAnnualPercentageRate' => 'tierAnnualPercentageRate',
        'latestAnnualPercentageRate' => 'latestAnnualPercentageRate',
        'yesterdayAirdropPercentageRate' => 'yesterdayAirdropPercentageRate',
        'asset' => 'asset',
        'airDropAsset' => 'airDropAsset',
        'canRedeem' => 'canRedeem',
        'collateralAmount' => 'collateralAmount',
        'productId' => 'productId',
        'yesterdayRealTimeRewards' => 'yesterdayRealTimeRewards',
        'cumulativeBonusRewards' => 'cumulativeBonusRewards',
        'cumulativeRealTimeRewards' => 'cumulativeRealTimeRewards',
        'cumulativeTotalRewards' => 'cumulativeTotalRewards',
        'autoSubscribe' => 'autoSubscribe',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'totalAmount' => 'setTotalAmount',
        'tierAnnualPercentageRate' => 'setTierAnnualPercentageRate',
        'latestAnnualPercentageRate' => 'setLatestAnnualPercentageRate',
        'yesterdayAirdropPercentageRate' => 'setYesterdayAirdropPercentageRate',
        'asset' => 'setAsset',
        'airDropAsset' => 'setAirDropAsset',
        'canRedeem' => 'setCanRedeem',
        'collateralAmount' => 'setCollateralAmount',
        'productId' => 'setProductId',
        'yesterdayRealTimeRewards' => 'setYesterdayRealTimeRewards',
        'cumulativeBonusRewards' => 'setCumulativeBonusRewards',
        'cumulativeRealTimeRewards' => 'setCumulativeRealTimeRewards',
        'cumulativeTotalRewards' => 'setCumulativeTotalRewards',
        'autoSubscribe' => 'setAutoSubscribe',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'totalAmount' => 'getTotalAmount',
        'tierAnnualPercentageRate' => 'getTierAnnualPercentageRate',
        'latestAnnualPercentageRate' => 'getLatestAnnualPercentageRate',
        'yesterdayAirdropPercentageRate' => 'getYesterdayAirdropPercentageRate',
        'asset' => 'getAsset',
        'airDropAsset' => 'getAirDropAsset',
        'canRedeem' => 'getCanRedeem',
        'collateralAmount' => 'getCollateralAmount',
        'productId' => 'getProductId',
        'yesterdayRealTimeRewards' => 'getYesterdayRealTimeRewards',
        'cumulativeBonusRewards' => 'getCumulativeBonusRewards',
        'cumulativeRealTimeRewards' => 'getCumulativeRealTimeRewards',
        'cumulativeTotalRewards' => 'getCumulativeTotalRewards',
        'autoSubscribe' => 'getAutoSubscribe',
    ];

    /**
     * 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('totalAmount', $data ?? [], null);
        $this->setIfExists('tierAnnualPercentageRate', $data ?? [], null);
        $this->setIfExists('latestAnnualPercentageRate', $data ?? [], null);
        $this->setIfExists('yesterdayAirdropPercentageRate', $data ?? [], null);
        $this->setIfExists('asset', $data ?? [], null);
        $this->setIfExists('airDropAsset', $data ?? [], null);
        $this->setIfExists('canRedeem', $data ?? [], null);
        $this->setIfExists('collateralAmount', $data ?? [], null);
        $this->setIfExists('productId', $data ?? [], null);
        $this->setIfExists('yesterdayRealTimeRewards', $data ?? [], null);
        $this->setIfExists('cumulativeBonusRewards', $data ?? [], null);
        $this->setIfExists('cumulativeRealTimeRewards', $data ?? [], null);
        $this->setIfExists('cumulativeTotalRewards', $data ?? [], null);
        $this->setIfExists('autoSubscribe', $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 totalAmount.
     *
     * @return null|string
     */
    public function getTotalAmount()
    {
        return $this->container['totalAmount'];
    }

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

        return $this;
    }

    /**
     * Gets tierAnnualPercentageRate.
     *
     * @return null|GetFlexibleProductPositionResponseRowsInnerTierAnnualPercentageRate
     */
    public function getTierAnnualPercentageRate()
    {
        return $this->container['tierAnnualPercentageRate'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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