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

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'body' => 'string',
        'image_id' => 'string',
        'dynamic_image' => 'string',
        'shorten_links' => 'bool',
        'include_contact_card' => 'bool',
        'add_org_prefix' => 'bool',
        'add_info_link' => 'bool',
        'add_opt_out_language' => 'bool',
        'smart_sending_enabled' => 'bool',
        'sms_quiet_hours_enabled' => 'bool',
        'transactional' => 'bool',
        'add_tracking_params' => 'bool',
        'custom_tracking_params' => '\KlaviyoAPI\Model\UtmParam[]',
        'additional_filters' => '\KlaviyoAPI\Model\FlowSmsAdditionalFilters',
        '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 = [
        'body' => null,
        'image_id' => null,
        'dynamic_image' => null,
        'shorten_links' => null,
        'include_contact_card' => null,
        'add_org_prefix' => null,
        'add_info_link' => null,
        'add_opt_out_language' => null,
        'smart_sending_enabled' => null,
        'sms_quiet_hours_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 = [
        'body' => false,
		'image_id' => true,
		'dynamic_image' => true,
		'shorten_links' => false,
		'include_contact_card' => false,
		'add_org_prefix' => false,
		'add_info_link' => false,
		'add_opt_out_language' => false,
		'smart_sending_enabled' => false,
		'sms_quiet_hours_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 = [
        'body' => 'body',
        'image_id' => 'image_id',
        'dynamic_image' => 'dynamic_image',
        'shorten_links' => 'shorten_links',
        'include_contact_card' => 'include_contact_card',
        'add_org_prefix' => 'add_org_prefix',
        'add_info_link' => 'add_info_link',
        'add_opt_out_language' => 'add_opt_out_language',
        'smart_sending_enabled' => 'smart_sending_enabled',
        'sms_quiet_hours_enabled' => 'sms_quiet_hours_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 = [
        'body' => 'setBody',
        'image_id' => 'setImageId',
        'dynamic_image' => 'setDynamicImage',
        'shorten_links' => 'setShortenLinks',
        'include_contact_card' => 'setIncludeContactCard',
        'add_org_prefix' => 'setAddOrgPrefix',
        'add_info_link' => 'setAddInfoLink',
        'add_opt_out_language' => 'setAddOptOutLanguage',
        'smart_sending_enabled' => 'setSmartSendingEnabled',
        'sms_quiet_hours_enabled' => 'setSmsQuietHoursEnabled',
        '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 = [
        'body' => 'getBody',
        'image_id' => 'getImageId',
        'dynamic_image' => 'getDynamicImage',
        'shorten_links' => 'getShortenLinks',
        'include_contact_card' => 'getIncludeContactCard',
        'add_org_prefix' => 'getAddOrgPrefix',
        'add_info_link' => 'getAddInfoLink',
        'add_opt_out_language' => 'getAddOptOutLanguage',
        'smart_sending_enabled' => 'getSmartSendingEnabled',
        'sms_quiet_hours_enabled' => 'getSmsQuietHoursEnabled',
        '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('body', $data ?? [], null);
        $this->setIfExists('image_id', $data ?? [], null);
        $this->setIfExists('dynamic_image', $data ?? [], null);
        $this->setIfExists('shorten_links', $data ?? [], true);
        $this->setIfExists('include_contact_card', $data ?? [], false);
        $this->setIfExists('add_org_prefix', $data ?? [], true);
        $this->setIfExists('add_info_link', $data ?? [], true);
        $this->setIfExists('add_opt_out_language', $data ?? [], false);
        $this->setIfExists('smart_sending_enabled', $data ?? [], true);
        $this->setIfExists('sms_quiet_hours_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['body'] === null) {
            $invalidProperties[] = "'body' 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 body
     *
     * @return string
     */
    public function getBody()
    {
        return $this->container['body'];
    }

    /**
     * Sets body
     *
     * @param string $body body
     *
     * @return self
     */
    public function setBody($body)
    {

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

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

        return $this;
    }

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

    /**
     * Sets image_id
     *
     * @param string|null $image_id The id of an ImageAsset. If provided, this will take precedence over a dynamic_image.
     *
     * @return self
     */
    public function setImageId($image_id)
    {

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

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

        return $this;
    }

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

    /**
     * Sets dynamic_image
     *
     * @param string|null $dynamic_image A dynamic image asset to include in the SMS message.
     *
     * @return self
     */
    public function setDynamicImage($dynamic_image)
    {

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

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

        return $this;
    }

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

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

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

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

        return $this;
    }

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

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

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

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

        return $this;
    }

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

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

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

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

        return $this;
    }

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

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

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

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

        return $this;
    }

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

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

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

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

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

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

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

        $this->container['sms_quiet_hours_enabled'] = $sms_quiet_hours_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\FlowSmsAdditionalFilters|null
     */
    public function getAdditionalFilters()
    {
        return $this->container['additional_filters'];
    }

    /**
     * Sets additional_filters
     *
     * @param \KlaviyoAPI\Model\FlowSmsAdditionalFilters|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));
    }
}


