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

/**
 * linnworks_channel
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.0
 * 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\Channel\Model;

use \ArrayAccess;
use \Linnworks\Channel\ObjectSerializer;

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'attributes' => '\Linnworks\Channel\Model\ListingAttribute[]',
        'categories' => 'string[]',
        'configurator_id' => 'int',
        'description' => 'string',
        'external_listing_id' => 'string',
        'images' => '\Linnworks\Channel\Model\ProductImage[]',
        'price' => 'int',
        'quantity' => 'int',
        'sku' => 'string',
        'shipping_methods' => '\Linnworks\Channel\Model\ProductShipping[]',
        'template_id' => 'int',
        'title' => 'string',
        'variation_options' => '\Linnworks\Channel\Model\ProductOption[]',
        'variations' => '\Linnworks\Channel\Model\ProductVariation[]',
        'settings' => '\Linnworks\Channel\Model\ConfiguratorGeneralSetting[]',
        'type' => '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 = [
        'attributes' => null,
        'categories' => null,
        'configurator_id' => null,
        'description' => null,
        'external_listing_id' => null,
        'images' => null,
        'price' => null,
        'quantity' => null,
        'sku' => null,
        'shipping_methods' => null,
        'template_id' => null,
        'title' => null,
        'variation_options' => null,
        'variations' => null,
        'settings' => null,
        'type' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'attributes' => false,
        'categories' => false,
        'configurator_id' => false,
        'description' => false,
        'external_listing_id' => false,
        'images' => false,
        'price' => false,
        'quantity' => false,
        'sku' => false,
        'shipping_methods' => false,
        'template_id' => false,
        'title' => false,
        'variation_options' => false,
        'variations' => false,
        'settings' => false,
        'type' => 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 = [
        'attributes' => 'Attributes',
        'categories' => 'Categories',
        'configurator_id' => 'ConfiguratorId',
        'description' => 'Description',
        'external_listing_id' => 'ExternalListingId',
        'images' => 'Images',
        'price' => 'Price',
        'quantity' => 'Quantity',
        'sku' => 'SKU',
        'shipping_methods' => 'ShippingMethods',
        'template_id' => 'TemplateId',
        'title' => 'Title',
        'variation_options' => 'VariationOptions',
        'variations' => 'Variations',
        'settings' => 'Settings',
        'type' => 'Type'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'attributes' => 'setAttributes',
        'categories' => 'setCategories',
        'configurator_id' => 'setConfiguratorId',
        'description' => 'setDescription',
        'external_listing_id' => 'setExternalListingId',
        'images' => 'setImages',
        'price' => 'setPrice',
        'quantity' => 'setQuantity',
        'sku' => 'setSku',
        'shipping_methods' => 'setShippingMethods',
        'template_id' => 'setTemplateId',
        'title' => 'setTitle',
        'variation_options' => 'setVariationOptions',
        'variations' => 'setVariations',
        'settings' => 'setSettings',
        'type' => 'setType'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'attributes' => 'getAttributes',
        'categories' => 'getCategories',
        'configurator_id' => 'getConfiguratorId',
        'description' => 'getDescription',
        'external_listing_id' => 'getExternalListingId',
        'images' => 'getImages',
        'price' => 'getPrice',
        'quantity' => 'getQuantity',
        'sku' => 'getSku',
        'shipping_methods' => 'getShippingMethods',
        'template_id' => 'getTemplateId',
        'title' => 'getTitle',
        'variation_options' => 'getVariationOptions',
        'variations' => 'getVariations',
        'settings' => 'getSettings',
        'type' => 'getType'
    ];

    /**
     * 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('attributes', $data ?? [], null);
        $this->setIfExists('categories', $data ?? [], null);
        $this->setIfExists('configurator_id', $data ?? [], null);
        $this->setIfExists('description', $data ?? [], null);
        $this->setIfExists('external_listing_id', $data ?? [], null);
        $this->setIfExists('images', $data ?? [], null);
        $this->setIfExists('price', $data ?? [], null);
        $this->setIfExists('quantity', $data ?? [], null);
        $this->setIfExists('sku', $data ?? [], null);
        $this->setIfExists('shipping_methods', $data ?? [], null);
        $this->setIfExists('template_id', $data ?? [], null);
        $this->setIfExists('title', $data ?? [], null);
        $this->setIfExists('variation_options', $data ?? [], null);
        $this->setIfExists('variations', $data ?? [], null);
        $this->setIfExists('settings', $data ?? [], null);
        $this->setIfExists('type', $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 attributes
     *
     * @return \Linnworks\Channel\Model\ListingAttribute[]|null
     */
    public function getAttributes()
    {
        return $this->container['attributes'];
    }

    /**
     * Sets attributes
     *
     * @param \Linnworks\Channel\Model\ListingAttribute[]|null $attributes attributes
     *
     * @return self
     */
    public function setAttributes($attributes)
    {
        if (is_null($attributes)) {
            throw new \InvalidArgumentException('non-nullable attributes cannot be null');
        }
        $this->container['attributes'] = $attributes;

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets images
     *
     * @return \Linnworks\Channel\Model\ProductImage[]|null
     */
    public function getImages()
    {
        return $this->container['images'];
    }

    /**
     * Sets images
     *
     * @param \Linnworks\Channel\Model\ProductImage[]|null $images images
     *
     * @return self
     */
    public function setImages($images)
    {
        if (is_null($images)) {
            throw new \InvalidArgumentException('non-nullable images cannot be null');
        }
        $this->container['images'] = $images;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets quantity
     *
     * @param int|null $quantity quantity
     *
     * @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 sku
     *
     * @return string|null
     */
    public function getSku()
    {
        return $this->container['sku'];
    }

    /**
     * Sets sku
     *
     * @param string|null $sku sku
     *
     * @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 shipping_methods
     *
     * @return \Linnworks\Channel\Model\ProductShipping[]|null
     */
    public function getShippingMethods()
    {
        return $this->container['shipping_methods'];
    }

    /**
     * Sets shipping_methods
     *
     * @param \Linnworks\Channel\Model\ProductShipping[]|null $shipping_methods shipping_methods
     *
     * @return self
     */
    public function setShippingMethods($shipping_methods)
    {
        if (is_null($shipping_methods)) {
            throw new \InvalidArgumentException('non-nullable shipping_methods cannot be null');
        }
        $this->container['shipping_methods'] = $shipping_methods;

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets variation_options
     *
     * @return \Linnworks\Channel\Model\ProductOption[]|null
     */
    public function getVariationOptions()
    {
        return $this->container['variation_options'];
    }

    /**
     * Sets variation_options
     *
     * @param \Linnworks\Channel\Model\ProductOption[]|null $variation_options variation_options
     *
     * @return self
     */
    public function setVariationOptions($variation_options)
    {
        if (is_null($variation_options)) {
            throw new \InvalidArgumentException('non-nullable variation_options cannot be null');
        }
        $this->container['variation_options'] = $variation_options;

        return $this;
    }

    /**
     * Gets variations
     *
     * @return \Linnworks\Channel\Model\ProductVariation[]|null
     */
    public function getVariations()
    {
        return $this->container['variations'];
    }

    /**
     * Sets variations
     *
     * @param \Linnworks\Channel\Model\ProductVariation[]|null $variations variations
     *
     * @return self
     */
    public function setVariations($variations)
    {
        if (is_null($variations)) {
            throw new \InvalidArgumentException('non-nullable variations cannot be null');
        }
        $this->container['variations'] = $variations;

        return $this;
    }

    /**
     * Gets settings
     *
     * @return \Linnworks\Channel\Model\ConfiguratorGeneralSetting[]|null
     */
    public function getSettings()
    {
        return $this->container['settings'];
    }

    /**
     * Sets settings
     *
     * @param \Linnworks\Channel\Model\ConfiguratorGeneralSetting[]|null $settings settings
     *
     * @return self
     */
    public function setSettings($settings)
    {
        if (is_null($settings)) {
            throw new \InvalidArgumentException('non-nullable settings cannot be null');
        }
        $this->container['settings'] = $settings;

        return $this;
    }

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

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

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


