<?php

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

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

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

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'fifteenMinHashRate' => 'string',
        'dayHashRate' => 'string',
        'validNum' => 'int',
        'invalidNum' => 'int',
        'profitToday' => '\Binance\Client\Mining\Model\StatisticListResponseDataProfitToday',
        'profitYesterday' => '\Binance\Client\Mining\Model\StatisticListResponseDataProfitToday',
        'userName' => 'string',
        'unit' => 'string',
        'algo' => '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 = [
        'fifteenMinHashRate' => null,
        'dayHashRate' => null,
        'validNum' => 'int64',
        'invalidNum' => 'int64',
        'profitToday' => null,
        'profitYesterday' => null,
        'userName' => null,
        'unit' => null,
        'algo' => null,
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'fifteenMinHashRate' => false,
        'dayHashRate' => false,
        'validNum' => false,
        'invalidNum' => false,
        'profitToday' => false,
        'profitYesterday' => false,
        'userName' => false,
        'unit' => false,
        'algo' => 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 = [
        'fifteenMinHashRate' => 'fifteenMinHashRate',
        'dayHashRate' => 'dayHashRate',
        'validNum' => 'validNum',
        'invalidNum' => 'invalidNum',
        'profitToday' => 'profitToday',
        'profitYesterday' => 'profitYesterday',
        'userName' => 'userName',
        'unit' => 'unit',
        'algo' => 'algo',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'fifteenMinHashRate' => 'setFifteenMinHashRate',
        'dayHashRate' => 'setDayHashRate',
        'validNum' => 'setValidNum',
        'invalidNum' => 'setInvalidNum',
        'profitToday' => 'setProfitToday',
        'profitYesterday' => 'setProfitYesterday',
        'userName' => 'setUserName',
        'unit' => 'setUnit',
        'algo' => 'setAlgo',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'fifteenMinHashRate' => 'getFifteenMinHashRate',
        'dayHashRate' => 'getDayHashRate',
        'validNum' => 'getValidNum',
        'invalidNum' => 'getInvalidNum',
        'profitToday' => 'getProfitToday',
        'profitYesterday' => 'getProfitYesterday',
        'userName' => 'getUserName',
        'unit' => 'getUnit',
        'algo' => 'getAlgo',
    ];

    /**
     * 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('fifteenMinHashRate', $data ?? [], null);
        $this->setIfExists('dayHashRate', $data ?? [], null);
        $this->setIfExists('validNum', $data ?? [], null);
        $this->setIfExists('invalidNum', $data ?? [], null);
        $this->setIfExists('profitToday', $data ?? [], null);
        $this->setIfExists('profitYesterday', $data ?? [], null);
        $this->setIfExists('userName', $data ?? [], null);
        $this->setIfExists('unit', $data ?? [], null);
        $this->setIfExists('algo', $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 fifteenMinHashRate.
     *
     * @return null|string
     */
    public function getFifteenMinHashRate()
    {
        return $this->container['fifteenMinHashRate'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets profitToday.
     *
     * @return null|StatisticListResponseDataProfitToday
     */
    public function getProfitToday()
    {
        return $this->container['profitToday'];
    }

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

        return $this;
    }

    /**
     * Gets profitYesterday.
     *
     * @return null|StatisticListResponseDataProfitToday
     */
    public function getProfitYesterday()
    {
        return $this->container['profitYesterday'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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