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

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'title' => 'string',
        'body' => 'string',
        'sound' => 'bool',
        'badge' => 'bool',
        'badge_options' => '\KlaviyoAPI\Model\FlowPushNotificationBadgeOptions',
        'image_id' => 'string',
        'dynamic_image' => 'string',
        'on_open' => 'string',
        'ios_link' => 'string',
        'android_link' => 'string',
        'conversion_metric_id' => 'string',
        'smart_sending_enabled' => 'bool',
        'additional_filters' => '\KlaviyoAPI\Model\FlowPushNotificationAdditionalFilters',
        '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 = [
        'title' => null,
        'body' => null,
        'sound' => null,
        'badge' => null,
        'badge_options' => null,
        'image_id' => null,
        'dynamic_image' => null,
        'on_open' => null,
        'ios_link' => null,
        'android_link' => null,
        'conversion_metric_id' => null,
        'smart_sending_enabled' => null,
        'additional_filters' => null,
        'name' => null,
        'id' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'title' => true,
		'body' => false,
		'sound' => false,
		'badge' => false,
		'badge_options' => false,
		'image_id' => true,
		'dynamic_image' => true,
		'on_open' => false,
		'ios_link' => true,
		'android_link' => true,
		'conversion_metric_id' => true,
		'smart_sending_enabled' => false,
		'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 = [
        'title' => 'title',
        'body' => 'body',
        'sound' => 'sound',
        'badge' => 'badge',
        'badge_options' => 'badge_options',
        'image_id' => 'image_id',
        'dynamic_image' => 'dynamic_image',
        'on_open' => 'on_open',
        'ios_link' => 'ios_link',
        'android_link' => 'android_link',
        'conversion_metric_id' => 'conversion_metric_id',
        'smart_sending_enabled' => 'smart_sending_enabled',
        'additional_filters' => 'additional_filters',
        'name' => 'name',
        'id' => 'id'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'title' => 'setTitle',
        'body' => 'setBody',
        'sound' => 'setSound',
        'badge' => 'setBadge',
        'badge_options' => 'setBadgeOptions',
        'image_id' => 'setImageId',
        'dynamic_image' => 'setDynamicImage',
        'on_open' => 'setOnOpen',
        'ios_link' => 'setIosLink',
        'android_link' => 'setAndroidLink',
        'conversion_metric_id' => 'setConversionMetricId',
        'smart_sending_enabled' => 'setSmartSendingEnabled',
        'additional_filters' => 'setAdditionalFilters',
        'name' => 'setName',
        'id' => 'setId'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'title' => 'getTitle',
        'body' => 'getBody',
        'sound' => 'getSound',
        'badge' => 'getBadge',
        'badge_options' => 'getBadgeOptions',
        'image_id' => 'getImageId',
        'dynamic_image' => 'getDynamicImage',
        'on_open' => 'getOnOpen',
        'ios_link' => 'getIosLink',
        'android_link' => 'getAndroidLink',
        'conversion_metric_id' => 'getConversionMetricId',
        'smart_sending_enabled' => 'getSmartSendingEnabled',
        '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;
    }

    public const ON_OPEN_HOME = 'home';
    public const ON_OPEN_LINK = 'link';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getOnOpenAllowableValues()
    {
        return [
            self::ON_OPEN_HOME,
            self::ON_OPEN_LINK,
        ];
    }

    /**
     * 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('title', $data ?? [], null);
        $this->setIfExists('body', $data ?? [], null);
        $this->setIfExists('sound', $data ?? [], false);
        $this->setIfExists('badge', $data ?? [], false);
        $this->setIfExists('badge_options', $data ?? [], null);
        $this->setIfExists('image_id', $data ?? [], null);
        $this->setIfExists('dynamic_image', $data ?? [], null);
        $this->setIfExists('on_open', $data ?? [], 'home');
        $this->setIfExists('ios_link', $data ?? [], null);
        $this->setIfExists('android_link', $data ?? [], null);
        $this->setIfExists('conversion_metric_id', $data ?? [], null);
        $this->setIfExists('smart_sending_enabled', $data ?? [], true);
        $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";
        }
        $allowedValues = $this->getOnOpenAllowableValues();
        if (!is_null($this->container['on_open']) && !in_array($this->container['on_open'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value '%s' for 'on_open', must be one of '%s'",
                $this->container['on_open'],
                implode("', '", $allowedValues)
            );
        }

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

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

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

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

        return $this;
    }

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

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

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

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

        return $this;
    }

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

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

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

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

        return $this;
    }

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

    /**
     * Sets badge_options
     *
     * @param \KlaviyoAPI\Model\FlowPushNotificationBadgeOptions|null $badge_options badge_options
     *
     * @return self
     */
    public function setBadgeOptions($badge_options)
    {

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

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

        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 push notification.
     *
     * @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 on_open
     *
     * @return string|null
     */
    public function getOnOpen()
    {
        return $this->container['on_open'];
    }

    /**
     * Sets on_open
     *
     * @param string|null $on_open See PushLinkAction in app.  This is not a flow action, but the literal action that should be taken when the push notification is tapped.
     *
     * @return self
     */
    public function setOnOpen($on_open)
    {
        $allowedValues = $this->getOnOpenAllowableValues();
        if (!is_null($on_open) && !in_array($on_open, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'on_open', must be one of '%s'",
                    $on_open,
                    implode("', '", $allowedValues)
                )
            );
        }

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

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

        return $this;
    }

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

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

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

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

        return $this;
    }

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

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

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

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

        return $this;
    }

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

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

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

        $this->container['conversion_metric_id'] = $conversion_metric_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 additional_filters
     *
     * @return \KlaviyoAPI\Model\FlowPushNotificationAdditionalFilters|null
     */
    public function getAdditionalFilters()
    {
        return $this->container['additional_filters'];
    }

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


