<?php

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

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

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

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'ipRestrict' => 'bool',
        'createTime' => 'int',
        'enableReading' => 'bool',
        'enableWithdrawals' => 'bool',
        'enableInternalTransfer' => 'bool',
        'enableMargin' => 'bool',
        'enableFutures' => 'bool',
        'permitsUniversalTransfer' => 'bool',
        'enableVanillaOptions' => 'bool',
        'enableFixApiTrade' => 'bool',
        'enableFixReadOnly' => 'bool',
        'enableSpotAndMarginTrading' => 'bool',
        'enablePortfolioMarginTrading' => '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 = [
        'ipRestrict' => null,
        'createTime' => 'int64',
        'enableReading' => null,
        'enableWithdrawals' => null,
        'enableInternalTransfer' => null,
        'enableMargin' => null,
        'enableFutures' => null,
        'permitsUniversalTransfer' => null,
        'enableVanillaOptions' => null,
        'enableFixApiTrade' => null,
        'enableFixReadOnly' => null,
        'enableSpotAndMarginTrading' => null,
        'enablePortfolioMarginTrading' => null,
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'ipRestrict' => false,
        'createTime' => false,
        'enableReading' => false,
        'enableWithdrawals' => false,
        'enableInternalTransfer' => false,
        'enableMargin' => false,
        'enableFutures' => false,
        'permitsUniversalTransfer' => false,
        'enableVanillaOptions' => false,
        'enableFixApiTrade' => false,
        'enableFixReadOnly' => false,
        'enableSpotAndMarginTrading' => false,
        'enablePortfolioMarginTrading' => 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 = [
        'ipRestrict' => 'ipRestrict',
        'createTime' => 'createTime',
        'enableReading' => 'enableReading',
        'enableWithdrawals' => 'enableWithdrawals',
        'enableInternalTransfer' => 'enableInternalTransfer',
        'enableMargin' => 'enableMargin',
        'enableFutures' => 'enableFutures',
        'permitsUniversalTransfer' => 'permitsUniversalTransfer',
        'enableVanillaOptions' => 'enableVanillaOptions',
        'enableFixApiTrade' => 'enableFixApiTrade',
        'enableFixReadOnly' => 'enableFixReadOnly',
        'enableSpotAndMarginTrading' => 'enableSpotAndMarginTrading',
        'enablePortfolioMarginTrading' => 'enablePortfolioMarginTrading',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'ipRestrict' => 'setIpRestrict',
        'createTime' => 'setCreateTime',
        'enableReading' => 'setEnableReading',
        'enableWithdrawals' => 'setEnableWithdrawals',
        'enableInternalTransfer' => 'setEnableInternalTransfer',
        'enableMargin' => 'setEnableMargin',
        'enableFutures' => 'setEnableFutures',
        'permitsUniversalTransfer' => 'setPermitsUniversalTransfer',
        'enableVanillaOptions' => 'setEnableVanillaOptions',
        'enableFixApiTrade' => 'setEnableFixApiTrade',
        'enableFixReadOnly' => 'setEnableFixReadOnly',
        'enableSpotAndMarginTrading' => 'setEnableSpotAndMarginTrading',
        'enablePortfolioMarginTrading' => 'setEnablePortfolioMarginTrading',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'ipRestrict' => 'getIpRestrict',
        'createTime' => 'getCreateTime',
        'enableReading' => 'getEnableReading',
        'enableWithdrawals' => 'getEnableWithdrawals',
        'enableInternalTransfer' => 'getEnableInternalTransfer',
        'enableMargin' => 'getEnableMargin',
        'enableFutures' => 'getEnableFutures',
        'permitsUniversalTransfer' => 'getPermitsUniversalTransfer',
        'enableVanillaOptions' => 'getEnableVanillaOptions',
        'enableFixApiTrade' => 'getEnableFixApiTrade',
        'enableFixReadOnly' => 'getEnableFixReadOnly',
        'enableSpotAndMarginTrading' => 'getEnableSpotAndMarginTrading',
        'enablePortfolioMarginTrading' => 'getEnablePortfolioMarginTrading',
    ];

    /**
     * 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('ipRestrict', $data ?? [], null);
        $this->setIfExists('createTime', $data ?? [], null);
        $this->setIfExists('enableReading', $data ?? [], null);
        $this->setIfExists('enableWithdrawals', $data ?? [], null);
        $this->setIfExists('enableInternalTransfer', $data ?? [], null);
        $this->setIfExists('enableMargin', $data ?? [], null);
        $this->setIfExists('enableFutures', $data ?? [], null);
        $this->setIfExists('permitsUniversalTransfer', $data ?? [], null);
        $this->setIfExists('enableVanillaOptions', $data ?? [], null);
        $this->setIfExists('enableFixApiTrade', $data ?? [], null);
        $this->setIfExists('enableFixReadOnly', $data ?? [], null);
        $this->setIfExists('enableSpotAndMarginTrading', $data ?? [], null);
        $this->setIfExists('enablePortfolioMarginTrading', $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 ipRestrict.
     *
     * @return null|bool
     */
    public function getIpRestrict()
    {
        return $this->container['ipRestrict'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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