<?php
/**
 * ServiceOrderLineItemsInner
 *
 * 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.20.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;

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'fulfillment_type' => 'string',
        'gift_card' => 'object',
        'id' => 'string',
        'is_picklist_pickable' => 'bool',
        'note' => 'string',
        'price_set' => 'bool',
        'product_id' => 'string',
        'promotions' => '\Vend202601\Model\PromotionDescription[]',
        'quantity' => 'string',
        'register_id' => 'string',
        'register_sequence_id' => 'string',
        'sales_person_id' => 'string',
        'sequence' => 'int',
        'sku' => 'string',
        'state' => 'string',
        'tax_components' => '\Vend202601\Model\LineItemTaxComponent[]',
        'unit_discount' => 'string',
        'unit_loyalty' => 'string',
        'unit_price' => '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 = [
        'fulfillment_type' => null,
        'gift_card' => null,
        'id' => null,
        'is_picklist_pickable' => null,
        'note' => null,
        'price_set' => null,
        'product_id' => null,
        'promotions' => null,
        'quantity' => null,
        'register_id' => null,
        'register_sequence_id' => null,
        'sales_person_id' => null,
        'sequence' => null,
        'sku' => null,
        'state' => null,
        'tax_components' => null,
        'unit_discount' => null,
        'unit_loyalty' => null,
        'unit_price' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'fulfillment_type' => false,
        'gift_card' => true,
        'id' => false,
        'is_picklist_pickable' => false,
        'note' => false,
        'price_set' => false,
        'product_id' => false,
        'promotions' => false,
        'quantity' => false,
        'register_id' => false,
        'register_sequence_id' => false,
        'sales_person_id' => false,
        'sequence' => false,
        'sku' => false,
        'state' => false,
        'tax_components' => false,
        'unit_discount' => false,
        'unit_loyalty' => false,
        'unit_price' => 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 = [
        'fulfillment_type' => 'fulfillment_type',
        'gift_card' => 'gift_card',
        'id' => 'id',
        'is_picklist_pickable' => 'is_picklist_pickable',
        'note' => 'note',
        'price_set' => 'price_set',
        'product_id' => 'product_id',
        'promotions' => 'promotions',
        'quantity' => 'quantity',
        'register_id' => 'register_id',
        'register_sequence_id' => 'register_sequence_id',
        'sales_person_id' => 'sales_person_id',
        'sequence' => 'sequence',
        'sku' => 'sku',
        'state' => 'state',
        'tax_components' => 'tax_components',
        'unit_discount' => 'unit_discount',
        'unit_loyalty' => 'unit_loyalty',
        'unit_price' => 'unit_price'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'fulfillment_type' => 'setFulfillmentType',
        'gift_card' => 'setGiftCard',
        'id' => 'setId',
        'is_picklist_pickable' => 'setIsPicklistPickable',
        'note' => 'setNote',
        'price_set' => 'setPriceSet',
        'product_id' => 'setProductId',
        'promotions' => 'setPromotions',
        'quantity' => 'setQuantity',
        'register_id' => 'setRegisterId',
        'register_sequence_id' => 'setRegisterSequenceId',
        'sales_person_id' => 'setSalesPersonId',
        'sequence' => 'setSequence',
        'sku' => 'setSku',
        'state' => 'setState',
        'tax_components' => 'setTaxComponents',
        'unit_discount' => 'setUnitDiscount',
        'unit_loyalty' => 'setUnitLoyalty',
        'unit_price' => 'setUnitPrice'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'fulfillment_type' => 'getFulfillmentType',
        'gift_card' => 'getGiftCard',
        'id' => 'getId',
        'is_picklist_pickable' => 'getIsPicklistPickable',
        'note' => 'getNote',
        'price_set' => 'getPriceSet',
        'product_id' => 'getProductId',
        'promotions' => 'getPromotions',
        'quantity' => 'getQuantity',
        'register_id' => 'getRegisterId',
        'register_sequence_id' => 'getRegisterSequenceId',
        'sales_person_id' => 'getSalesPersonId',
        'sequence' => 'getSequence',
        'sku' => 'getSku',
        'state' => 'getState',
        'tax_components' => 'getTaxComponents',
        'unit_discount' => 'getUnitDiscount',
        'unit_loyalty' => 'getUnitLoyalty',
        'unit_price' => 'getUnitPrice'
    ];

    /**
     * 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('fulfillment_type', $data ?? [], null);
        $this->setIfExists('gift_card', $data ?? [], null);
        $this->setIfExists('id', $data ?? [], null);
        $this->setIfExists('is_picklist_pickable', $data ?? [], null);
        $this->setIfExists('note', $data ?? [], null);
        $this->setIfExists('price_set', $data ?? [], null);
        $this->setIfExists('product_id', $data ?? [], null);
        $this->setIfExists('promotions', $data ?? [], null);
        $this->setIfExists('quantity', $data ?? [], null);
        $this->setIfExists('register_id', $data ?? [], null);
        $this->setIfExists('register_sequence_id', $data ?? [], null);
        $this->setIfExists('sales_person_id', $data ?? [], null);
        $this->setIfExists('sequence', $data ?? [], null);
        $this->setIfExists('sku', $data ?? [], null);
        $this->setIfExists('state', $data ?? [], null);
        $this->setIfExists('tax_components', $data ?? [], null);
        $this->setIfExists('unit_discount', $data ?? [], null);
        $this->setIfExists('unit_loyalty', $data ?? [], null);
        $this->setIfExists('unit_price', $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 fulfillment_type
     *
     * @return string|null
     */
    public function getFulfillmentType()
    {
        return $this->container['fulfillment_type'];
    }

    /**
     * Sets fulfillment_type
     *
     * @param string|null $fulfillment_type Type of fulfillment for this line item.
     *
     * @return self
     */
    public function setFulfillmentType($fulfillment_type)
    {
        if (is_null($fulfillment_type)) {
            throw new \InvalidArgumentException('non-nullable fulfillment_type cannot be null');
        }
        $this->container['fulfillment_type'] = $fulfillment_type;

        return $this;
    }

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

    /**
     * Sets gift_card
     *
     * @param object|null $gift_card Gift card information if applicable.
     *
     * @return self
     */
    public function setGiftCard($gift_card)
    {
        if (is_null($gift_card)) {
            array_push($this->openAPINullablesSetToNull, 'gift_card');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('gift_card', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['gift_card'] = $gift_card;

        return $this;
    }

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

    /**
     * Sets id
     *
     * @param string|null $id The ID of this line item.
     *
     * @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 is_picklist_pickable
     *
     * @return bool|null
     */
    public function getIsPicklistPickable()
    {
        return $this->container['is_picklist_pickable'];
    }

    /**
     * Sets is_picklist_pickable
     *
     * @param bool|null $is_picklist_pickable Indicates if this line item can be picked from a picklist.
     *
     * @return self
     */
    public function setIsPicklistPickable($is_picklist_pickable)
    {
        if (is_null($is_picklist_pickable)) {
            throw new \InvalidArgumentException('non-nullable is_picklist_pickable cannot be null');
        }
        $this->container['is_picklist_pickable'] = $is_picklist_pickable;

        return $this;
    }

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

    /**
     * Sets note
     *
     * @param string|null $note Line item 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 price_set
     *
     * @return bool|null
     */
    public function getPriceSet()
    {
        return $this->container['price_set'];
    }

    /**
     * Sets price_set
     *
     * @param bool|null $price_set Indicates whether the price was set manually.
     *
     * @return self
     */
    public function setPriceSet($price_set)
    {
        if (is_null($price_set)) {
            throw new \InvalidArgumentException('non-nullable price_set cannot be null');
        }
        $this->container['price_set'] = $price_set;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets promotions
     *
     * @param \Vend202601\Model\PromotionDescription[]|null $promotions Array of promotions applied to this line item.
     *
     * @return self
     */
    public function setPromotions($promotions)
    {
        if (is_null($promotions)) {
            throw new \InvalidArgumentException('non-nullable promotions cannot be null');
        }
        $this->container['promotions'] = $promotions;

        return $this;
    }

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

    /**
     * Sets quantity
     *
     * @param string|null $quantity Quantity of products for the line item.
     *
     * @return self
     */
    public function setQuantity($quantity)
    {
        if (is_null($quantity)) {
            throw new \InvalidArgumentException('non-nullable quantity cannot be null');
        }
        $this->container['quantity'] = $quantity;

        return $this;
    }

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

    /**
     * Sets register_id
     *
     * @param string|null $register_id The register ID associated with this line item.
     *
     * @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 register_sequence_id
     *
     * @return string|null
     */
    public function getRegisterSequenceId()
    {
        return $this->container['register_sequence_id'];
    }

    /**
     * Sets register_sequence_id
     *
     * @param string|null $register_sequence_id The register sequence ID for this line item.
     *
     * @return self
     */
    public function setRegisterSequenceId($register_sequence_id)
    {
        if (is_null($register_sequence_id)) {
            throw new \InvalidArgumentException('non-nullable register_sequence_id cannot be null');
        }
        $this->container['register_sequence_id'] = $register_sequence_id;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets sequence
     *
     * @param int|null $sequence Order of the line item in the service order.
     *
     * @return self
     */
    public function setSequence($sequence)
    {
        if (is_null($sequence)) {
            throw new \InvalidArgumentException('non-nullable sequence cannot be null');
        }
        $this->container['sequence'] = $sequence;

        return $this;
    }

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

    /**
     * Sets sku
     *
     * @param string|null $sku The SKU of the product.
     *
     * @return self
     */
    public function setSku($sku)
    {
        if (is_null($sku)) {
            throw new \InvalidArgumentException('non-nullable sku cannot be null');
        }
        $this->container['sku'] = $sku;

        return $this;
    }

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

    /**
     * Sets state
     *
     * @param string|null $state State of the line item.
     *
     * @return self
     */
    public function setState($state)
    {
        if (is_null($state)) {
            throw new \InvalidArgumentException('non-nullable state cannot be null');
        }
        $this->container['state'] = $state;

        return $this;
    }

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

    /**
     * Sets tax_components
     *
     * @param \Vend202601\Model\LineItemTaxComponent[]|null $tax_components Collection of tax components associated with the line item.
     *
     * @return self
     */
    public function setTaxComponents($tax_components)
    {
        if (is_null($tax_components)) {
            throw new \InvalidArgumentException('non-nullable tax_components cannot be null');
        }
        $this->container['tax_components'] = $tax_components;

        return $this;
    }

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

    /**
     * Sets unit_discount
     *
     * @param string|null $unit_discount Unit discount value for the line item.
     *
     * @return self
     */
    public function setUnitDiscount($unit_discount)
    {
        if (is_null($unit_discount)) {
            throw new \InvalidArgumentException('non-nullable unit_discount cannot be null');
        }
        $this->container['unit_discount'] = $unit_discount;

        return $this;
    }

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

    /**
     * Sets unit_loyalty
     *
     * @param string|null $unit_loyalty Unit loyalty value for the line item.
     *
     * @return self
     */
    public function setUnitLoyalty($unit_loyalty)
    {
        if (is_null($unit_loyalty)) {
            throw new \InvalidArgumentException('non-nullable unit_loyalty cannot be null');
        }
        $this->container['unit_loyalty'] = $unit_loyalty;

        return $this;
    }

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

    /**
     * Sets unit_price
     *
     * @param string|null $unit_price Unit price of the line item.
     *
     * @return self
     */
    public function setUnitPrice($unit_price)
    {
        if (is_null($unit_price)) {
            throw new \InvalidArgumentException('non-nullable unit_price cannot be null');
        }
        $this->container['unit_price'] = $unit_price;

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


