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

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'group_by' => 'string[]',
        'include_composites' => 'bool',
        'include_inactive' => 'bool',
        'location_ids' => 'string[]',
        'offset' => 'int',
        'out_of_stock_only' => 'bool',
        'product_ids' => 'string[]',
        'root_product_ids' => 'string[]',
        'size' => 'int',
        'sort_direction' => 'string',
        'sort_type' => 'string',
        'supplier_ids' => '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 = [
        'group_by' => null,
        'include_composites' => null,
        'include_inactive' => null,
        'location_ids' => 'uuid',
        'offset' => 'int64',
        'out_of_stock_only' => null,
        'product_ids' => 'uuid',
        'root_product_ids' => 'uuid',
        'size' => 'int64',
        'sort_direction' => null,
        'sort_type' => null,
        'supplier_ids' => 'uuid'
    ];

    /**
     * Array of nullable properties. Used for (de)serialization
     *
     * @var boolean[]
     */
    protected static array $openAPINullables = [
        'group_by' => false,
        'include_composites' => false,
        'include_inactive' => false,
        'location_ids' => false,
        'offset' => false,
        'out_of_stock_only' => false,
        'product_ids' => false,
        'root_product_ids' => false,
        'size' => false,
        'sort_direction' => false,
        'sort_type' => false,
        'supplier_ids' => 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 = [
        'group_by' => 'group_by',
        'include_composites' => 'include_composites',
        'include_inactive' => 'include_inactive',
        'location_ids' => 'location_ids',
        'offset' => 'offset',
        'out_of_stock_only' => 'out_of_stock_only',
        'product_ids' => 'product_ids',
        'root_product_ids' => 'root_product_ids',
        'size' => 'size',
        'sort_direction' => 'sort_direction',
        'sort_type' => 'sort_type',
        'supplier_ids' => 'supplier_ids'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'group_by' => 'setGroupBy',
        'include_composites' => 'setIncludeComposites',
        'include_inactive' => 'setIncludeInactive',
        'location_ids' => 'setLocationIds',
        'offset' => 'setOffset',
        'out_of_stock_only' => 'setOutOfStockOnly',
        'product_ids' => 'setProductIds',
        'root_product_ids' => 'setRootProductIds',
        'size' => 'setSize',
        'sort_direction' => 'setSortDirection',
        'sort_type' => 'setSortType',
        'supplier_ids' => 'setSupplierIds'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'group_by' => 'getGroupBy',
        'include_composites' => 'getIncludeComposites',
        'include_inactive' => 'getIncludeInactive',
        'location_ids' => 'getLocationIds',
        'offset' => 'getOffset',
        'out_of_stock_only' => 'getOutOfStockOnly',
        'product_ids' => 'getProductIds',
        'root_product_ids' => 'getRootProductIds',
        'size' => 'getSize',
        'sort_direction' => 'getSortDirection',
        'sort_type' => 'getSortType',
        'supplier_ids' => 'getSupplierIds'
    ];

    /**
     * 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 GROUP_BY_BRAND = 'brand';
    public const GROUP_BY_OUTLET = 'outlet';
    public const GROUP_BY_PRODUCT = 'product';
    public const GROUP_BY_PRODUCT_TYPE = 'product_type';
    public const GROUP_BY_PRODUCT_VARIANT = 'product_variant';
    public const GROUP_BY_SUPPLIER = 'supplier';
    public const SORT_DIRECTION_ASC = 'asc';
    public const SORT_DIRECTION_DESC = 'desc';
    public const SORT_TYPE_TOTAL_COUNT = 'total_count';
    public const SORT_TYPE_TOTAL_COST = 'total_cost';
    public const SORT_TYPE_AVERAGE_COST = 'average_cost';
    public const SORT_TYPE_REORDER_POINT = 'reorder_point';
    public const SORT_TYPE_REORDER_AMOUNT = 'reorder_amount';
    public const SORT_TYPE_PRODUCT_NAME = 'product_name';
    public const SORT_TYPE_CREATED_AT = 'created_at';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getGroupByAllowableValues()
    {
        return [
            self::GROUP_BY_BRAND,
            self::GROUP_BY_OUTLET,
            self::GROUP_BY_PRODUCT,
            self::GROUP_BY_PRODUCT_TYPE,
            self::GROUP_BY_PRODUCT_VARIANT,
            self::GROUP_BY_SUPPLIER,
        ];
    }

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getSortDirectionAllowableValues()
    {
        return [
            self::SORT_DIRECTION_ASC,
            self::SORT_DIRECTION_DESC,
        ];
    }

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getSortTypeAllowableValues()
    {
        return [
            self::SORT_TYPE_TOTAL_COUNT,
            self::SORT_TYPE_TOTAL_COST,
            self::SORT_TYPE_AVERAGE_COST,
            self::SORT_TYPE_REORDER_POINT,
            self::SORT_TYPE_REORDER_AMOUNT,
            self::SORT_TYPE_PRODUCT_NAME,
            self::SORT_TYPE_CREATED_AT,
        ];
    }

    /**
     * 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('group_by', $data ?? [], null);
        $this->setIfExists('include_composites', $data ?? [], false);
        $this->setIfExists('include_inactive', $data ?? [], false);
        $this->setIfExists('location_ids', $data ?? [], null);
        $this->setIfExists('offset', $data ?? [], 0);
        $this->setIfExists('out_of_stock_only', $data ?? [], false);
        $this->setIfExists('product_ids', $data ?? [], null);
        $this->setIfExists('root_product_ids', $data ?? [], null);
        $this->setIfExists('size', $data ?? [], 100);
        $this->setIfExists('sort_direction', $data ?? [], 'desc');
        $this->setIfExists('sort_type', $data ?? [], 'total_count');
        $this->setIfExists('supplier_ids', $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 (!is_null($this->container['group_by']) && (count($this->container['group_by']) > 2)) {
            $invalidProperties[] = "invalid value for 'group_by', number of items must be less than or equal to 2.";
        }

        if (!is_null($this->container['location_ids']) && (count($this->container['location_ids']) > 1000)) {
            $invalidProperties[] = "invalid value for 'location_ids', number of items must be less than or equal to 1000.";
        }

        if (!is_null($this->container['product_ids']) && (count($this->container['product_ids']) > 1000)) {
            $invalidProperties[] = "invalid value for 'product_ids', number of items must be less than or equal to 1000.";
        }

        if (!is_null($this->container['root_product_ids']) && (count($this->container['root_product_ids']) > 1000)) {
            $invalidProperties[] = "invalid value for 'root_product_ids', number of items must be less than or equal to 1000.";
        }

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

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

        if (!is_null($this->container['supplier_ids']) && (count($this->container['supplier_ids']) > 1000)) {
            $invalidProperties[] = "invalid value for 'supplier_ids', number of items must be less than or equal to 1000.";
        }

        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 group_by
     *
     * @return string[]|null
     * @deprecated
     */
    public function getGroupBy()
    {
        return $this->container['group_by'];
    }

    /**
     * Sets group_by
     *
     * @param string[]|null $group_by Categories by which to aggregate returned inventory levels. **Deprecated**: Removed in 2026-04. Use `group_variants` instead.
     *
     * @return self
     * @deprecated
     */
    public function setGroupBy($group_by)
    {
        if (is_null($group_by)) {
            throw new \InvalidArgumentException('non-nullable group_by cannot be null');
        }
        $allowedValues = $this->getGroupByAllowableValues();
        if (array_diff($group_by, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'group_by', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }

        if ((count($group_by) > 2)) {
            throw new \InvalidArgumentException('invalid value for $group_by when calling InventoryLevelsRequest., number of items must be less than or equal to 2.');
        }
        $this->container['group_by'] = $group_by;

        return $this;
    }

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

    /**
     * Sets include_composites
     *
     * @param bool|null $include_composites Include composite products in the response.
     *
     * @return self
     */
    public function setIncludeComposites($include_composites)
    {
        if (is_null($include_composites)) {
            throw new \InvalidArgumentException('non-nullable include_composites cannot be null');
        }
        $this->container['include_composites'] = $include_composites;

        return $this;
    }

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

    /**
     * Sets include_inactive
     *
     * @param bool|null $include_inactive Include inactive products in the response.
     *
     * @return self
     */
    public function setIncludeInactive($include_inactive)
    {
        if (is_null($include_inactive)) {
            throw new \InvalidArgumentException('non-nullable include_inactive cannot be null');
        }
        $this->container['include_inactive'] = $include_inactive;

        return $this;
    }

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

    /**
     * Sets location_ids
     *
     * @param string[]|null $location_ids Optional outlet IDs to filter response by.
     *
     * @return self
     */
    public function setLocationIds($location_ids)
    {
        if (is_null($location_ids)) {
            throw new \InvalidArgumentException('non-nullable location_ids cannot be null');
        }

        if ((count($location_ids) > 1000)) {
            throw new \InvalidArgumentException('invalid value for $location_ids when calling InventoryLevelsRequest., number of items must be less than or equal to 1000.');
        }
        $this->container['location_ids'] = $location_ids;

        return $this;
    }

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

    /**
     * Sets offset
     *
     * @param int|null $offset How many inventory levels to skip.
     *
     * @return self
     */
    public function setOffset($offset)
    {
        if (is_null($offset)) {
            throw new \InvalidArgumentException('non-nullable offset cannot be null');
        }
        $this->container['offset'] = $offset;

        return $this;
    }

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

    /**
     * Sets out_of_stock_only
     *
     * @param bool|null $out_of_stock_only Only return inventory levels with zero or fewer units available to sell. **Deprecated**: Removed in 2026-04. Use `to_be_procured_only` instead.
     *
     * @return self
     * @deprecated
     */
    public function setOutOfStockOnly($out_of_stock_only)
    {
        if (is_null($out_of_stock_only)) {
            throw new \InvalidArgumentException('non-nullable out_of_stock_only cannot be null');
        }
        $this->container['out_of_stock_only'] = $out_of_stock_only;

        return $this;
    }

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

    /**
     * Sets product_ids
     *
     * @param string[]|null $product_ids Optional product IDs to filter response by.
     *
     * @return self
     */
    public function setProductIds($product_ids)
    {
        if (is_null($product_ids)) {
            throw new \InvalidArgumentException('non-nullable product_ids cannot be null');
        }

        if ((count($product_ids) > 1000)) {
            throw new \InvalidArgumentException('invalid value for $product_ids when calling InventoryLevelsRequest., number of items must be less than or equal to 1000.');
        }
        $this->container['product_ids'] = $product_ids;

        return $this;
    }

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

    /**
     * Sets root_product_ids
     *
     * @param string[]|null $root_product_ids Optional root product IDs to filter response by.
     *
     * @return self
     */
    public function setRootProductIds($root_product_ids)
    {
        if (is_null($root_product_ids)) {
            throw new \InvalidArgumentException('non-nullable root_product_ids cannot be null');
        }

        if ((count($root_product_ids) > 1000)) {
            throw new \InvalidArgumentException('invalid value for $root_product_ids when calling InventoryLevelsRequest., number of items must be less than or equal to 1000.');
        }
        $this->container['root_product_ids'] = $root_product_ids;

        return $this;
    }

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

    /**
     * Sets size
     *
     * @param int|null $size How many inventory levels to return.
     *
     * @return self
     */
    public function setSize($size)
    {
        if (is_null($size)) {
            throw new \InvalidArgumentException('non-nullable size cannot be null');
        }
        $this->container['size'] = $size;

        return $this;
    }

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

    /**
     * Sets sort_direction
     *
     * @param string|null $sort_direction Whether to sort the response ascending or descending.
     *
     * @return self
     */
    public function setSortDirection($sort_direction)
    {
        if (is_null($sort_direction)) {
            throw new \InvalidArgumentException('non-nullable sort_direction cannot be null');
        }
        $allowedValues = $this->getSortDirectionAllowableValues();
        if (!in_array($sort_direction, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'sort_direction', must be one of '%s'",
                    $sort_direction,
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['sort_direction'] = $sort_direction;

        return $this;
    }

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

    /**
     * Sets sort_type
     *
     * @param string|null $sort_type Which response field to sort by.
     *
     * @return self
     */
    public function setSortType($sort_type)
    {
        if (is_null($sort_type)) {
            throw new \InvalidArgumentException('non-nullable sort_type cannot be null');
        }
        $allowedValues = $this->getSortTypeAllowableValues();
        if (!in_array($sort_type, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'sort_type', must be one of '%s'",
                    $sort_type,
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['sort_type'] = $sort_type;

        return $this;
    }

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

    /**
     * Sets supplier_ids
     *
     * @param string[]|null $supplier_ids Optional supplier IDs to filter response by.
     *
     * @return self
     */
    public function setSupplierIds($supplier_ids)
    {
        if (is_null($supplier_ids)) {
            throw new \InvalidArgumentException('non-nullable supplier_ids cannot be null');
        }

        if ((count($supplier_ids) > 1000)) {
            throw new \InvalidArgumentException('invalid value for $supplier_ids when calling InventoryLevelsRequest., number of items must be less than or equal to 1000.');
        }
        $this->container['supplier_ids'] = $supplier_ids;

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


