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

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'channel_type' => 'string',
        'created_at' => '\DateTime',
        'id' => 'string',
        'inventory_outlet_ids' => 'string[]',
        'payment_type_id' => 'string',
        'products_last_imported_at' => '\DateTime',
        'register_id' => 'string',
        'sales_last_imported_at' => '\DateTime',
        'store_url' => '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 = [
        'channel_type' => null,
        'created_at' => 'date-time',
        'id' => null,
        'inventory_outlet_ids' => null,
        'payment_type_id' => null,
        'products_last_imported_at' => 'date-time',
        'register_id' => null,
        'sales_last_imported_at' => 'date-time',
        'store_url' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'channel_type' => false,
        'created_at' => false,
        'id' => false,
        'inventory_outlet_ids' => false,
        'payment_type_id' => false,
        'products_last_imported_at' => false,
        'register_id' => false,
        'sales_last_imported_at' => false,
        'store_url' => 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 = [
        'channel_type' => 'channel_type',
        'created_at' => 'created_at',
        'id' => 'id',
        'inventory_outlet_ids' => 'inventory_outlet_ids',
        'payment_type_id' => 'payment_type_id',
        'products_last_imported_at' => 'products_last_imported_at',
        'register_id' => 'register_id',
        'sales_last_imported_at' => 'sales_last_imported_at',
        'store_url' => 'store_url'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'channel_type' => 'setChannelType',
        'created_at' => 'setCreatedAt',
        'id' => 'setId',
        'inventory_outlet_ids' => 'setInventoryOutletIds',
        'payment_type_id' => 'setPaymentTypeId',
        'products_last_imported_at' => 'setProductsLastImportedAt',
        'register_id' => 'setRegisterId',
        'sales_last_imported_at' => 'setSalesLastImportedAt',
        'store_url' => 'setStoreUrl'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'channel_type' => 'getChannelType',
        'created_at' => 'getCreatedAt',
        'id' => 'getId',
        'inventory_outlet_ids' => 'getInventoryOutletIds',
        'payment_type_id' => 'getPaymentTypeId',
        'products_last_imported_at' => 'getProductsLastImportedAt',
        'register_id' => 'getRegisterId',
        'sales_last_imported_at' => 'getSalesLastImportedAt',
        'store_url' => 'getStoreUrl'
    ];

    /**
     * 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 CHANNEL_TYPE_WOOCOMMERCE = 'woocommerce';

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

    /**
     * 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('channel_type', $data ?? [], null);
        $this->setIfExists('created_at', $data ?? [], null);
        $this->setIfExists('id', $data ?? [], null);
        $this->setIfExists('inventory_outlet_ids', $data ?? [], null);
        $this->setIfExists('payment_type_id', $data ?? [], null);
        $this->setIfExists('products_last_imported_at', $data ?? [], null);
        $this->setIfExists('register_id', $data ?? [], null);
        $this->setIfExists('sales_last_imported_at', $data ?? [], null);
        $this->setIfExists('store_url', $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['channel_type'] === null) {
            $invalidProperties[] = "'channel_type' can't be null";
        }
        $allowedValues = $this->getChannelTypeAllowableValues();
        if (!is_null($this->container['channel_type']) && !in_array($this->container['channel_type'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value '%s' for 'channel_type', must be one of '%s'",
                $this->container['channel_type'],
                implode("', '", $allowedValues)
            );
        }

        if ($this->container['id'] === null) {
            $invalidProperties[] = "'id' can't be null";
        }
        if ($this->container['inventory_outlet_ids'] === null) {
            $invalidProperties[] = "'inventory_outlet_ids' can't be null";
        }
        if ($this->container['payment_type_id'] === null) {
            $invalidProperties[] = "'payment_type_id' can't be null";
        }
        if ($this->container['products_last_imported_at'] === null) {
            $invalidProperties[] = "'products_last_imported_at' can't be null";
        }
        if ($this->container['register_id'] === null) {
            $invalidProperties[] = "'register_id' can't be null";
        }
        if ($this->container['sales_last_imported_at'] === null) {
            $invalidProperties[] = "'sales_last_imported_at' can't be null";
        }
        if ($this->container['store_url'] === null) {
            $invalidProperties[] = "'store_url' 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 channel_type
     *
     * @return string
     */
    public function getChannelType()
    {
        return $this->container['channel_type'];
    }

    /**
     * Sets channel_type
     *
     * @param string $channel_type The type of channel this is.
     *
     * @return self
     */
    public function setChannelType($channel_type)
    {
        if (is_null($channel_type)) {
            throw new \InvalidArgumentException('non-nullable channel_type cannot be null');
        }
        $allowedValues = $this->getChannelTypeAllowableValues();
        if (!in_array($channel_type, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'channel_type', must be one of '%s'",
                    $channel_type,
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['channel_type'] = $channel_type;

        return $this;
    }

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

    /**
     * Sets created_at
     *
     * @param \DateTime|null $created_at An RFC3339 representation of the time at which the channel was created.
     *
     * @return self
     */
    public function setCreatedAt($created_at)
    {
        if (is_null($created_at)) {
            throw new \InvalidArgumentException('non-nullable created_at cannot be null');
        }
        $this->container['created_at'] = $created_at;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets inventory_outlet_ids
     *
     * @param string[] $inventory_outlet_ids IDs of the outlets that count towards inventory.
     *
     * @return self
     */
    public function setInventoryOutletIds($inventory_outlet_ids)
    {
        if (is_null($inventory_outlet_ids)) {
            throw new \InvalidArgumentException('non-nullable inventory_outlet_ids cannot be null');
        }
        $this->container['inventory_outlet_ids'] = $inventory_outlet_ids;

        return $this;
    }

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

    /**
     * Sets payment_type_id
     *
     * @param string $payment_type_id The payment type id that sale payments will be associated to.
     *
     * @return self
     */
    public function setPaymentTypeId($payment_type_id)
    {
        if (is_null($payment_type_id)) {
            throw new \InvalidArgumentException('non-nullable payment_type_id cannot be null');
        }
        $this->container['payment_type_id'] = $payment_type_id;

        return $this;
    }

    /**
     * Gets products_last_imported_at
     *
     * @return \DateTime
     */
    public function getProductsLastImportedAt()
    {
        return $this->container['products_last_imported_at'];
    }

    /**
     * Sets products_last_imported_at
     *
     * @param \DateTime $products_last_imported_at An RFC3339 representation of the time at which products were last imported.
     *
     * @return self
     */
    public function setProductsLastImportedAt($products_last_imported_at)
    {
        if (is_null($products_last_imported_at)) {
            throw new \InvalidArgumentException('non-nullable products_last_imported_at cannot be null');
        }
        $this->container['products_last_imported_at'] = $products_last_imported_at;

        return $this;
    }

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

    /**
     * Sets register_id
     *
     * @param string $register_id The register id that sales will be associated to.
     *
     * @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 sales_last_imported_at
     *
     * @return \DateTime
     */
    public function getSalesLastImportedAt()
    {
        return $this->container['sales_last_imported_at'];
    }

    /**
     * Sets sales_last_imported_at
     *
     * @param \DateTime $sales_last_imported_at An RFC3339 representation of the time at which sales were last imported.
     *
     * @return self
     */
    public function setSalesLastImportedAt($sales_last_imported_at)
    {
        if (is_null($sales_last_imported_at)) {
            throw new \InvalidArgumentException('non-nullable sales_last_imported_at cannot be null');
        }
        $this->container['sales_last_imported_at'] = $sales_last_imported_at;

        return $this;
    }

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

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

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


