<?php
/**
 * Level3ExecutedOrderModel
 *
 * 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;

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'symbol' => 'string',
        'timestamp_nanos' => 'int',
        'timestamp' => '\DateTime',
        'order_id_reference' => 'int',
        'sale_condition_flags' => 'int',
        'is_intermarket_sweep' => 'bool',
        'is_extended_hours_trade' => 'bool',
        'is_odd_lot_trade' => 'bool',
        'is_trade_through_exempt' => 'bool',
        'is_single_price_cross_trade' => 'bool',
        'size' => 'int',
        'price' => 'float',
        'trade_id' => 'int'
    ];

    /**
      * 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 = [
        'symbol' => null,
        'timestamp_nanos' => 'int64',
        'timestamp' => 'date-time',
        'order_id_reference' => 'int64',
        'sale_condition_flags' => 'int32',
        'is_intermarket_sweep' => null,
        'is_extended_hours_trade' => null,
        'is_odd_lot_trade' => null,
        'is_trade_through_exempt' => null,
        'is_single_price_cross_trade' => null,
        'size' => 'int32',
        'price' => 'double',
        'trade_id' => 'int64'
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'symbol' => true,
        'timestamp_nanos' => false,
        'timestamp' => false,
        'order_id_reference' => false,
        'sale_condition_flags' => false,
        'is_intermarket_sweep' => false,
        'is_extended_hours_trade' => false,
        'is_odd_lot_trade' => false,
        'is_trade_through_exempt' => false,
        'is_single_price_cross_trade' => false,
        'size' => false,
        'price' => false,
        'trade_id' => 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 = [
        'symbol' => 'symbol',
        'timestamp_nanos' => 'timestamp_nanos',
        'timestamp' => 'timestamp',
        'order_id_reference' => 'order_id_reference',
        'sale_condition_flags' => 'sale_condition_flags',
        'is_intermarket_sweep' => 'is_intermarket_sweep',
        'is_extended_hours_trade' => 'is_extended_hours_trade',
        'is_odd_lot_trade' => 'is_odd_lot_trade',
        'is_trade_through_exempt' => 'is_trade_through_exempt',
        'is_single_price_cross_trade' => 'is_single_price_cross_trade',
        'size' => 'size',
        'price' => 'price',
        'trade_id' => 'trade_id'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'symbol' => 'setSymbol',
        'timestamp_nanos' => 'setTimestampNanos',
        'timestamp' => 'setTimestamp',
        'order_id_reference' => 'setOrderIdReference',
        'sale_condition_flags' => 'setSaleConditionFlags',
        'is_intermarket_sweep' => 'setIsIntermarketSweep',
        'is_extended_hours_trade' => 'setIsExtendedHoursTrade',
        'is_odd_lot_trade' => 'setIsOddLotTrade',
        'is_trade_through_exempt' => 'setIsTradeThroughExempt',
        'is_single_price_cross_trade' => 'setIsSinglePriceCrossTrade',
        'size' => 'setSize',
        'price' => 'setPrice',
        'trade_id' => 'setTradeId'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'symbol' => 'getSymbol',
        'timestamp_nanos' => 'getTimestampNanos',
        'timestamp' => 'getTimestamp',
        'order_id_reference' => 'getOrderIdReference',
        'sale_condition_flags' => 'getSaleConditionFlags',
        'is_intermarket_sweep' => 'getIsIntermarketSweep',
        'is_extended_hours_trade' => 'getIsExtendedHoursTrade',
        'is_odd_lot_trade' => 'getIsOddLotTrade',
        'is_trade_through_exempt' => 'getIsTradeThroughExempt',
        'is_single_price_cross_trade' => 'getIsSinglePriceCrossTrade',
        'size' => 'getSize',
        'price' => 'getPrice',
        'trade_id' => 'getTradeId'
    ];

    /**
     * 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('symbol', $data ?? [], null);
        $this->setIfExists('timestamp_nanos', $data ?? [], null);
        $this->setIfExists('timestamp', $data ?? [], null);
        $this->setIfExists('order_id_reference', $data ?? [], null);
        $this->setIfExists('sale_condition_flags', $data ?? [], null);
        $this->setIfExists('is_intermarket_sweep', $data ?? [], null);
        $this->setIfExists('is_extended_hours_trade', $data ?? [], null);
        $this->setIfExists('is_odd_lot_trade', $data ?? [], null);
        $this->setIfExists('is_trade_through_exempt', $data ?? [], null);
        $this->setIfExists('is_single_price_cross_trade', $data ?? [], null);
        $this->setIfExists('size', $data ?? [], null);
        $this->setIfExists('price', $data ?? [], null);
        $this->setIfExists('trade_id', $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 symbol
     *
     * @return string|null
     */
    public function getSymbol()
    {
        return $this->container['symbol'];
    }

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

        return $this;
    }

    /**
     * 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 order was executed 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 order_id_reference
     *
     * @return int|null
     */
    public function getOrderIdReference()
    {
        return $this->container['order_id_reference'];
    }

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

        return $this;
    }

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

    /**
     * Sets sale_condition_flags
     *
     * @param int|null $sale_condition_flags Sale condition flags for the execution as byte value
     *
     * @return self
     */
    public function setSaleConditionFlags($sale_condition_flags)
    {
        if (is_null($sale_condition_flags)) {
            throw new \InvalidArgumentException('non-nullable sale_condition_flags cannot be null');
        }
        $this->container['sale_condition_flags'] = $sale_condition_flags;

        return $this;
    }

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

    /**
     * Sets is_intermarket_sweep
     *
     * @param bool|null $is_intermarket_sweep Bit 7 (Mask 0x80): Intermarket Sweep Flag True: Intermarket Sweep Order (\"ISO\") False: Non-Intermarket Sweep Order
     *
     * @return self
     */
    public function setIsIntermarketSweep($is_intermarket_sweep)
    {
        if (is_null($is_intermarket_sweep)) {
            throw new \InvalidArgumentException('non-nullable is_intermarket_sweep cannot be null');
        }
        $this->container['is_intermarket_sweep'] = $is_intermarket_sweep;

        return $this;
    }

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

    /**
     * Sets is_extended_hours_trade
     *
     * @param bool|null $is_extended_hours_trade Bit 6 (Mask 0x40): Extended Hours Flag True: Extended Hours Trade (i.e., Form T sale condition) False: Regular Market Session Trade
     *
     * @return self
     */
    public function setIsExtendedHoursTrade($is_extended_hours_trade)
    {
        if (is_null($is_extended_hours_trade)) {
            throw new \InvalidArgumentException('non-nullable is_extended_hours_trade cannot be null');
        }
        $this->container['is_extended_hours_trade'] = $is_extended_hours_trade;

        return $this;
    }

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

    /**
     * Sets is_odd_lot_trade
     *
     * @param bool|null $is_odd_lot_trade Bit 5 (Mask 0x20): Odd Lot Flag True: Odd Lot Trade False: Round or Mixed Lot Trade
     *
     * @return self
     */
    public function setIsOddLotTrade($is_odd_lot_trade)
    {
        if (is_null($is_odd_lot_trade)) {
            throw new \InvalidArgumentException('non-nullable is_odd_lot_trade cannot be null');
        }
        $this->container['is_odd_lot_trade'] = $is_odd_lot_trade;

        return $this;
    }

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

    /**
     * Sets is_trade_through_exempt
     *
     * @param bool|null $is_trade_through_exempt Bit 4 (Mask 0x10): Trade Through Exempt Flag True: Trade is not subject to Rule 611 (Trade Through) of SEC Reg. NMS False: Trade is subject to Rule 611 (Trade Through) of SEC Reg. NMS
     *
     * @return self
     */
    public function setIsTradeThroughExempt($is_trade_through_exempt)
    {
        if (is_null($is_trade_through_exempt)) {
            throw new \InvalidArgumentException('non-nullable is_trade_through_exempt cannot be null');
        }
        $this->container['is_trade_through_exempt'] = $is_trade_through_exempt;

        return $this;
    }

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

    /**
     * Sets is_single_price_cross_trade
     *
     * @param bool|null $is_single_price_cross_trade Bit 3 (Mask 0x08): Single-price Cross Trade Flag True: Trade resulting from a single-price cross False: Execution during continuous trading
     *
     * @return self
     */
    public function setIsSinglePriceCrossTrade($is_single_price_cross_trade)
    {
        if (is_null($is_single_price_cross_trade)) {
            throw new \InvalidArgumentException('non-nullable is_single_price_cross_trade cannot be null');
        }
        $this->container['is_single_price_cross_trade'] = $is_single_price_cross_trade;

        return $this;
    }

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

    /**
     * Sets size
     *
     * @param int|null $size Trade volume in number of shares
     *
     * @return self
     */
    public function setSize($size)
    {
        if (is_null($size)) {
            throw new \InvalidArgumentException('non-nullable size cannot be null');
        }
        $this->container['size'] = $size;

        return $this;
    }

    /**
     * Gets price
     *
     * @return float|null
     */
    public function getPrice()
    {
        return $this->container['price'];
    }

    /**
     * Sets price
     *
     * @param float|null $price Execution price as decimal
     *
     * @return self
     */
    public function setPrice($price)
    {
        if (is_null($price)) {
            throw new \InvalidArgumentException('non-nullable price cannot be null');
        }
        $this->container['price'] = $price;

        return $this;
    }

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

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

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


