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

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'error' => 'string',
        'settings' => '\Linnworks\Channel\Model\CustomerSettings[]',
        'max_description_length' => 'int',
        'image_settings' => '\Linnworks\Channel\Model\ListingImage',
        'max_category_count' => 'int',
        'max_custom_attribute_length' => 'int',
        'is_custom_html_supported' => 'bool',
        'is_custom_attributes_allowed' => 'bool',
        'is_variations_allowed' => 'bool',
        'has_main_variation_price' => 'bool',
        'is_title_in_variation' => 'bool',
        'has_variation_attribute_display_name' => 'bool',
        'is_price_in_variation' => 'bool',
        'is_shipping_listing_specific' => 'bool',
        'is_payment_listing_specific' => 'bool'
    ];

    /**
      * 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 = [
        'error' => null,
        'settings' => null,
        'max_description_length' => null,
        'image_settings' => null,
        'max_category_count' => null,
        'max_custom_attribute_length' => null,
        'is_custom_html_supported' => null,
        'is_custom_attributes_allowed' => null,
        'is_variations_allowed' => null,
        'has_main_variation_price' => null,
        'is_title_in_variation' => null,
        'has_variation_attribute_display_name' => null,
        'is_price_in_variation' => null,
        'is_shipping_listing_specific' => null,
        'is_payment_listing_specific' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'error' => true,
        'settings' => false,
        'max_description_length' => false,
        'image_settings' => false,
        'max_category_count' => false,
        'max_custom_attribute_length' => false,
        'is_custom_html_supported' => false,
        'is_custom_attributes_allowed' => false,
        'is_variations_allowed' => false,
        'has_main_variation_price' => false,
        'is_title_in_variation' => false,
        'has_variation_attribute_display_name' => false,
        'is_price_in_variation' => false,
        'is_shipping_listing_specific' => false,
        'is_payment_listing_specific' => 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 = [
        'error' => 'Error',
        'settings' => 'Settings',
        'max_description_length' => 'MaxDescriptionLength',
        'image_settings' => 'ImageSettings',
        'max_category_count' => 'MaxCategoryCount',
        'max_custom_attribute_length' => 'MaxCustomAttributeLength',
        'is_custom_html_supported' => 'IsCustomHtmlSupported',
        'is_custom_attributes_allowed' => 'IsCustomAttributesAllowed',
        'is_variations_allowed' => 'IsVariationsAllowed',
        'has_main_variation_price' => 'HasMainVariationPrice',
        'is_title_in_variation' => 'IsTitleInVariation',
        'has_variation_attribute_display_name' => 'HasVariationAttributeDisplayName',
        'is_price_in_variation' => 'IsPriceInVariation',
        'is_shipping_listing_specific' => 'IsShippingListingSpecific',
        'is_payment_listing_specific' => 'IsPaymentListingSpecific'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'error' => 'setError',
        'settings' => 'setSettings',
        'max_description_length' => 'setMaxDescriptionLength',
        'image_settings' => 'setImageSettings',
        'max_category_count' => 'setMaxCategoryCount',
        'max_custom_attribute_length' => 'setMaxCustomAttributeLength',
        'is_custom_html_supported' => 'setIsCustomHtmlSupported',
        'is_custom_attributes_allowed' => 'setIsCustomAttributesAllowed',
        'is_variations_allowed' => 'setIsVariationsAllowed',
        'has_main_variation_price' => 'setHasMainVariationPrice',
        'is_title_in_variation' => 'setIsTitleInVariation',
        'has_variation_attribute_display_name' => 'setHasVariationAttributeDisplayName',
        'is_price_in_variation' => 'setIsPriceInVariation',
        'is_shipping_listing_specific' => 'setIsShippingListingSpecific',
        'is_payment_listing_specific' => 'setIsPaymentListingSpecific'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'error' => 'getError',
        'settings' => 'getSettings',
        'max_description_length' => 'getMaxDescriptionLength',
        'image_settings' => 'getImageSettings',
        'max_category_count' => 'getMaxCategoryCount',
        'max_custom_attribute_length' => 'getMaxCustomAttributeLength',
        'is_custom_html_supported' => 'getIsCustomHtmlSupported',
        'is_custom_attributes_allowed' => 'getIsCustomAttributesAllowed',
        'is_variations_allowed' => 'getIsVariationsAllowed',
        'has_main_variation_price' => 'getHasMainVariationPrice',
        'is_title_in_variation' => 'getIsTitleInVariation',
        'has_variation_attribute_display_name' => 'getHasVariationAttributeDisplayName',
        'is_price_in_variation' => 'getIsPriceInVariation',
        'is_shipping_listing_specific' => 'getIsShippingListingSpecific',
        'is_payment_listing_specific' => 'getIsPaymentListingSpecific'
    ];

    /**
     * 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('error', $data ?? [], null);
        $this->setIfExists('settings', $data ?? [], null);
        $this->setIfExists('max_description_length', $data ?? [], null);
        $this->setIfExists('image_settings', $data ?? [], null);
        $this->setIfExists('max_category_count', $data ?? [], null);
        $this->setIfExists('max_custom_attribute_length', $data ?? [], null);
        $this->setIfExists('is_custom_html_supported', $data ?? [], null);
        $this->setIfExists('is_custom_attributes_allowed', $data ?? [], null);
        $this->setIfExists('is_variations_allowed', $data ?? [], null);
        $this->setIfExists('has_main_variation_price', $data ?? [], null);
        $this->setIfExists('is_title_in_variation', $data ?? [], null);
        $this->setIfExists('has_variation_attribute_display_name', $data ?? [], null);
        $this->setIfExists('is_price_in_variation', $data ?? [], null);
        $this->setIfExists('is_shipping_listing_specific', $data ?? [], null);
        $this->setIfExists('is_payment_listing_specific', $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 error
     *
     * @return string|null
     */
    public function getError()
    {
        return $this->container['error'];
    }

    /**
     * Sets error
     *
     * @param string|null $error error
     *
     * @return self
     */
    public function setError($error)
    {
        if (is_null($error)) {
            array_push($this->openAPINullablesSetToNull, 'error');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('error', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['error'] = $error;

        return $this;
    }

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

    /**
     * Sets settings
     *
     * @param \Linnworks\Channel\Model\CustomerSettings[]|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 max_description_length
     *
     * @return int|null
     */
    public function getMaxDescriptionLength()
    {
        return $this->container['max_description_length'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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


