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

/**
 * Lethean Blockchain API
 *
 * OpenAPI for Lethean Blockchain
 *
 * The version of the OpenAPI document: 6.0.1
 * @generated Generated by: https://openapi-generator.tech
 * Generator version: 7.16.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 JsonSerializable;
use InvalidArgumentException;
use ReturnTypeWillChange;
use OpenAPI\Client\ObjectSerializer;

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var array<string, string>
      */
    protected static array $openAPITypes = [
        'amount' => 'int',
        'attachments' => '\OpenAPI\Client\Model\TransactionAttachmentModel[]',
        'blob' => 'string',
        'blob_size' => 'int',
        'extra' => '\OpenAPI\Client\Model\TransactionExtraModel[]',
        'fee' => 'int',
        'id' => 'string',
        'ins' => '\OpenAPI\Client\Model\TransactionInputModel[]',
        'keeper_block' => 'int',
        'object_in_json' => 'string',
        'outs' => '\OpenAPI\Client\Model\TransactionOutputModel[]',
        'pub_key' => 'string',
        'timestamp' => 'int'
    ];

    /**
      * Array of property to format mappings. Used for (de)serialization
      *
      * @var array<string, string|null>
      */
    protected static array $openAPIFormats = [
        'amount' => null,
        'attachments' => null,
        'blob' => null,
        'blob_size' => null,
        'extra' => null,
        'fee' => null,
        'id' => null,
        'ins' => null,
        'keeper_block' => 'int64',
        'object_in_json' => null,
        'outs' => null,
        'pub_key' => null,
        'timestamp' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var array<string, bool>
      */
    protected static array $openAPINullables = [
        'amount' => false,
        'attachments' => false,
        'blob' => false,
        'blob_size' => false,
        'extra' => false,
        'fee' => false,
        'id' => false,
        'ins' => false,
        'keeper_block' => false,
        'object_in_json' => false,
        'outs' => false,
        'pub_key' => false,
        'timestamp' => false
    ];

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

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @return array<string, string>
     */
    public static function openAPITypes(): array
    {
        return self::$openAPITypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization
     *
     * @return array<string, string>
     */
    public static function openAPIFormats(): array
    {
        return self::$openAPIFormats;
    }

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

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

    /**
     * Setter - Array of nullable field names deliberately set to null
     *
     * @param array<string, bool> $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 array<string, string>
     */
    protected static array $attributeMap = [
        'amount' => 'amount',
        'attachments' => 'attachments',
        'blob' => 'blob',
        'blob_size' => 'blob_size',
        'extra' => 'extra',
        'fee' => 'fee',
        'id' => 'id',
        'ins' => 'ins',
        'keeper_block' => 'keeper_block',
        'object_in_json' => 'object_in_json',
        'outs' => 'outs',
        'pub_key' => 'pub_key',
        'timestamp' => 'timestamp'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var array<string, string>
     */
    protected static array $setters = [
        'amount' => 'setAmount',
        'attachments' => 'setAttachments',
        'blob' => 'setBlob',
        'blob_size' => 'setBlobSize',
        'extra' => 'setExtra',
        'fee' => 'setFee',
        'id' => 'setId',
        'ins' => 'setIns',
        'keeper_block' => 'setKeeperBlock',
        'object_in_json' => 'setObjectInJson',
        'outs' => 'setOuts',
        'pub_key' => 'setPubKey',
        'timestamp' => 'setTimestamp'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var array<string, string>
     */
    protected static array $getters = [
        'amount' => 'getAmount',
        'attachments' => 'getAttachments',
        'blob' => 'getBlob',
        'blob_size' => 'getBlobSize',
        'extra' => 'getExtra',
        'fee' => 'getFee',
        'id' => 'getId',
        'ins' => 'getIns',
        'keeper_block' => 'getKeeperBlock',
        'object_in_json' => 'getObjectInJson',
        'outs' => 'getOuts',
        'pub_key' => 'getPubKey',
        'timestamp' => 'getTimestamp'
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @return array<string, string>
     */
    public static function attributeMap(): array
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @return array<string, string>
     */
    public static function setters(): array
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @return array<string, string>
     */
    public static function getters(): array
    {
        return self::$getters;
    }

    /**
     * The original name of the model.
     *
     * @return string
     */
    public function getModelName(): string
    {
        return self::$openAPIModelName;
    }


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

    /**
     * Constructor
     *
     * @param array $data Associated array of property values initializing the model
     */
    public function __construct(?array $data = null)
    {
        $this->setIfExists('amount', $data ?? [], null);
        $this->setIfExists('attachments', $data ?? [], null);
        $this->setIfExists('blob', $data ?? [], null);
        $this->setIfExists('blob_size', $data ?? [], null);
        $this->setIfExists('extra', $data ?? [], null);
        $this->setIfExists('fee', $data ?? [], null);
        $this->setIfExists('id', $data ?? [], null);
        $this->setIfExists('ins', $data ?? [], null);
        $this->setIfExists('keeper_block', $data ?? [], null);
        $this->setIfExists('object_in_json', $data ?? [], null);
        $this->setIfExists('outs', $data ?? [], null);
        $this->setIfExists('pub_key', $data ?? [], null);
        $this->setIfExists('timestamp', $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, mixed $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 string[] invalid properties with reasons
     */
    public function listInvalidProperties(): array
    {
        $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(): bool
    {
        return count($this->listInvalidProperties()) === 0;
    }


    /**
     * Gets amount
     *
     * @return int|null
     */
    public function getAmount(): ?int
    {
        return $this->container['amount'];
    }

    /**
     * Sets amount
     *
     * @param int|null $amount amount
     *
     * @return $this
     */
    public function setAmount(?int $amount): static
    {
        if (is_null($amount)) {
            throw new InvalidArgumentException('non-nullable amount cannot be null');
        }
        $this->container['amount'] = $amount;

        return $this;
    }

    /**
     * Gets attachments
     *
     * @return \OpenAPI\Client\Model\TransactionAttachmentModel[]|null
     */
    public function getAttachments(): ?array
    {
        return $this->container['attachments'];
    }

    /**
     * Sets attachments
     *
     * @param \OpenAPI\Client\Model\TransactionAttachmentModel[]|null $attachments attachments
     *
     * @return $this
     */
    public function setAttachments(?array $attachments): static
    {
        if (is_null($attachments)) {
            throw new InvalidArgumentException('non-nullable attachments cannot be null');
        }
        $this->container['attachments'] = $attachments;

        return $this;
    }

    /**
     * Gets blob
     *
     * @return string|null
     */
    public function getBlob(): ?string
    {
        return $this->container['blob'];
    }

    /**
     * Sets blob
     *
     * @param string|null $blob blob
     *
     * @return $this
     */
    public function setBlob(?string $blob): static
    {
        if (is_null($blob)) {
            throw new InvalidArgumentException('non-nullable blob cannot be null');
        }
        $this->container['blob'] = $blob;

        return $this;
    }

    /**
     * Gets blob_size
     *
     * @return int|null
     */
    public function getBlobSize(): ?int
    {
        return $this->container['blob_size'];
    }

    /**
     * Sets blob_size
     *
     * @param int|null $blob_size blob_size
     *
     * @return $this
     */
    public function setBlobSize(?int $blob_size): static
    {
        if (is_null($blob_size)) {
            throw new InvalidArgumentException('non-nullable blob_size cannot be null');
        }
        $this->container['blob_size'] = $blob_size;

        return $this;
    }

    /**
     * Gets extra
     *
     * @return \OpenAPI\Client\Model\TransactionExtraModel[]|null
     */
    public function getExtra(): ?array
    {
        return $this->container['extra'];
    }

    /**
     * Sets extra
     *
     * @param \OpenAPI\Client\Model\TransactionExtraModel[]|null $extra extra
     *
     * @return $this
     */
    public function setExtra(?array $extra): static
    {
        if (is_null($extra)) {
            throw new InvalidArgumentException('non-nullable extra cannot be null');
        }
        $this->container['extra'] = $extra;

        return $this;
    }

    /**
     * Gets fee
     *
     * @return int|null
     */
    public function getFee(): ?int
    {
        return $this->container['fee'];
    }

    /**
     * Sets fee
     *
     * @param int|null $fee fee
     *
     * @return $this
     */
    public function setFee(?int $fee): static
    {
        if (is_null($fee)) {
            throw new InvalidArgumentException('non-nullable fee cannot be null');
        }
        $this->container['fee'] = $fee;

        return $this;
    }

    /**
     * Gets id
     *
     * @return string|null
     */
    public function getId(): ?string
    {
        return $this->container['id'];
    }

    /**
     * Sets id
     *
     * @param string|null $id id
     *
     * @return $this
     */
    public function setId(?string $id): static
    {
        if (is_null($id)) {
            throw new InvalidArgumentException('non-nullable id cannot be null');
        }
        $this->container['id'] = $id;

        return $this;
    }

    /**
     * Gets ins
     *
     * @return \OpenAPI\Client\Model\TransactionInputModel[]|null
     */
    public function getIns(): ?array
    {
        return $this->container['ins'];
    }

    /**
     * Sets ins
     *
     * @param \OpenAPI\Client\Model\TransactionInputModel[]|null $ins ins
     *
     * @return $this
     */
    public function setIns(?array $ins): static
    {
        if (is_null($ins)) {
            throw new InvalidArgumentException('non-nullable ins cannot be null');
        }
        $this->container['ins'] = $ins;

        return $this;
    }

    /**
     * Gets keeper_block
     *
     * @return int|null
     */
    public function getKeeperBlock(): ?int
    {
        return $this->container['keeper_block'];
    }

    /**
     * Sets keeper_block
     *
     * @param int|null $keeper_block keeper_block
     *
     * @return $this
     */
    public function setKeeperBlock(?int $keeper_block): static
    {
        if (is_null($keeper_block)) {
            throw new InvalidArgumentException('non-nullable keeper_block cannot be null');
        }
        $this->container['keeper_block'] = $keeper_block;

        return $this;
    }

    /**
     * Gets object_in_json
     *
     * @return string|null
     */
    public function getObjectInJson(): ?string
    {
        return $this->container['object_in_json'];
    }

    /**
     * Sets object_in_json
     *
     * @param string|null $object_in_json object_in_json
     *
     * @return $this
     */
    public function setObjectInJson(?string $object_in_json): static
    {
        if (is_null($object_in_json)) {
            throw new InvalidArgumentException('non-nullable object_in_json cannot be null');
        }
        $this->container['object_in_json'] = $object_in_json;

        return $this;
    }

    /**
     * Gets outs
     *
     * @return \OpenAPI\Client\Model\TransactionOutputModel[]|null
     */
    public function getOuts(): ?array
    {
        return $this->container['outs'];
    }

    /**
     * Sets outs
     *
     * @param \OpenAPI\Client\Model\TransactionOutputModel[]|null $outs outs
     *
     * @return $this
     */
    public function setOuts(?array $outs): static
    {
        if (is_null($outs)) {
            throw new InvalidArgumentException('non-nullable outs cannot be null');
        }
        $this->container['outs'] = $outs;

        return $this;
    }

    /**
     * Gets pub_key
     *
     * @return string|null
     */
    public function getPubKey(): ?string
    {
        return $this->container['pub_key'];
    }

    /**
     * Sets pub_key
     *
     * @param string|null $pub_key pub_key
     *
     * @return $this
     */
    public function setPubKey(?string $pub_key): static
    {
        if (is_null($pub_key)) {
            throw new InvalidArgumentException('non-nullable pub_key cannot be null');
        }
        $this->container['pub_key'] = $pub_key;

        return $this;
    }

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

    /**
     * Sets timestamp
     *
     * @param int|null $timestamp timestamp
     *
     * @return $this
     */
    public function setTimestamp(?int $timestamp): static
    {
        if (is_null($timestamp)) {
            throw new InvalidArgumentException('non-nullable timestamp cannot be null');
        }
        $this->container['timestamp'] = $timestamp;

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

    /**
     * Gets offset.
     *
     * @param integer $offset Offset
     *
     * @return mixed|null
     */
    #[ReturnTypeWillChange]
    public function offsetGet(mixed $offset): mixed
    {
        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(mixed $offset, mixed $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(mixed $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(): mixed
    {
       return ObjectSerializer::sanitizeForSerialization($this);
    }

    /**
     * Gets the string presentation of the object
     *
     * @return string
     */
    public function __toString(): string
    {
        return json_encode(
            ObjectSerializer::sanitizeForSerialization($this),
            JSON_PRETTY_PRINT
        );
    }

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


