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

/**
 * PublicRssEmailDetails Class Doc Comment
 *
 * @category Class
 * @description RSS related data if it is a blog or rss email.
 * @package  HubSpot\Client\Marketing\Emails
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 * @implements \ArrayAccess<string, mixed>
 */
class PublicRssEmailDetails implements ModelInterface, ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'blog_image_max_width' => 'int',
        'blog_email_type' => 'string',
        'hubspot_blog_id' => 'string',
        'rss_entry_template' => 'string',
        'timing' => 'array<string,object>',
        'max_entries' => 'int',
        'use_headline_as_subject' => 'bool',
        'blog_layout' => 'string',
        '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 = [
        'blog_image_max_width' => 'int32',
        'blog_email_type' => null,
        'hubspot_blog_id' => null,
        'rss_entry_template' => null,
        'timing' => null,
        'max_entries' => 'int32',
        'use_headline_as_subject' => null,
        'blog_layout' => null,
        'url' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'blog_image_max_width' => false,
        'blog_email_type' => false,
        'hubspot_blog_id' => false,
        'rss_entry_template' => false,
        'timing' => false,
        'max_entries' => false,
        'use_headline_as_subject' => false,
        'blog_layout' => false,
        '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 = [
        'blog_image_max_width' => 'blogImageMaxWidth',
        'blog_email_type' => 'blogEmailType',
        'hubspot_blog_id' => 'hubspotBlogId',
        'rss_entry_template' => 'rssEntryTemplate',
        'timing' => 'timing',
        'max_entries' => 'maxEntries',
        'use_headline_as_subject' => 'useHeadlineAsSubject',
        'blog_layout' => 'blogLayout',
        'url' => 'url'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'blog_image_max_width' => 'setBlogImageMaxWidth',
        'blog_email_type' => 'setBlogEmailType',
        'hubspot_blog_id' => 'setHubspotBlogId',
        'rss_entry_template' => 'setRssEntryTemplate',
        'timing' => 'setTiming',
        'max_entries' => 'setMaxEntries',
        'use_headline_as_subject' => 'setUseHeadlineAsSubject',
        'blog_layout' => 'setBlogLayout',
        'url' => 'setUrl'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'blog_image_max_width' => 'getBlogImageMaxWidth',
        'blog_email_type' => 'getBlogEmailType',
        'hubspot_blog_id' => 'getHubspotBlogId',
        'rss_entry_template' => 'getRssEntryTemplate',
        'timing' => 'getTiming',
        'max_entries' => 'getMaxEntries',
        'use_headline_as_subject' => 'getUseHeadlineAsSubject',
        'blog_layout' => 'getBlogLayout',
        'url' => 'getUrl'
    ];

    /**
     * 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('blog_image_max_width', $data ?? [], null);
        $this->setIfExists('blog_email_type', $data ?? [], null);
        $this->setIfExists('hubspot_blog_id', $data ?? [], null);
        $this->setIfExists('rss_entry_template', $data ?? [], null);
        $this->setIfExists('timing', $data ?? [], null);
        $this->setIfExists('max_entries', $data ?? [], null);
        $this->setIfExists('use_headline_as_subject', $data ?? [], null);
        $this->setIfExists('blog_layout', $data ?? [], null);
        $this->setIfExists('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 = [];

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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


