<?php
/**
 * PublicEmailContent
 *
 * PHP version 7.4
 *
 * @category Class
 * @package  HubSpot\Client\Marketing\Emails
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * Marketing Emails
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: v3
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.12.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 HubSpot\Client\Marketing\Emails\Model;

use \ArrayAccess;
use \HubSpot\Client\Marketing\Emails\ObjectSerializer;

/**
 * PublicEmailContent Class Doc Comment
 *
 * @category Class
 * @description Data structure representing the content of the email.
 * @package  HubSpot\Client\Marketing\Emails
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 * @implements \ArrayAccess<string, mixed>
 */
class PublicEmailContent implements ModelInterface, ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'smart_fields' => 'array<string,object>',
        'theme_settings_values' => 'array<string,object>',
        'flex_areas' => 'array<string,object>',
        'widgets' => 'array<string,object>',
        'plain_text_version' => 'string',
        'template_path' => 'string',
        'widget_containers' => 'array<string,object>',
        'style_settings' => '\HubSpot\Client\Marketing\Emails\Model\PublicEmailStyleSettings'
    ];

    /**
      * 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 = [
        'smart_fields' => null,
        'theme_settings_values' => null,
        'flex_areas' => null,
        'widgets' => null,
        'plain_text_version' => null,
        'template_path' => null,
        'widget_containers' => null,
        'style_settings' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'smart_fields' => false,
        'theme_settings_values' => false,
        'flex_areas' => false,
        'widgets' => false,
        'plain_text_version' => false,
        'template_path' => false,
        'widget_containers' => false,
        'style_settings' => 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 = [
        'smart_fields' => 'smartFields',
        'theme_settings_values' => 'themeSettingsValues',
        'flex_areas' => 'flexAreas',
        'widgets' => 'widgets',
        'plain_text_version' => 'plainTextVersion',
        'template_path' => 'templatePath',
        'widget_containers' => 'widgetContainers',
        'style_settings' => 'styleSettings'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'smart_fields' => 'setSmartFields',
        'theme_settings_values' => 'setThemeSettingsValues',
        'flex_areas' => 'setFlexAreas',
        'widgets' => 'setWidgets',
        'plain_text_version' => 'setPlainTextVersion',
        'template_path' => 'setTemplatePath',
        'widget_containers' => 'setWidgetContainers',
        'style_settings' => 'setStyleSettings'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'smart_fields' => 'getSmartFields',
        'theme_settings_values' => 'getThemeSettingsValues',
        'flex_areas' => 'getFlexAreas',
        'widgets' => 'getWidgets',
        'plain_text_version' => 'getPlainTextVersion',
        'template_path' => 'getTemplatePath',
        'widget_containers' => 'getWidgetContainers',
        'style_settings' => 'getStyleSettings'
    ];

    /**
     * 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('smart_fields', $data ?? [], null);
        $this->setIfExists('theme_settings_values', $data ?? [], null);
        $this->setIfExists('flex_areas', $data ?? [], null);
        $this->setIfExists('widgets', $data ?? [], null);
        $this->setIfExists('plain_text_version', $data ?? [], null);
        $this->setIfExists('template_path', $data ?? [], null);
        $this->setIfExists('widget_containers', $data ?? [], null);
        $this->setIfExists('style_settings', $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 smart_fields
     *
     * @return array<string,object>|null
     */
    public function getSmartFields()
    {
        return $this->container['smart_fields'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets style_settings
     *
     * @return \HubSpot\Client\Marketing\Emails\Model\PublicEmailStyleSettings|null
     */
    public function getStyleSettings()
    {
        return $this->container['style_settings'];
    }

    /**
     * Sets style_settings
     *
     * @param \HubSpot\Client\Marketing\Emails\Model\PublicEmailStyleSettings|null $style_settings style_settings
     *
     * @return self
     */
    public function setStyleSettings($style_settings)
    {
        if (is_null($style_settings)) {
            throw new \InvalidArgumentException('non-nullable style_settings cannot be null');
        }
        $this->container['style_settings'] = $style_settings;

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


