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

/**
 * Klaviyo API
 *
 * The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details.
 *
 * Contact: developers@klaviyo.com
 * Generated by: https://openapi-generator.tech
 * OpenAPI Generator version: 6.1.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 KlaviyoAPI\Model;

use \ArrayAccess;
use \KlaviyoAPI\ObjectSerializer;

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'from_email' => 'string',
        'from_label' => 'string',
        'reply_to_email' => 'string',
        'cc_email' => 'string',
        'bcc_email' => 'string',
        'subject_line' => 'string',
        'preview_text' => 'string',
        'template_id' => 'string',
        'smart_sending_enabled' => 'bool',
        'transactional' => 'bool',
        'add_tracking_params' => 'bool',
        'custom_tracking_params' => '\KlaviyoAPI\Model\UtmParam[]',
        'additional_filters' => '\KlaviyoAPI\Model\FlowEmailAdditionalFilters',
        'name' => 'string',
        'id' => '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 = [
        'from_email' => null,
        'from_label' => null,
        'reply_to_email' => null,
        'cc_email' => null,
        'bcc_email' => null,
        'subject_line' => null,
        'preview_text' => null,
        'template_id' => null,
        'smart_sending_enabled' => null,
        'transactional' => null,
        'add_tracking_params' => null,
        'custom_tracking_params' => null,
        'additional_filters' => null,
        'name' => null,
        'id' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'from_email' => true,
		'from_label' => true,
		'reply_to_email' => true,
		'cc_email' => true,
		'bcc_email' => true,
		'subject_line' => true,
		'preview_text' => true,
		'template_id' => true,
		'smart_sending_enabled' => false,
		'transactional' => false,
		'add_tracking_params' => false,
		'custom_tracking_params' => true,
		'additional_filters' => true,
		'name' => true,
		'id' => true
    ];

    /**
      * 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;
    }

    /**
     * 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 = [
        'from_email' => 'from_email',
        'from_label' => 'from_label',
        'reply_to_email' => 'reply_to_email',
        'cc_email' => 'cc_email',
        'bcc_email' => 'bcc_email',
        'subject_line' => 'subject_line',
        'preview_text' => 'preview_text',
        'template_id' => 'template_id',
        'smart_sending_enabled' => 'smart_sending_enabled',
        'transactional' => 'transactional',
        'add_tracking_params' => 'add_tracking_params',
        'custom_tracking_params' => 'custom_tracking_params',
        'additional_filters' => 'additional_filters',
        'name' => 'name',
        'id' => 'id'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'from_email' => 'setFromEmail',
        'from_label' => 'setFromLabel',
        'reply_to_email' => 'setReplyToEmail',
        'cc_email' => 'setCcEmail',
        'bcc_email' => 'setBccEmail',
        'subject_line' => 'setSubjectLine',
        'preview_text' => 'setPreviewText',
        'template_id' => 'setTemplateId',
        'smart_sending_enabled' => 'setSmartSendingEnabled',
        'transactional' => 'setTransactional',
        'add_tracking_params' => 'setAddTrackingParams',
        'custom_tracking_params' => 'setCustomTrackingParams',
        'additional_filters' => 'setAdditionalFilters',
        'name' => 'setName',
        'id' => 'setId'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'from_email' => 'getFromEmail',
        'from_label' => 'getFromLabel',
        'reply_to_email' => 'getReplyToEmail',
        'cc_email' => 'getCcEmail',
        'bcc_email' => 'getBccEmail',
        'subject_line' => 'getSubjectLine',
        'preview_text' => 'getPreviewText',
        'template_id' => 'getTemplateId',
        'smart_sending_enabled' => 'getSmartSendingEnabled',
        'transactional' => 'getTransactional',
        'add_tracking_params' => 'getAddTrackingParams',
        'custom_tracking_params' => 'getCustomTrackingParams',
        'additional_filters' => 'getAdditionalFilters',
        'name' => 'getName',
        'id' => 'getId'
    ];

    /**
     * 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[] $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(array $data = null)
    {
        $this->setIfExists('from_email', $data ?? [], null);
        $this->setIfExists('from_label', $data ?? [], null);
        $this->setIfExists('reply_to_email', $data ?? [], null);
        $this->setIfExists('cc_email', $data ?? [], null);
        $this->setIfExists('bcc_email', $data ?? [], null);
        $this->setIfExists('subject_line', $data ?? [], null);
        $this->setIfExists('preview_text', $data ?? [], null);
        $this->setIfExists('template_id', $data ?? [], null);
        $this->setIfExists('smart_sending_enabled', $data ?? [], true);
        $this->setIfExists('transactional', $data ?? [], false);
        $this->setIfExists('add_tracking_params', $data ?? [], false);
        $this->setIfExists('custom_tracking_params', $data ?? [], null);
        $this->setIfExists('additional_filters', $data ?? [], null);
        $this->setIfExists('name', $data ?? [], null);
        $this->setIfExists('id', $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 = [];

        if ($this->container['from_email'] === null) {
            $invalidProperties[] = "'from_email' can't be null";
        }
        if ($this->container['from_label'] === null) {
            $invalidProperties[] = "'from_label' can't be null";
        }
        if ($this->container['reply_to_email'] === null) {
            $invalidProperties[] = "'reply_to_email' can't be null";
        }
        if ($this->container['cc_email'] === null) {
            $invalidProperties[] = "'cc_email' can't be null";
        }
        if ($this->container['bcc_email'] === null) {
            $invalidProperties[] = "'bcc_email' can't be null";
        }
        if ($this->container['subject_line'] === null) {
            $invalidProperties[] = "'subject_line' can't be null";
        }
        if ($this->container['preview_text'] === null) {
            $invalidProperties[] = "'preview_text' can't be null";
        }
        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 from_email
     *
     * @return string
     */
    public function getFromEmail()
    {
        return $this->container['from_email'];
    }

    /**
     * Sets from_email
     *
     * @param string $from_email from_email
     *
     * @return self
     */
    public function setFromEmail($from_email)
    {

        if (is_null($from_email)) {
            array_push($this->openAPINullablesSetToNull, 'from_email');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('from_email', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }

        $this->container['from_email'] = $from_email;

        return $this;
    }

    /**
     * Gets from_label
     *
     * @return string
     */
    public function getFromLabel()
    {
        return $this->container['from_label'];
    }

    /**
     * Sets from_label
     *
     * @param string $from_label from_label
     *
     * @return self
     */
    public function setFromLabel($from_label)
    {

        if (is_null($from_label)) {
            array_push($this->openAPINullablesSetToNull, 'from_label');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('from_label', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }

        $this->container['from_label'] = $from_label;

        return $this;
    }

    /**
     * Gets reply_to_email
     *
     * @return string
     */
    public function getReplyToEmail()
    {
        return $this->container['reply_to_email'];
    }

    /**
     * Sets reply_to_email
     *
     * @param string $reply_to_email reply_to_email
     *
     * @return self
     */
    public function setReplyToEmail($reply_to_email)
    {

        if (is_null($reply_to_email)) {
            array_push($this->openAPINullablesSetToNull, 'reply_to_email');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('reply_to_email', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }

        $this->container['reply_to_email'] = $reply_to_email;

        return $this;
    }

    /**
     * Gets cc_email
     *
     * @return string
     */
    public function getCcEmail()
    {
        return $this->container['cc_email'];
    }

    /**
     * Sets cc_email
     *
     * @param string $cc_email cc_email
     *
     * @return self
     */
    public function setCcEmail($cc_email)
    {

        if (is_null($cc_email)) {
            array_push($this->openAPINullablesSetToNull, 'cc_email');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('cc_email', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }

        $this->container['cc_email'] = $cc_email;

        return $this;
    }

    /**
     * Gets bcc_email
     *
     * @return string
     */
    public function getBccEmail()
    {
        return $this->container['bcc_email'];
    }

    /**
     * Sets bcc_email
     *
     * @param string $bcc_email bcc_email
     *
     * @return self
     */
    public function setBccEmail($bcc_email)
    {

        if (is_null($bcc_email)) {
            array_push($this->openAPINullablesSetToNull, 'bcc_email');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('bcc_email', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }

        $this->container['bcc_email'] = $bcc_email;

        return $this;
    }

    /**
     * Gets subject_line
     *
     * @return string
     */
    public function getSubjectLine()
    {
        return $this->container['subject_line'];
    }

    /**
     * Sets subject_line
     *
     * @param string $subject_line subject_line
     *
     * @return self
     */
    public function setSubjectLine($subject_line)
    {

        if (is_null($subject_line)) {
            array_push($this->openAPINullablesSetToNull, 'subject_line');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('subject_line', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }

        $this->container['subject_line'] = $subject_line;

        return $this;
    }

    /**
     * Gets preview_text
     *
     * @return string
     */
    public function getPreviewText()
    {
        return $this->container['preview_text'];
    }

    /**
     * Sets preview_text
     *
     * @param string $preview_text preview_text
     *
     * @return self
     */
    public function setPreviewText($preview_text)
    {

        if (is_null($preview_text)) {
            array_push($this->openAPINullablesSetToNull, 'preview_text');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('preview_text', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }

        $this->container['preview_text'] = $preview_text;

        return $this;
    }

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

    /**
     * Sets template_id
     *
     * @param string|null $template_id template_id
     *
     * @return self
     */
    public function setTemplateId($template_id)
    {

        if (is_null($template_id)) {
            array_push($this->openAPINullablesSetToNull, 'template_id');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('template_id', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }

        $this->container['template_id'] = $template_id;

        return $this;
    }

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

    /**
     * Sets smart_sending_enabled
     *
     * @param bool|null $smart_sending_enabled smart_sending_enabled
     *
     * @return self
     */
    public function setSmartSendingEnabled($smart_sending_enabled)
    {

        if (is_null($smart_sending_enabled)) {
            throw new \InvalidArgumentException('non-nullable smart_sending_enabled cannot be null');
        }

        $this->container['smart_sending_enabled'] = $smart_sending_enabled;

        return $this;
    }

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

    /**
     * Sets transactional
     *
     * @param bool|null $transactional transactional
     *
     * @return self
     */
    public function setTransactional($transactional)
    {

        if (is_null($transactional)) {
            throw new \InvalidArgumentException('non-nullable transactional cannot be null');
        }

        $this->container['transactional'] = $transactional;

        return $this;
    }

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

    /**
     * Sets add_tracking_params
     *
     * @param bool|null $add_tracking_params add_tracking_params
     *
     * @return self
     */
    public function setAddTrackingParams($add_tracking_params)
    {

        if (is_null($add_tracking_params)) {
            throw new \InvalidArgumentException('non-nullable add_tracking_params cannot be null');
        }

        $this->container['add_tracking_params'] = $add_tracking_params;

        return $this;
    }

    /**
     * Gets custom_tracking_params
     *
     * @return \KlaviyoAPI\Model\UtmParam[]|null
     */
    public function getCustomTrackingParams()
    {
        return $this->container['custom_tracking_params'];
    }

    /**
     * Sets custom_tracking_params
     *
     * @param \KlaviyoAPI\Model\UtmParam[]|null $custom_tracking_params custom_tracking_params
     *
     * @return self
     */
    public function setCustomTrackingParams($custom_tracking_params)
    {

        if (is_null($custom_tracking_params)) {
            array_push($this->openAPINullablesSetToNull, 'custom_tracking_params');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('custom_tracking_params', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }

        $this->container['custom_tracking_params'] = $custom_tracking_params;

        return $this;
    }

    /**
     * Gets additional_filters
     *
     * @return \KlaviyoAPI\Model\FlowEmailAdditionalFilters|null
     */
    public function getAdditionalFilters()
    {
        return $this->container['additional_filters'];
    }

    /**
     * Sets additional_filters
     *
     * @param \KlaviyoAPI\Model\FlowEmailAdditionalFilters|null $additional_filters additional_filters
     *
     * @return self
     */
    public function setAdditionalFilters($additional_filters)
    {

        if (is_null($additional_filters)) {
            array_push($this->openAPINullablesSetToNull, 'additional_filters');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('additional_filters', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }

        $this->container['additional_filters'] = $additional_filters;

        return $this;
    }

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

    /**
     * Sets name
     *
     * @param string|null $name name
     *
     * @return self
     */
    public function setName($name)
    {

        if (is_null($name)) {
            array_push($this->openAPINullablesSetToNull, 'name');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('name', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }

        $this->container['name'] = $name;

        return $this;
    }

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

    /**
     * Sets id
     *
     * @param string|null $id id
     *
     * @return self
     */
    public function setId($id)
    {

        if (is_null($id)) {
            array_push($this->openAPINullablesSetToNull, 'id');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('id', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }

        $this->container['id'] = $id;

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


