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

/**
 * API 2026-01
 *
 * Lightspeed Retail (X-Series) API.
 *
 * The version of the OpenAPI document: 2026-01
 * Contact: x-series.api@lightspeedhq.com
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.21.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 Vend202601\Model;

use \ArrayAccess;
use \Vend202601\ObjectSerializer;

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        '_metadata' => '\Vend202601\Model\SaleResponseMetadata',
        'adjustments' => '\Vend202601\Model\SaleAdjustment[]',
        'attributes' => 'string[]',
        'created_at' => 'string',
        'customer_id' => 'string',
        'date' => 'string',
        'deleted_at' => 'string',
        'ecom_custom_charges' => '\Vend202601\Model\EcomCustomCharges',
        'external_applications' => 'object[]',
        'id' => 'string',
        'invoice_number' => 'string',
        'line_items' => '\Vend202601\Model\SaleResponseLineItem[]',
        'note' => 'string',
        'payments' => '\Vend202601\Model\SaleResponsePayment[]',
        'receipt_number' => 'string',
        'return' => '\Vend202601\Model\SaleReturn',
        'short_code' => 'string',
        'source' => '\Vend202601\Model\SaleResponseSource',
        'state' => 'string',
        'taxes' => '\Vend202601\Model\SaleResponseTax[]',
        'totals' => '\Vend202601\Model\SaleTotals',
        'updated_at' => '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 = [
        '_metadata' => null,
        'adjustments' => null,
        'attributes' => null,
        'created_at' => null,
        'customer_id' => 'uuid',
        'date' => null,
        'deleted_at' => null,
        'ecom_custom_charges' => null,
        'external_applications' => null,
        'id' => 'uuid',
        'invoice_number' => null,
        'line_items' => null,
        'note' => null,
        'payments' => null,
        'receipt_number' => null,
        'return' => null,
        'short_code' => null,
        'source' => null,
        'state' => null,
        'taxes' => null,
        'totals' => null,
        'updated_at' => null
    ];

    /**
     * Array of nullable properties. Used for (de)serialization
     *
     * @var boolean[]
     */
    protected static array $openAPINullables = [
        '_metadata' => false,
        'adjustments' => false,
        'attributes' => false,
        'created_at' => false,
        'customer_id' => false,
        'date' => false,
        'deleted_at' => false,
        'ecom_custom_charges' => false,
        'external_applications' => false,
        'id' => false,
        'invoice_number' => false,
        'line_items' => false,
        'note' => false,
        'payments' => false,
        'receipt_number' => false,
        'return' => false,
        'short_code' => false,
        'source' => false,
        'state' => false,
        'taxes' => false,
        'totals' => false,
        'updated_at' => 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 = [
        '_metadata' => '_metadata',
        'adjustments' => 'adjustments',
        'attributes' => 'attributes',
        'created_at' => 'created_at',
        'customer_id' => 'customer_id',
        'date' => 'date',
        'deleted_at' => 'deleted_at',
        'ecom_custom_charges' => 'ecom_custom_charges',
        'external_applications' => 'external_applications',
        'id' => 'id',
        'invoice_number' => 'invoice_number',
        'line_items' => 'line_items',
        'note' => 'note',
        'payments' => 'payments',
        'receipt_number' => 'receipt_number',
        'return' => 'return',
        'short_code' => 'short_code',
        'source' => 'source',
        'state' => 'state',
        'taxes' => 'taxes',
        'totals' => 'totals',
        'updated_at' => 'updated_at'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        '_metadata' => 'setMetadata',
        'adjustments' => 'setAdjustments',
        'attributes' => 'setAttributes',
        'created_at' => 'setCreatedAt',
        'customer_id' => 'setCustomerId',
        'date' => 'setDate',
        'deleted_at' => 'setDeletedAt',
        'ecom_custom_charges' => 'setEcomCustomCharges',
        'external_applications' => 'setExternalApplications',
        'id' => 'setId',
        'invoice_number' => 'setInvoiceNumber',
        'line_items' => 'setLineItems',
        'note' => 'setNote',
        'payments' => 'setPayments',
        'receipt_number' => 'setReceiptNumber',
        'return' => 'setReturn',
        'short_code' => 'setShortCode',
        'source' => 'setSource',
        'state' => 'setState',
        'taxes' => 'setTaxes',
        'totals' => 'setTotals',
        'updated_at' => 'setUpdatedAt'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        '_metadata' => 'getMetadata',
        'adjustments' => 'getAdjustments',
        'attributes' => 'getAttributes',
        'created_at' => 'getCreatedAt',
        'customer_id' => 'getCustomerId',
        'date' => 'getDate',
        'deleted_at' => 'getDeletedAt',
        'ecom_custom_charges' => 'getEcomCustomCharges',
        'external_applications' => 'getExternalApplications',
        'id' => 'getId',
        'invoice_number' => 'getInvoiceNumber',
        'line_items' => 'getLineItems',
        'note' => 'getNote',
        'payments' => 'getPayments',
        'receipt_number' => 'getReceiptNumber',
        'return' => 'getReturn',
        'short_code' => 'getShortCode',
        'source' => 'getSource',
        'state' => 'getState',
        'taxes' => 'getTaxes',
        'totals' => 'getTotals',
        'updated_at' => 'getUpdatedAt'
    ];

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

    public const STATE_PARKED = 'parked';
    public const STATE_PENDING = 'pending';
    public const STATE_VOIDED = 'voided';
    public const STATE_CLOSED = 'closed';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getStateAllowableValues()
    {
        return [
            self::STATE_PARKED,
            self::STATE_PENDING,
            self::STATE_VOIDED,
            self::STATE_CLOSED,
        ];
    }

    /**
     * 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('_metadata', $data ?? [], null);
        $this->setIfExists('adjustments', $data ?? [], null);
        $this->setIfExists('attributes', $data ?? [], null);
        $this->setIfExists('created_at', $data ?? [], null);
        $this->setIfExists('customer_id', $data ?? [], null);
        $this->setIfExists('date', $data ?? [], null);
        $this->setIfExists('deleted_at', $data ?? [], null);
        $this->setIfExists('ecom_custom_charges', $data ?? [], null);
        $this->setIfExists('external_applications', $data ?? [], null);
        $this->setIfExists('id', $data ?? [], null);
        $this->setIfExists('invoice_number', $data ?? [], null);
        $this->setIfExists('line_items', $data ?? [], null);
        $this->setIfExists('note', $data ?? [], null);
        $this->setIfExists('payments', $data ?? [], null);
        $this->setIfExists('receipt_number', $data ?? [], null);
        $this->setIfExists('return', $data ?? [], null);
        $this->setIfExists('short_code', $data ?? [], null);
        $this->setIfExists('source', $data ?? [], null);
        $this->setIfExists('state', $data ?? [], null);
        $this->setIfExists('taxes', $data ?? [], null);
        $this->setIfExists('totals', $data ?? [], null);
        $this->setIfExists('updated_at', $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 = [];

        $allowedValues = $this->getStateAllowableValues();
        if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value '%s' for 'state', must be one of '%s'",
                $this->container['state'],
                implode("', '", $allowedValues)
            );
        }

        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 _metadata
     *
     * @return \Vend202601\Model\SaleResponseMetadata|null
     */
    public function getMetadata()
    {
        return $this->container['_metadata'];
    }

    /**
     * Sets _metadata
     *
     * @param \Vend202601\Model\SaleResponseMetadata|null $_metadata _metadata
     *
     * @return self
     */
    public function setMetadata($_metadata)
    {
        if (is_null($_metadata)) {
            throw new \InvalidArgumentException('non-nullable _metadata cannot be null');
        }
        $this->container['_metadata'] = $_metadata;

        return $this;
    }

    /**
     * Gets adjustments
     *
     * @return \Vend202601\Model\SaleAdjustment[]|null
     */
    public function getAdjustments()
    {
        return $this->container['adjustments'];
    }

    /**
     * Sets adjustments
     *
     * @param \Vend202601\Model\SaleAdjustment[]|null $adjustments Collection of aggregated adjustments.
     *
     * @return self
     */
    public function setAdjustments($adjustments)
    {
        if (is_null($adjustments)) {
            throw new \InvalidArgumentException('non-nullable adjustments cannot be null');
        }
        $this->container['adjustments'] = $adjustments;

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets customer_id
     *
     * @param string|null $customer_id The ID of the customer associated with this sale.
     *
     * @return self
     */
    public function setCustomerId($customer_id)
    {
        if (is_null($customer_id)) {
            throw new \InvalidArgumentException('non-nullable customer_id cannot be null');
        }
        $this->container['customer_id'] = $customer_id;

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets ecom_custom_charges
     *
     * @return \Vend202601\Model\EcomCustomCharges|null
     */
    public function getEcomCustomCharges()
    {
        return $this->container['ecom_custom_charges'];
    }

    /**
     * Sets ecom_custom_charges
     *
     * @param \Vend202601\Model\EcomCustomCharges|null $ecom_custom_charges ecom_custom_charges
     *
     * @return self
     */
    public function setEcomCustomCharges($ecom_custom_charges)
    {
        if (is_null($ecom_custom_charges)) {
            throw new \InvalidArgumentException('non-nullable ecom_custom_charges cannot be null');
        }
        $this->container['ecom_custom_charges'] = $ecom_custom_charges;

        return $this;
    }

    /**
     * Gets external_applications
     *
     * @return object[]|null
     */
    public function getExternalApplications()
    {
        return $this->container['external_applications'];
    }

    /**
     * Sets external_applications
     *
     * @param object[]|null $external_applications External applications associated with the sale.
     *
     * @return self
     */
    public function setExternalApplications($external_applications)
    {
        if (is_null($external_applications)) {
            throw new \InvalidArgumentException('non-nullable external_applications cannot be null');
        }
        $this->container['external_applications'] = $external_applications;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets invoice_number
     *
     * @param string|null $invoice_number Invoice number which if provided, should use the prefix and suffix defined for the register.
     *
     * @return self
     */
    public function setInvoiceNumber($invoice_number)
    {
        if (is_null($invoice_number)) {
            throw new \InvalidArgumentException('non-nullable invoice_number cannot be null');
        }
        $this->container['invoice_number'] = $invoice_number;

        return $this;
    }

    /**
     * Gets line_items
     *
     * @return \Vend202601\Model\SaleResponseLineItem[]|null
     */
    public function getLineItems()
    {
        return $this->container['line_items'];
    }

    /**
     * Sets line_items
     *
     * @param \Vend202601\Model\SaleResponseLineItem[]|null $line_items Collection of line items.
     *
     * @return self
     */
    public function setLineItems($line_items)
    {
        if (is_null($line_items)) {
            throw new \InvalidArgumentException('non-nullable line_items cannot be null');
        }
        $this->container['line_items'] = $line_items;

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets payments
     *
     * @return \Vend202601\Model\SaleResponsePayment[]|null
     */
    public function getPayments()
    {
        return $this->container['payments'];
    }

    /**
     * Sets payments
     *
     * @param \Vend202601\Model\SaleResponsePayment[]|null $payments Collection of payments.
     *
     * @return self
     */
    public function setPayments($payments)
    {
        if (is_null($payments)) {
            throw new \InvalidArgumentException('non-nullable payments cannot be null');
        }
        $this->container['payments'] = $payments;

        return $this;
    }

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

    /**
     * Sets receipt_number
     *
     * @param string|null $receipt_number The receipt number for the sale.
     *
     * @return self
     */
    public function setReceiptNumber($receipt_number)
    {
        if (is_null($receipt_number)) {
            throw new \InvalidArgumentException('non-nullable receipt_number cannot be null');
        }
        $this->container['receipt_number'] = $receipt_number;

        return $this;
    }

    /**
     * Gets return
     *
     * @return \Vend202601\Model\SaleReturn|null
     */
    public function getReturn()
    {
        return $this->container['return'];
    }

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

        return $this;
    }

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

    /**
     * Sets short_code
     *
     * @param string|null $short_code Short, unique code used for loyalty tracking purposes.
     *
     * @return self
     */
    public function setShortCode($short_code)
    {
        if (is_null($short_code)) {
            throw new \InvalidArgumentException('non-nullable short_code cannot be null');
        }
        $this->container['short_code'] = $short_code;

        return $this;
    }

    /**
     * Gets source
     *
     * @return \Vend202601\Model\SaleResponseSource|null
     */
    public function getSource()
    {
        return $this->container['source'];
    }

    /**
     * Sets source
     *
     * @param \Vend202601\Model\SaleResponseSource|null $source source
     *
     * @return self
     */
    public function setSource($source)
    {
        if (is_null($source)) {
            throw new \InvalidArgumentException('non-nullable source cannot be null');
        }
        $this->container['source'] = $source;

        return $this;
    }

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

    /**
     * Sets state
     *
     * @param string|null $state State of the sale.
     *
     * @return self
     */
    public function setState($state)
    {
        if (is_null($state)) {
            throw new \InvalidArgumentException('non-nullable state cannot be null');
        }
        $allowedValues = $this->getStateAllowableValues();
        if (!in_array($state, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'state', must be one of '%s'",
                    $state,
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['state'] = $state;

        return $this;
    }

    /**
     * Gets taxes
     *
     * @return \Vend202601\Model\SaleResponseTax[]|null
     */
    public function getTaxes()
    {
        return $this->container['taxes'];
    }

    /**
     * Sets taxes
     *
     * @param \Vend202601\Model\SaleResponseTax[]|null $taxes Collection of taxes.
     *
     * @return self
     */
    public function setTaxes($taxes)
    {
        if (is_null($taxes)) {
            throw new \InvalidArgumentException('non-nullable taxes cannot be null');
        }
        $this->container['taxes'] = $taxes;

        return $this;
    }

    /**
     * Gets totals
     *
     * @return \Vend202601\Model\SaleTotals|null
     */
    public function getTotals()
    {
        return $this->container['totals'];
    }

    /**
     * Sets totals
     *
     * @param \Vend202601\Model\SaleTotals|null $totals totals
     *
     * @return self
     */
    public function setTotals($totals)
    {
        if (is_null($totals)) {
            throw new \InvalidArgumentException('non-nullable totals cannot be null');
        }
        $this->container['totals'] = $totals;

        return $this;
    }

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

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

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

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


