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

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'domain' => 'string',
        'redirect_to_page_id' => 'string',
        'is_page_redirected' => 'bool',
        'redirect_to_url' => 'string',
        'title' => 'string',
        'meta_description' => 'string',
        'page_expiry_enabled' => 'bool',
        'slug' => 'string',
        'url' => 'string',
        'expires_at' => '\DateTime'
    ];

    /**
      * 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 = [
        'domain' => null,
        'redirect_to_page_id' => null,
        'is_page_redirected' => null,
        'redirect_to_url' => null,
        'title' => null,
        'meta_description' => null,
        'page_expiry_enabled' => null,
        'slug' => null,
        'url' => null,
        'expires_at' => 'date-time'
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'domain' => false,
        'redirect_to_page_id' => false,
        'is_page_redirected' => false,
        'redirect_to_url' => false,
        'title' => false,
        'meta_description' => false,
        'page_expiry_enabled' => false,
        'slug' => false,
        'url' => false,
        'expires_at' => 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 = [
        'domain' => 'domain',
        'redirect_to_page_id' => 'redirectToPageId',
        'is_page_redirected' => 'isPageRedirected',
        'redirect_to_url' => 'redirectToUrl',
        'title' => 'title',
        'meta_description' => 'metaDescription',
        'page_expiry_enabled' => 'pageExpiryEnabled',
        'slug' => 'slug',
        'url' => 'url',
        'expires_at' => 'expiresAt'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'domain' => 'setDomain',
        'redirect_to_page_id' => 'setRedirectToPageId',
        'is_page_redirected' => 'setIsPageRedirected',
        'redirect_to_url' => 'setRedirectToUrl',
        'title' => 'setTitle',
        'meta_description' => 'setMetaDescription',
        'page_expiry_enabled' => 'setPageExpiryEnabled',
        'slug' => 'setSlug',
        'url' => 'setUrl',
        'expires_at' => 'setExpiresAt'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'domain' => 'getDomain',
        'redirect_to_page_id' => 'getRedirectToPageId',
        'is_page_redirected' => 'getIsPageRedirected',
        'redirect_to_url' => 'getRedirectToUrl',
        'title' => 'getTitle',
        'meta_description' => 'getMetaDescription',
        'page_expiry_enabled' => 'getPageExpiryEnabled',
        'slug' => 'getSlug',
        'url' => 'getUrl',
        'expires_at' => 'getExpiresAt'
    ];

    /**
     * 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('domain', $data ?? [], null);
        $this->setIfExists('redirect_to_page_id', $data ?? [], null);
        $this->setIfExists('is_page_redirected', $data ?? [], null);
        $this->setIfExists('redirect_to_url', $data ?? [], null);
        $this->setIfExists('title', $data ?? [], null);
        $this->setIfExists('meta_description', $data ?? [], null);
        $this->setIfExists('page_expiry_enabled', $data ?? [], null);
        $this->setIfExists('slug', $data ?? [], null);
        $this->setIfExists('url', $data ?? [], null);
        $this->setIfExists('expires_at', $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 domain
     *
     * @return string|null
     */
    public function getDomain()
    {
        return $this->container['domain'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets url
     *
     * @param string|null $url 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;
    }

    /**
     * Gets expires_at
     *
     * @return \DateTime|null
     */
    public function getExpiresAt()
    {
        return $this->container['expires_at'];
    }

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

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


