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

/**
 * Lightspeed Retail (R-Series) API
 *
 * API for Lightspeed Retail POS system. This specification covers the R-Series API endpoints.  NOTE: This is an abridged version of the R-Series API Documentation. For more detailed documentation, visit [API Developer Documentation](https://developers.lightspeedhq.com/retail/)
 *
 * The version of the OpenAPI document: 3.0.0
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.19.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 LightspeedV3\Model;

use \ArrayAccess;
use \LightspeedV3\ObjectSerializer;

/**
 * SaleCreateRequest Class Doc Comment
 *
 * @category Class
 * @description Sale creation request. For completed sales, total payments must equal the calculated sale total.
 * @package  LightspeedV3
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 * @implements \ArrayAccess<string, mixed>
 */
class SaleCreateRequest implements ModelInterface, ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'completed' => 'bool',
        'enable_promotions' => 'bool',
        'is_tax_inclusive' => 'bool',
        'tip_enabled' => 'bool',
        'discount_percent' => 'float',
        'reference_number' => 'string',
        'reference_number_source' => 'string',
        'receipt_preference' => 'string',
        'customer_id' => 'int',
        'discount_id' => 'int',
        'employee_id' => 'int',
        'tip_employee_id' => 'int',
        'quote_id' => 'int',
        'register_id' => 'int',
        'ship_to_id' => 'int',
        'shop_id' => 'int',
        'tax_category_id' => 'int',
        'customer' => '\LightspeedV3\Model\Customer',
        'sale_lines' => '\LightspeedV3\Model\SaleLinesCreateWrapper',
        'complete_time' => '\DateTime',
        'ship_to' => '\LightspeedV3\Model\ShipToCreate',
        'sale_payments' => '\LightspeedV3\Model\SalePaymentsCreateWrapper'
    ];

    /**
      * 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 = [
        'completed' => null,
        'enable_promotions' => null,
        'is_tax_inclusive' => null,
        'tip_enabled' => null,
        'discount_percent' => 'float',
        'reference_number' => null,
        'reference_number_source' => null,
        'receipt_preference' => null,
        'customer_id' => null,
        'discount_id' => null,
        'employee_id' => null,
        'tip_employee_id' => null,
        'quote_id' => null,
        'register_id' => null,
        'ship_to_id' => null,
        'shop_id' => null,
        'tax_category_id' => null,
        'customer' => null,
        'sale_lines' => null,
        'complete_time' => 'date-time',
        'ship_to' => null,
        'sale_payments' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'completed' => false,
        'enable_promotions' => false,
        'is_tax_inclusive' => false,
        'tip_enabled' => false,
        'discount_percent' => false,
        'reference_number' => false,
        'reference_number_source' => false,
        'receipt_preference' => false,
        'customer_id' => false,
        'discount_id' => false,
        'employee_id' => false,
        'tip_employee_id' => false,
        'quote_id' => false,
        'register_id' => false,
        'ship_to_id' => false,
        'shop_id' => false,
        'tax_category_id' => false,
        'customer' => false,
        'sale_lines' => false,
        'complete_time' => false,
        'ship_to' => false,
        'sale_payments' => 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 = [
        'completed' => 'completed',
        'enable_promotions' => 'enablePromotions',
        'is_tax_inclusive' => 'isTaxInclusive',
        'tip_enabled' => 'tipEnabled',
        'discount_percent' => 'discountPercent',
        'reference_number' => 'referenceNumber',
        'reference_number_source' => 'referenceNumberSource',
        'receipt_preference' => 'receiptPreference',
        'customer_id' => 'customerID',
        'discount_id' => 'discountID',
        'employee_id' => 'employeeID',
        'tip_employee_id' => 'tipEmployeeID',
        'quote_id' => 'quoteID',
        'register_id' => 'registerID',
        'ship_to_id' => 'shipToID',
        'shop_id' => 'shopID',
        'tax_category_id' => 'taxCategoryID',
        'customer' => 'Customer',
        'sale_lines' => 'SaleLines',
        'complete_time' => 'completeTime',
        'ship_to' => 'ShipTo',
        'sale_payments' => 'SalePayments'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'completed' => 'setCompleted',
        'enable_promotions' => 'setEnablePromotions',
        'is_tax_inclusive' => 'setIsTaxInclusive',
        'tip_enabled' => 'setTipEnabled',
        'discount_percent' => 'setDiscountPercent',
        'reference_number' => 'setReferenceNumber',
        'reference_number_source' => 'setReferenceNumberSource',
        'receipt_preference' => 'setReceiptPreference',
        'customer_id' => 'setCustomerId',
        'discount_id' => 'setDiscountId',
        'employee_id' => 'setEmployeeId',
        'tip_employee_id' => 'setTipEmployeeId',
        'quote_id' => 'setQuoteId',
        'register_id' => 'setRegisterId',
        'ship_to_id' => 'setShipToId',
        'shop_id' => 'setShopId',
        'tax_category_id' => 'setTaxCategoryId',
        'customer' => 'setCustomer',
        'sale_lines' => 'setSaleLines',
        'complete_time' => 'setCompleteTime',
        'ship_to' => 'setShipTo',
        'sale_payments' => 'setSalePayments'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'completed' => 'getCompleted',
        'enable_promotions' => 'getEnablePromotions',
        'is_tax_inclusive' => 'getIsTaxInclusive',
        'tip_enabled' => 'getTipEnabled',
        'discount_percent' => 'getDiscountPercent',
        'reference_number' => 'getReferenceNumber',
        'reference_number_source' => 'getReferenceNumberSource',
        'receipt_preference' => 'getReceiptPreference',
        'customer_id' => 'getCustomerId',
        'discount_id' => 'getDiscountId',
        'employee_id' => 'getEmployeeId',
        'tip_employee_id' => 'getTipEmployeeId',
        'quote_id' => 'getQuoteId',
        'register_id' => 'getRegisterId',
        'ship_to_id' => 'getShipToId',
        'shop_id' => 'getShopId',
        'tax_category_id' => 'getTaxCategoryId',
        'customer' => 'getCustomer',
        'sale_lines' => 'getSaleLines',
        'complete_time' => 'getCompleteTime',
        'ship_to' => 'getShipTo',
        'sale_payments' => 'getSalePayments'
    ];

    /**
     * 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('completed', $data ?? [], null);
        $this->setIfExists('enable_promotions', $data ?? [], null);
        $this->setIfExists('is_tax_inclusive', $data ?? [], null);
        $this->setIfExists('tip_enabled', $data ?? [], null);
        $this->setIfExists('discount_percent', $data ?? [], null);
        $this->setIfExists('reference_number', $data ?? [], null);
        $this->setIfExists('reference_number_source', $data ?? [], null);
        $this->setIfExists('receipt_preference', $data ?? [], null);
        $this->setIfExists('customer_id', $data ?? [], null);
        $this->setIfExists('discount_id', $data ?? [], null);
        $this->setIfExists('employee_id', $data ?? [], null);
        $this->setIfExists('tip_employee_id', $data ?? [], null);
        $this->setIfExists('quote_id', $data ?? [], null);
        $this->setIfExists('register_id', $data ?? [], null);
        $this->setIfExists('ship_to_id', $data ?? [], null);
        $this->setIfExists('shop_id', $data ?? [], null);
        $this->setIfExists('tax_category_id', $data ?? [], null);
        $this->setIfExists('customer', $data ?? [], null);
        $this->setIfExists('sale_lines', $data ?? [], null);
        $this->setIfExists('complete_time', $data ?? [], null);
        $this->setIfExists('ship_to', $data ?? [], null);
        $this->setIfExists('sale_payments', $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 = [];

        if ($this->container['employee_id'] === null) {
            $invalidProperties[] = "'employee_id' can't be null";
        }
        if ($this->container['register_id'] === null) {
            $invalidProperties[] = "'register_id' can't be null";
        }
        if ($this->container['shop_id'] === null) {
            $invalidProperties[] = "'shop_id' can't be null";
        }
        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 completed
     *
     * @return bool|null
     */
    public function getCompleted()
    {
        return $this->container['completed'];
    }

    /**
     * Sets completed
     *
     * @param bool|null $completed Whether the sale is completed. Sale must be balanced (payments equal total) for completed sales.
     *
     * @return self
     */
    public function setCompleted($completed)
    {
        if (is_null($completed)) {
            throw new \InvalidArgumentException('non-nullable completed cannot be null');
        }
        $this->container['completed'] = $completed;

        return $this;
    }

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

    /**
     * Sets enable_promotions
     *
     * @param bool|null $enable_promotions Whether promotions/pricing rules are enabled for this sale
     *
     * @return self
     */
    public function setEnablePromotions($enable_promotions)
    {
        if (is_null($enable_promotions)) {
            throw new \InvalidArgumentException('non-nullable enable_promotions cannot be null');
        }
        $this->container['enable_promotions'] = $enable_promotions;

        return $this;
    }

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

    /**
     * Sets is_tax_inclusive
     *
     * @param bool|null $is_tax_inclusive Whether prices include tax
     *
     * @return self
     */
    public function setIsTaxInclusive($is_tax_inclusive)
    {
        if (is_null($is_tax_inclusive)) {
            throw new \InvalidArgumentException('non-nullable is_tax_inclusive cannot be null');
        }
        $this->container['is_tax_inclusive'] = $is_tax_inclusive;

        return $this;
    }

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

    /**
     * Sets tip_enabled
     *
     * @param bool|null $tip_enabled Whether tipping is enabled for this sale
     *
     * @return self
     */
    public function setTipEnabled($tip_enabled)
    {
        if (is_null($tip_enabled)) {
            throw new \InvalidArgumentException('non-nullable tip_enabled cannot be null');
        }
        $this->container['tip_enabled'] = $tip_enabled;

        return $this;
    }

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

    /**
     * Sets discount_percent
     *
     * @param float|null $discount_percent Discount percentage applied to the sale
     *
     * @return self
     */
    public function setDiscountPercent($discount_percent)
    {
        if (is_null($discount_percent)) {
            throw new \InvalidArgumentException('non-nullable discount_percent cannot be null');
        }
        $this->container['discount_percent'] = $discount_percent;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets reference_number_source
     *
     * @param string|null $reference_number_source Source of the reference number
     *
     * @return self
     */
    public function setReferenceNumberSource($reference_number_source)
    {
        if (is_null($reference_number_source)) {
            throw new \InvalidArgumentException('non-nullable reference_number_source cannot be null');
        }
        $this->container['reference_number_source'] = $reference_number_source;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets customer_id
     *
     * @param int|null $customer_id Associated customer ID
     *
     * @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 discount_id
     *
     * @return int|null
     */
    public function getDiscountId()
    {
        return $this->container['discount_id'];
    }

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

        return $this;
    }

    /**
     * Gets employee_id
     *
     * @return int
     */
    public function getEmployeeId()
    {
        return $this->container['employee_id'];
    }

    /**
     * Sets employee_id
     *
     * @param int $employee_id Associated employee ID
     *
     * @return self
     */
    public function setEmployeeId($employee_id)
    {
        if (is_null($employee_id)) {
            throw new \InvalidArgumentException('non-nullable employee_id cannot be null');
        }
        $this->container['employee_id'] = $employee_id;

        return $this;
    }

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

    /**
     * Sets tip_employee_id
     *
     * @param int|null $tip_employee_id Employee ID who receives the tip
     *
     * @return self
     */
    public function setTipEmployeeId($tip_employee_id)
    {
        if (is_null($tip_employee_id)) {
            throw new \InvalidArgumentException('non-nullable tip_employee_id cannot be null');
        }
        $this->container['tip_employee_id'] = $tip_employee_id;

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets register_id
     *
     * @return int
     */
    public function getRegisterId()
    {
        return $this->container['register_id'];
    }

    /**
     * Sets register_id
     *
     * @param int $register_id Register used for sale
     *
     * @return self
     */
    public function setRegisterId($register_id)
    {
        if (is_null($register_id)) {
            throw new \InvalidArgumentException('non-nullable register_id cannot be null');
        }
        $this->container['register_id'] = $register_id;

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets shop_id
     *
     * @return int
     */
    public function getShopId()
    {
        return $this->container['shop_id'];
    }

    /**
     * Sets shop_id
     *
     * @param int $shop_id Shop where sale occurred
     *
     * @return self
     */
    public function setShopId($shop_id)
    {
        if (is_null($shop_id)) {
            throw new \InvalidArgumentException('non-nullable shop_id cannot be null');
        }
        $this->container['shop_id'] = $shop_id;

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets customer
     *
     * @return \LightspeedV3\Model\Customer|null
     */
    public function getCustomer()
    {
        return $this->container['customer'];
    }

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

        return $this;
    }

    /**
     * Gets sale_lines
     *
     * @return \LightspeedV3\Model\SaleLinesCreateWrapper|null
     */
    public function getSaleLines()
    {
        return $this->container['sale_lines'];
    }

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

        return $this;
    }

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

    /**
     * Sets complete_time
     *
     * @param \DateTime|null $complete_time The date/time that the sale was completed. Can be set to a past date/time, but not into the future.
     *
     * @return self
     */
    public function setCompleteTime($complete_time)
    {
        if (is_null($complete_time)) {
            throw new \InvalidArgumentException('non-nullable complete_time cannot be null');
        }
        $this->container['complete_time'] = $complete_time;

        return $this;
    }

    /**
     * Gets ship_to
     *
     * @return \LightspeedV3\Model\ShipToCreate|null
     */
    public function getShipTo()
    {
        return $this->container['ship_to'];
    }

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

        return $this;
    }

    /**
     * Gets sale_payments
     *
     * @return \LightspeedV3\Model\SalePaymentsCreateWrapper|null
     */
    public function getSalePayments()
    {
        return $this->container['sale_payments'];
    }

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

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


