<?php
/**
 * AdminSystemEventModel
 *
 * PHP version 8.1
 *
 * @category Class
 * @package  OpenAPI\Client
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * FinFeedAPI Stock REST API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: v1
 * Contact: support@apibricks.io
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.14.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 OpenAPI\Client\Model;

use \ArrayAccess;
use \OpenAPI\Client\ObjectSerializer;

/**
 * AdminSystemEventModel Class Doc Comment
 *
 * @category Class
 * @description Represents the response DTO for system event information
 * @package  OpenAPI\Client
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 * @implements \ArrayAccess<string, mixed>
 */
class AdminSystemEventModel implements ModelInterface, ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'timestamp_nanos' => 'int',
        'timestamp' => '\DateTime',
        'system_event' => 'int',
        'system_event_code' => 'string',
        'system_event_text' => 'string',
        'is_system_event_start_of_messages' => 'bool',
        'is_system_event_start_of_system_hours' => 'bool',
        'is_system_event_start_of_regular_market_hours' => 'bool',
        'is_system_event_end_of_regular_market_hours' => 'bool',
        'is_system_event_end_of_system_hours' => 'bool',
        'is_system_event_end_of_messages' => '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 = [
        'timestamp_nanos' => 'int64',
        'timestamp' => 'date-time',
        'system_event' => 'int32',
        'system_event_code' => null,
        'system_event_text' => null,
        'is_system_event_start_of_messages' => null,
        'is_system_event_start_of_system_hours' => null,
        'is_system_event_start_of_regular_market_hours' => null,
        'is_system_event_end_of_regular_market_hours' => null,
        'is_system_event_end_of_system_hours' => null,
        'is_system_event_end_of_messages' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'timestamp_nanos' => false,
        'timestamp' => false,
        'system_event' => false,
        'system_event_code' => true,
        'system_event_text' => true,
        'is_system_event_start_of_messages' => false,
        'is_system_event_start_of_system_hours' => false,
        'is_system_event_start_of_regular_market_hours' => false,
        'is_system_event_end_of_regular_market_hours' => false,
        'is_system_event_end_of_system_hours' => false,
        'is_system_event_end_of_messages' => false
    ];

    /**
      * If a nullable field gets set to null, insert it here
      *
      * @var boolean[]
      */
    protected array $openAPINullablesSetToNull = [];

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

    /**
     * Array of nullable properties
     *
     * @return array
     */
    protected static function openAPINullables(): array
    {
        return self::$openAPINullables;
    }

    /**
     * Array of nullable field names deliberately set to null
     *
     * @return boolean[]
     */
    private function getOpenAPINullablesSetToNull(): array
    {
        return $this->openAPINullablesSetToNull;
    }

    /**
     * Setter - Array of nullable field names deliberately set to null
     *
     * @param boolean[] $openAPINullablesSetToNull
     */
    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
    {
        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
    }

    /**
     * Checks if a property is nullable
     *
     * @param string $property
     * @return bool
     */
    public static function isNullable(string $property): bool
    {
        return self::openAPINullables()[$property] ?? false;
    }

    /**
     * Checks if a nullable property is set to null.
     *
     * @param string $property
     * @return bool
     */
    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
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'timestamp_nanos' => 'timestamp_nanos',
        'timestamp' => 'timestamp',
        'system_event' => 'system_event',
        'system_event_code' => 'system_event_code',
        'system_event_text' => 'system_event_text',
        'is_system_event_start_of_messages' => 'is_system_event_start_of_messages',
        'is_system_event_start_of_system_hours' => 'is_system_event_start_of_system_hours',
        'is_system_event_start_of_regular_market_hours' => 'is_system_event_start_of_regular_market_hours',
        'is_system_event_end_of_regular_market_hours' => 'is_system_event_end_of_regular_market_hours',
        'is_system_event_end_of_system_hours' => 'is_system_event_end_of_system_hours',
        'is_system_event_end_of_messages' => 'is_system_event_end_of_messages'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'timestamp_nanos' => 'setTimestampNanos',
        'timestamp' => 'setTimestamp',
        'system_event' => 'setSystemEvent',
        'system_event_code' => 'setSystemEventCode',
        'system_event_text' => 'setSystemEventText',
        'is_system_event_start_of_messages' => 'setIsSystemEventStartOfMessages',
        'is_system_event_start_of_system_hours' => 'setIsSystemEventStartOfSystemHours',
        'is_system_event_start_of_regular_market_hours' => 'setIsSystemEventStartOfRegularMarketHours',
        'is_system_event_end_of_regular_market_hours' => 'setIsSystemEventEndOfRegularMarketHours',
        'is_system_event_end_of_system_hours' => 'setIsSystemEventEndOfSystemHours',
        'is_system_event_end_of_messages' => 'setIsSystemEventEndOfMessages'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'timestamp_nanos' => 'getTimestampNanos',
        'timestamp' => 'getTimestamp',
        'system_event' => 'getSystemEvent',
        'system_event_code' => 'getSystemEventCode',
        'system_event_text' => 'getSystemEventText',
        'is_system_event_start_of_messages' => 'getIsSystemEventStartOfMessages',
        'is_system_event_start_of_system_hours' => 'getIsSystemEventStartOfSystemHours',
        'is_system_event_start_of_regular_market_hours' => 'getIsSystemEventStartOfRegularMarketHours',
        'is_system_event_end_of_regular_market_hours' => 'getIsSystemEventEndOfRegularMarketHours',
        'is_system_event_end_of_system_hours' => 'getIsSystemEventEndOfSystemHours',
        'is_system_event_end_of_messages' => 'getIsSystemEventEndOfMessages'
    ];

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


    /**
     * Associative array for storing property values
     *
     * @var mixed[]
     */
    protected $container = [];

    /**
     * Constructor
     *
     * @param mixed[]|null $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(?array $data = null)
    {
        $this->setIfExists('timestamp_nanos', $data ?? [], null);
        $this->setIfExists('timestamp', $data ?? [], null);
        $this->setIfExists('system_event', $data ?? [], null);
        $this->setIfExists('system_event_code', $data ?? [], null);
        $this->setIfExists('system_event_text', $data ?? [], null);
        $this->setIfExists('is_system_event_start_of_messages', $data ?? [], null);
        $this->setIfExists('is_system_event_start_of_system_hours', $data ?? [], null);
        $this->setIfExists('is_system_event_start_of_regular_market_hours', $data ?? [], null);
        $this->setIfExists('is_system_event_end_of_regular_market_hours', $data ?? [], null);
        $this->setIfExists('is_system_event_end_of_system_hours', $data ?? [], null);
        $this->setIfExists('is_system_event_end_of_messages', $data ?? [], null);
    }

    /**
    * 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 string $variableName
    * @param array  $fields
    * @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;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed
     *
     * @return bool True if all properties are valid
     */
    public function valid()
    {
        return count($this->listInvalidProperties()) === 0;
    }


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

    /**
     * Sets timestamp_nanos
     *
     * @param int|null $timestamp_nanos Original timestamp in nanoseconds since epoch
     *
     * @return self
     */
    public function setTimestampNanos($timestamp_nanos)
    {
        if (is_null($timestamp_nanos)) {
            throw new \InvalidArgumentException('non-nullable timestamp_nanos cannot be null');
        }
        $this->container['timestamp_nanos'] = $timestamp_nanos;

        return $this;
    }

    /**
     * Gets timestamp
     *
     * @return \DateTime|null
     */
    public function getTimestamp()
    {
        return $this->container['timestamp'];
    }

    /**
     * Sets timestamp
     *
     * @param \DateTime|null $timestamp Time when the system event was recorded as DateTime
     *
     * @return self
     */
    public function setTimestamp($timestamp)
    {
        if (is_null($timestamp)) {
            throw new \InvalidArgumentException('non-nullable timestamp cannot be null');
        }
        $this->container['timestamp'] = $timestamp;

        return $this;
    }

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

    /**
     * Sets system_event
     *
     * @param int|null $system_event System event as byte value
     *
     * @return self
     */
    public function setSystemEvent($system_event)
    {
        if (is_null($system_event)) {
            throw new \InvalidArgumentException('non-nullable system_event cannot be null');
        }
        $this->container['system_event'] = $system_event;

        return $this;
    }

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

    /**
     * Sets system_event_code
     *
     * @param string|null $system_event_code System event as string
     *
     * @return self
     */
    public function setSystemEventCode($system_event_code)
    {
        if (is_null($system_event_code)) {
            array_push($this->openAPINullablesSetToNull, 'system_event_code');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('system_event_code', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['system_event_code'] = $system_event_code;

        return $this;
    }

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

    /**
     * Sets system_event_text
     *
     * @param string|null $system_event_text Human-readable description of the system event
     *
     * @return self
     */
    public function setSystemEventText($system_event_text)
    {
        if (is_null($system_event_text)) {
            array_push($this->openAPINullablesSetToNull, 'system_event_text');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('system_event_text', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['system_event_text'] = $system_event_text;

        return $this;
    }

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

    /**
     * Sets is_system_event_start_of_messages
     *
     * @param bool|null $is_system_event_start_of_messages Indicates if the system event is 'Start of Messages' (O). Outside of heartbeat messages on the lower level protocol,  the start of day message is the first message sent in any trading session.
     *
     * @return self
     */
    public function setIsSystemEventStartOfMessages($is_system_event_start_of_messages)
    {
        if (is_null($is_system_event_start_of_messages)) {
            throw new \InvalidArgumentException('non-nullable is_system_event_start_of_messages cannot be null');
        }
        $this->container['is_system_event_start_of_messages'] = $is_system_event_start_of_messages;

        return $this;
    }

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

    /**
     * Sets is_system_event_start_of_system_hours
     *
     * @param bool|null $is_system_event_start_of_system_hours Indicates if the system event is 'Start of System Hours' (S). This message indicates that IEX is open and ready to start accepting orders.
     *
     * @return self
     */
    public function setIsSystemEventStartOfSystemHours($is_system_event_start_of_system_hours)
    {
        if (is_null($is_system_event_start_of_system_hours)) {
            throw new \InvalidArgumentException('non-nullable is_system_event_start_of_system_hours cannot be null');
        }
        $this->container['is_system_event_start_of_system_hours'] = $is_system_event_start_of_system_hours;

        return $this;
    }

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

    /**
     * Sets is_system_event_start_of_regular_market_hours
     *
     * @param bool|null $is_system_event_start_of_regular_market_hours Indicates if the system event is 'Start of Regular Market Hours' (R). This message indicates that DAY and GTX orders, as well as market orders and pegged orders,  are available for execution on IEX.
     *
     * @return self
     */
    public function setIsSystemEventStartOfRegularMarketHours($is_system_event_start_of_regular_market_hours)
    {
        if (is_null($is_system_event_start_of_regular_market_hours)) {
            throw new \InvalidArgumentException('non-nullable is_system_event_start_of_regular_market_hours cannot be null');
        }
        $this->container['is_system_event_start_of_regular_market_hours'] = $is_system_event_start_of_regular_market_hours;

        return $this;
    }

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

    /**
     * Sets is_system_event_end_of_regular_market_hours
     *
     * @param bool|null $is_system_event_end_of_regular_market_hours Indicates if the system event is 'End of Regular Market Hours' (M). This message indicates that DAY orders, market orders, and pegged orders  are no longer accepted by IEX.
     *
     * @return self
     */
    public function setIsSystemEventEndOfRegularMarketHours($is_system_event_end_of_regular_market_hours)
    {
        if (is_null($is_system_event_end_of_regular_market_hours)) {
            throw new \InvalidArgumentException('non-nullable is_system_event_end_of_regular_market_hours cannot be null');
        }
        $this->container['is_system_event_end_of_regular_market_hours'] = $is_system_event_end_of_regular_market_hours;

        return $this;
    }

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

    /**
     * Sets is_system_event_end_of_system_hours
     *
     * @param bool|null $is_system_event_end_of_system_hours Indicates if the system event is 'End of System Hours' (E). This message indicates that IEX is now closed and will not accept  any new orders during this trading session. It is still possible  to receive messages after the end of day.
     *
     * @return self
     */
    public function setIsSystemEventEndOfSystemHours($is_system_event_end_of_system_hours)
    {
        if (is_null($is_system_event_end_of_system_hours)) {
            throw new \InvalidArgumentException('non-nullable is_system_event_end_of_system_hours cannot be null');
        }
        $this->container['is_system_event_end_of_system_hours'] = $is_system_event_end_of_system_hours;

        return $this;
    }

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

    /**
     * Sets is_system_event_end_of_messages
     *
     * @param bool|null $is_system_event_end_of_messages Indicates if the system event is 'End of Messages' (C). This is always the last message sent in any trading session.
     *
     * @return self
     */
    public function setIsSystemEventEndOfMessages($is_system_event_end_of_messages)
    {
        if (is_null($is_system_event_end_of_messages)) {
            throw new \InvalidArgumentException('non-nullable is_system_event_end_of_messages cannot be null');
        }
        $this->container['is_system_event_end_of_messages'] = $is_system_event_end_of_messages;

        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param integer $offset Offset
     *
     * @return boolean
     */
    public function offsetExists($offset): bool
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param integer $offset Offset
     *
     * @return mixed|null
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($offset)
    {
        return $this->container[$offset] ?? null;
    }

    /**
     * Sets value based on offset.
     *
     * @param int|null $offset Offset
     * @param mixed    $value  Value to be set
     *
     * @return void
     */
    public function offsetSet($offset, $value): void
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param integer $offset Offset
     *
     * @return void
     */
    public function offsetUnset($offset): void
    {
        unset($this->container[$offset]);
    }

    /**
     * Serializes the object to a value that can be serialized natively by json_encode().
     * @link 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 the string presentation of the object
     *
     * @return string
     */
    public function __toString()
    {
        return json_encode(
            ObjectSerializer::sanitizeForSerialization($this),
            JSON_PRETTY_PRINT
        );
    }

    /**
     * Gets a header-safe presentation of the object
     *
     * @return string
     */
    public function toHeaderValue()
    {
        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }
}


