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

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'confirmed' => 'bool',
        'explicit_loyalty_value' => 'bool',
        'handle' => 'string',
        'id' => 'string',
        'loyalty_value' => 'float',
        'price_adjusted' => 'bool',
        'product_brand_id' => 'string',
        'product_id' => 'string',
        'product_supplier_id' => 'string',
        'product_tag_ids' => 'string[]',
        'product_type_id' => 'string',
        'promotion_ids' => 'string[]',
        'quantity' => 'int',
        'unit_discount' => 'float',
        'unit_price' => 'float',
        'unit_tax_discount' => 'float',
        'variant_parent_id' => '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 = [
        'confirmed' => null,
        'explicit_loyalty_value' => null,
        'handle' => null,
        'id' => null,
        'loyalty_value' => 'double',
        'price_adjusted' => null,
        'product_brand_id' => null,
        'product_id' => null,
        'product_supplier_id' => null,
        'product_tag_ids' => null,
        'product_type_id' => null,
        'promotion_ids' => null,
        'quantity' => null,
        'unit_discount' => 'double',
        'unit_price' => 'double',
        'unit_tax_discount' => 'double',
        'variant_parent_id' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'confirmed' => false,
        'explicit_loyalty_value' => false,
        'handle' => false,
        'id' => false,
        'loyalty_value' => false,
        'price_adjusted' => false,
        'product_brand_id' => false,
        'product_id' => false,
        'product_supplier_id' => false,
        'product_tag_ids' => false,
        'product_type_id' => false,
        'promotion_ids' => false,
        'quantity' => false,
        'unit_discount' => false,
        'unit_price' => false,
        'unit_tax_discount' => false,
        'variant_parent_id' => false
    ];

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

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

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

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

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

    /**
     * Setter - Array of nullable field names deliberately set to null
     *
     * @param boolean[] $openAPINullablesSetToNull
     */
    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
    {
        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
    }

    /**
     * Checks if a property is nullable
     *
     * @param string $property
     * @return bool
     */
    public static function isNullable(string $property): bool
    {
        return self::openAPINullables()[$property] ?? false;
    }

    /**
     * Checks if a nullable property is set to null.
     *
     * @param string $property
     * @return bool
     */
    public function isNullableSetToNull(string $property): bool
    {
        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'confirmed' => 'confirmed',
        'explicit_loyalty_value' => 'explicit_loyalty_value',
        'handle' => 'handle',
        'id' => 'id',
        'loyalty_value' => 'loyalty_value',
        'price_adjusted' => 'price_adjusted',
        'product_brand_id' => 'product_brand_id',
        'product_id' => 'product_id',
        'product_supplier_id' => 'product_supplier_id',
        'product_tag_ids' => 'product_tag_ids',
        'product_type_id' => 'product_type_id',
        'promotion_ids' => 'promotion_ids',
        'quantity' => 'quantity',
        'unit_discount' => 'unit_discount',
        'unit_price' => 'unit_price',
        'unit_tax_discount' => 'unit_tax_discount',
        'variant_parent_id' => 'variant_parent_id'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'confirmed' => 'setConfirmed',
        'explicit_loyalty_value' => 'setExplicitLoyaltyValue',
        'handle' => 'setHandle',
        'id' => 'setId',
        'loyalty_value' => 'setLoyaltyValue',
        'price_adjusted' => 'setPriceAdjusted',
        'product_brand_id' => 'setProductBrandId',
        'product_id' => 'setProductId',
        'product_supplier_id' => 'setProductSupplierId',
        'product_tag_ids' => 'setProductTagIds',
        'product_type_id' => 'setProductTypeId',
        'promotion_ids' => 'setPromotionIds',
        'quantity' => 'setQuantity',
        'unit_discount' => 'setUnitDiscount',
        'unit_price' => 'setUnitPrice',
        'unit_tax_discount' => 'setUnitTaxDiscount',
        'variant_parent_id' => 'setVariantParentId'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'confirmed' => 'getConfirmed',
        'explicit_loyalty_value' => 'getExplicitLoyaltyValue',
        'handle' => 'getHandle',
        'id' => 'getId',
        'loyalty_value' => 'getLoyaltyValue',
        'price_adjusted' => 'getPriceAdjusted',
        'product_brand_id' => 'getProductBrandId',
        'product_id' => 'getProductId',
        'product_supplier_id' => 'getProductSupplierId',
        'product_tag_ids' => 'getProductTagIds',
        'product_type_id' => 'getProductTypeId',
        'promotion_ids' => 'getPromotionIds',
        'quantity' => 'getQuantity',
        'unit_discount' => 'getUnitDiscount',
        'unit_price' => 'getUnitPrice',
        'unit_tax_discount' => 'getUnitTaxDiscount',
        'variant_parent_id' => 'getVariantParentId'
    ];

    /**
     * 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('confirmed', $data ?? [], null);
        $this->setIfExists('explicit_loyalty_value', $data ?? [], null);
        $this->setIfExists('handle', $data ?? [], null);
        $this->setIfExists('id', $data ?? [], null);
        $this->setIfExists('loyalty_value', $data ?? [], null);
        $this->setIfExists('price_adjusted', $data ?? [], null);
        $this->setIfExists('product_brand_id', $data ?? [], null);
        $this->setIfExists('product_id', $data ?? [], null);
        $this->setIfExists('product_supplier_id', $data ?? [], null);
        $this->setIfExists('product_tag_ids', $data ?? [], null);
        $this->setIfExists('product_type_id', $data ?? [], null);
        $this->setIfExists('promotion_ids', $data ?? [], null);
        $this->setIfExists('quantity', $data ?? [], null);
        $this->setIfExists('unit_discount', $data ?? [], null);
        $this->setIfExists('unit_price', $data ?? [], null);
        $this->setIfExists('unit_tax_discount', $data ?? [], null);
        $this->setIfExists('variant_parent_id', $data ?? [], null);
    }

    /**
    * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
    * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
    * $this->openAPINullablesSetToNull array
    *
    * @param string $variableName
    * @param array  $fields
    * @param mixed  $defaultValue
    */
    private function setIfExists(string $variableName, array $fields, $defaultValue): void
    {
        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
            $this->openAPINullablesSetToNull[] = $variableName;
        }

        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        if ($this->container['handle'] === null) {
            $invalidProperties[] = "'handle' can't be null";
        }
        if ($this->container['product_brand_id'] === null) {
            $invalidProperties[] = "'product_brand_id' can't be null";
        }
        if ($this->container['product_id'] === null) {
            $invalidProperties[] = "'product_id' can't be null";
        }
        if ($this->container['product_supplier_id'] === null) {
            $invalidProperties[] = "'product_supplier_id' can't be null";
        }
        if ($this->container['product_tag_ids'] === null) {
            $invalidProperties[] = "'product_tag_ids' can't be null";
        }
        if ($this->container['product_type_id'] === null) {
            $invalidProperties[] = "'product_type_id' can't be null";
        }
        if ($this->container['quantity'] === null) {
            $invalidProperties[] = "'quantity' can't be null";
        }
        if ($this->container['unit_price'] === null) {
            $invalidProperties[] = "'unit_price' can't be null";
        }
        if ($this->container['unit_tax_discount'] === null) {
            $invalidProperties[] = "'unit_tax_discount' 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 confirmed
     *
     * @return bool|null
     */
    public function getConfirmed()
    {
        return $this->container['confirmed'];
    }

    /**
     * Sets confirmed
     *
     * @param bool|null $confirmed Whether the line item is confirmed as part of a layby or on account sale.
     *
     * @return self
     */
    public function setConfirmed($confirmed)
    {
        if (is_null($confirmed)) {
            throw new \InvalidArgumentException('non-nullable confirmed cannot be null');
        }
        $this->container['confirmed'] = $confirmed;

        return $this;
    }

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

    /**
     * Sets explicit_loyalty_value
     *
     * @param bool|null $explicit_loyalty_value Whether loyalty was explicitly set in the product or it just uses the default outlet ratio.
     *
     * @return self
     */
    public function setExplicitLoyaltyValue($explicit_loyalty_value)
    {
        if (is_null($explicit_loyalty_value)) {
            throw new \InvalidArgumentException('non-nullable explicit_loyalty_value cannot be null');
        }
        $this->container['explicit_loyalty_value'] = $explicit_loyalty_value;

        return $this;
    }

    /**
     * Gets handle
     *
     * @return string
     */
    public function getHandle()
    {
        return $this->container['handle'];
    }

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

        return $this;
    }

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

    /**
     * Sets id
     *
     * @param string|null $id Line item 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 loyalty_value
     *
     * @return float|null
     */
    public function getLoyaltyValue()
    {
        return $this->container['loyalty_value'];
    }

    /**
     * Sets loyalty_value
     *
     * @param float|null $loyalty_value The line item's loyalty value
     *
     * @return self
     */
    public function setLoyaltyValue($loyalty_value)
    {
        if (is_null($loyalty_value)) {
            throw new \InvalidArgumentException('non-nullable loyalty_value cannot be null');
        }
        $this->container['loyalty_value'] = $loyalty_value;

        return $this;
    }

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

    /**
     * Sets price_adjusted
     *
     * @param bool|null $price_adjusted Indicator to suggest that the price has been adjusted manually, such as through a discount.
     *
     * @return self
     */
    public function setPriceAdjusted($price_adjusted)
    {
        if (is_null($price_adjusted)) {
            throw new \InvalidArgumentException('non-nullable price_adjusted cannot be null');
        }
        $this->container['price_adjusted'] = $price_adjusted;

        return $this;
    }

    /**
     * Gets product_brand_id
     *
     * @return string
     */
    public function getProductBrandId()
    {
        return $this->container['product_brand_id'];
    }

    /**
     * Sets product_brand_id
     *
     * @param string $product_brand_id Product Brand ID.
     *
     * @return self
     */
    public function setProductBrandId($product_brand_id)
    {
        if (is_null($product_brand_id)) {
            throw new \InvalidArgumentException('non-nullable product_brand_id cannot be null');
        }
        $this->container['product_brand_id'] = $product_brand_id;

        return $this;
    }

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

    /**
     * Sets product_id
     *
     * @param string $product_id Product ID
     *
     * @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 product_supplier_id
     *
     * @return string
     */
    public function getProductSupplierId()
    {
        return $this->container['product_supplier_id'];
    }

    /**
     * Sets product_supplier_id
     *
     * @param string $product_supplier_id Product Supplier ID.
     *
     * @return self
     */
    public function setProductSupplierId($product_supplier_id)
    {
        if (is_null($product_supplier_id)) {
            throw new \InvalidArgumentException('non-nullable product_supplier_id cannot be null');
        }
        $this->container['product_supplier_id'] = $product_supplier_id;

        return $this;
    }

    /**
     * Gets product_tag_ids
     *
     * @return string[]
     */
    public function getProductTagIds()
    {
        return $this->container['product_tag_ids'];
    }

    /**
     * Sets product_tag_ids
     *
     * @param string[] $product_tag_ids Product Tag IDs.
     *
     * @return self
     */
    public function setProductTagIds($product_tag_ids)
    {
        if (is_null($product_tag_ids)) {
            throw new \InvalidArgumentException('non-nullable product_tag_ids cannot be null');
        }
        $this->container['product_tag_ids'] = $product_tag_ids;

        return $this;
    }

    /**
     * Gets product_type_id
     *
     * @return string
     */
    public function getProductTypeId()
    {
        return $this->container['product_type_id'];
    }

    /**
     * Sets product_type_id
     *
     * @param string $product_type_id Product Type ID.
     *
     * @return self
     */
    public function setProductTypeId($product_type_id)
    {
        if (is_null($product_type_id)) {
            throw new \InvalidArgumentException('non-nullable product_type_id cannot be null');
        }
        $this->container['product_type_id'] = $product_type_id;

        return $this;
    }

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

    /**
     * Sets promotion_ids
     *
     * @param string[]|null $promotion_ids List of promotion IDs applied to this line item.
     *
     * @return self
     */
    public function setPromotionIds($promotion_ids)
    {
        if (is_null($promotion_ids)) {
            throw new \InvalidArgumentException('non-nullable promotion_ids cannot be null');
        }
        $this->container['promotion_ids'] = $promotion_ids;

        return $this;
    }

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

    /**
     * Sets quantity
     *
     * @param int $quantity Quantity of 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 unit_discount
     *
     * @return float|null
     */
    public function getUnitDiscount()
    {
        return $this->container['unit_discount'];
    }

    /**
     * Sets unit_discount
     *
     * @param float|null $unit_discount The line item's unit discount
     *
     * @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_price
     *
     * @return float
     */
    public function getUnitPrice()
    {
        return $this->container['unit_price'];
    }

    /**
     * Sets unit_price
     *
     * @param float $unit_price The unit price for 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;
    }

    /**
     * Gets unit_tax_discount
     *
     * @return float
     */
    public function getUnitTaxDiscount()
    {
        return $this->container['unit_tax_discount'];
    }

    /**
     * Sets unit_tax_discount
     *
     * @param float $unit_tax_discount The line item's unit tax discount
     *
     * @return self
     */
    public function setUnitTaxDiscount($unit_tax_discount)
    {
        if (is_null($unit_tax_discount)) {
            throw new \InvalidArgumentException('non-nullable unit_tax_discount cannot be null');
        }
        $this->container['unit_tax_discount'] = $unit_tax_discount;

        return $this;
    }

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

    /**
     * Sets variant_parent_id
     *
     * @param string|null $variant_parent_id Product variant parent ID
     *
     * @return self
     */
    public function setVariantParentId($variant_parent_id)
    {
        if (is_null($variant_parent_id)) {
            throw new \InvalidArgumentException('non-nullable variant_parent_id cannot be null');
        }
        $this->container['variant_parent_id'] = $variant_parent_id;

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


