<?php
/**
 * ConfigChannelLocation
 *
 * PHP version 7.4
 *
 * @category Class
 * @package  Linnworks\Inventory
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * Inventory API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: inventory
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.11.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 Linnworks\Inventory\Model;

use \ArrayAccess;
use \Linnworks\Inventory\ObjectSerializer;

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'pk_channel_location_id' => 'int',
        'identifier' => 'string',
        'name' => 'string',
        'external_reference' => 'string',
        'order_download_location' => 'string',
        'inventory_sync_locations' => 'string[]',
        'types' => 'string',
        'deleted' => 'bool',
        'is_fulfilment' => 'bool',
        'additional_fields' => 'array<string,object>'
    ];

    /**
      * 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 = [
        'pk_channel_location_id' => 'int32',
        'identifier' => null,
        'name' => null,
        'external_reference' => null,
        'order_download_location' => 'uuid',
        'inventory_sync_locations' => 'uuid',
        'types' => null,
        'deleted' => null,
        'is_fulfilment' => null,
        'additional_fields' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'pk_channel_location_id' => false,
        'identifier' => false,
        'name' => false,
        'external_reference' => false,
        'order_download_location' => false,
        'inventory_sync_locations' => false,
        'types' => false,
        'deleted' => false,
        'is_fulfilment' => false,
        'additional_fields' => 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 = [
        'pk_channel_location_id' => 'pkChannelLocationId',
        'identifier' => 'Identifier',
        'name' => 'Name',
        'external_reference' => 'ExternalReference',
        'order_download_location' => 'OrderDownloadLocation',
        'inventory_sync_locations' => 'InventorySyncLocations',
        'types' => 'Types',
        'deleted' => 'Deleted',
        'is_fulfilment' => 'IsFulfilment',
        'additional_fields' => 'AdditionalFields'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'pk_channel_location_id' => 'setPkChannelLocationId',
        'identifier' => 'setIdentifier',
        'name' => 'setName',
        'external_reference' => 'setExternalReference',
        'order_download_location' => 'setOrderDownloadLocation',
        'inventory_sync_locations' => 'setInventorySyncLocations',
        'types' => 'setTypes',
        'deleted' => 'setDeleted',
        'is_fulfilment' => 'setIsFulfilment',
        'additional_fields' => 'setAdditionalFields'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'pk_channel_location_id' => 'getPkChannelLocationId',
        'identifier' => 'getIdentifier',
        'name' => 'getName',
        'external_reference' => 'getExternalReference',
        'order_download_location' => 'getOrderDownloadLocation',
        'inventory_sync_locations' => 'getInventorySyncLocations',
        'types' => 'getTypes',
        'deleted' => 'getDeleted',
        'is_fulfilment' => 'getIsFulfilment',
        'additional_fields' => 'getAdditionalFields'
    ];

    /**
     * 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 TYPES_UNSPECIFIED = 'Unspecified';
    public const TYPES_DELIVERY = 'Delivery';
    public const TYPES_COLLECTION = 'Collection';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getTypesAllowableValues()
    {
        return [
            self::TYPES_UNSPECIFIED,
            self::TYPES_DELIVERY,
            self::TYPES_COLLECTION,
        ];
    }

    /**
     * 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('pk_channel_location_id', $data ?? [], null);
        $this->setIfExists('identifier', $data ?? [], null);
        $this->setIfExists('name', $data ?? [], null);
        $this->setIfExists('external_reference', $data ?? [], null);
        $this->setIfExists('order_download_location', $data ?? [], null);
        $this->setIfExists('inventory_sync_locations', $data ?? [], null);
        $this->setIfExists('types', $data ?? [], null);
        $this->setIfExists('deleted', $data ?? [], null);
        $this->setIfExists('is_fulfilment', $data ?? [], null);
        $this->setIfExists('additional_fields', $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 = [];

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

        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 pk_channel_location_id
     *
     * @return int|null
     */
    public function getPkChannelLocationId()
    {
        return $this->container['pk_channel_location_id'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets additional_fields
     *
     * @return array<string,object>|null
     */
    public function getAdditionalFields()
    {
        return $this->container['additional_fields'];
    }

    /**
     * Sets additional_fields
     *
     * @param array<string,object>|null $additional_fields additional_fields
     *
     * @return self
     */
    public function setAdditionalFields($additional_fields)
    {
        if (is_null($additional_fields)) {
            throw new \InvalidArgumentException('non-nullable additional_fields cannot be null');
        }
        $this->container['additional_fields'] = $additional_fields;

        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param integer $offset Offset
     *
     * @return boolean
     */
    public function offsetExists($offset): bool
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param integer $offset Offset
     *
     * @return mixed|null
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($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 $offset Offset
     *
     * @return void
     */
    public function offsetUnset($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));
    }
}


