<?php
/**
 * SubscriptionResponse
 *
 * PHP version 7.4
 *
 * @category Class
 * @package  HubSpot\Client\Webhooks
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * Webhooks API
 *
 * Provides a way for apps to subscribe to certain change events in HubSpot. Once configured, apps will receive event payloads containing details about the changes at a specified target URL. There can only be one target URL for receiving event notifications per app.
 *
 * The version of the OpenAPI document: v3
 * Generated by: https://openapi-generator.tech
 * OpenAPI Generator version: 6.0.1-SNAPSHOT
 */

/**
 * 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\Webhooks\Model;

use \ArrayAccess;
use \HubSpot\Client\Webhooks\ObjectSerializer;

/**
 * SubscriptionResponse Class Doc Comment
 *
 * @category Class
 * @description Complete details for an event subscription.
 * @package  HubSpot\Client\Webhooks
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 * @implements \ArrayAccess<TKey, TValue>
 * @template TKey int|null
 * @template TValue mixed|null
 */
class SubscriptionResponse implements ModelInterface, ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'event_type' => 'string',
        'property_name' => 'string',
        'active' => 'bool',
        'id' => 'string',
        'created_at' => '\DateTime',
        'updated_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 = [
        'event_type' => null,
        'property_name' => null,
        'active' => null,
        'id' => null,
        'created_at' => 'date-time',
        'updated_at' => 'date-time'
    ];

    /**
     * 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 attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'event_type' => 'eventType',
        'property_name' => 'propertyName',
        'active' => 'active',
        'id' => 'id',
        'created_at' => 'createdAt',
        'updated_at' => 'updatedAt'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'event_type' => 'setEventType',
        'property_name' => 'setPropertyName',
        'active' => 'setActive',
        'id' => 'setId',
        'created_at' => 'setCreatedAt',
        'updated_at' => 'setUpdatedAt'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'event_type' => 'getEventType',
        'property_name' => 'getPropertyName',
        'active' => 'getActive',
        'id' => 'getId',
        'created_at' => 'getCreatedAt',
        'updated_at' => 'getUpdatedAt'
    ];

    /**
     * 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 EVENT_TYPE_CONTACT_PROPERTY_CHANGE = 'contact.propertyChange';
    public const EVENT_TYPE_COMPANY_PROPERTY_CHANGE = 'company.propertyChange';
    public const EVENT_TYPE_DEAL_PROPERTY_CHANGE = 'deal.propertyChange';
    public const EVENT_TYPE_TICKET_PROPERTY_CHANGE = 'ticket.propertyChange';
    public const EVENT_TYPE_PRODUCT_PROPERTY_CHANGE = 'product.propertyChange';
    public const EVENT_TYPE_LINE_ITEM_PROPERTY_CHANGE = 'line_item.propertyChange';
    public const EVENT_TYPE_CONTACT_CREATION = 'contact.creation';
    public const EVENT_TYPE_CONTACT_DELETION = 'contact.deletion';
    public const EVENT_TYPE_CONTACT_PRIVACY_DELETION = 'contact.privacyDeletion';
    public const EVENT_TYPE_COMPANY_CREATION = 'company.creation';
    public const EVENT_TYPE_COMPANY_DELETION = 'company.deletion';
    public const EVENT_TYPE_DEAL_CREATION = 'deal.creation';
    public const EVENT_TYPE_DEAL_DELETION = 'deal.deletion';
    public const EVENT_TYPE_TICKET_CREATION = 'ticket.creation';
    public const EVENT_TYPE_TICKET_DELETION = 'ticket.deletion';
    public const EVENT_TYPE_PRODUCT_CREATION = 'product.creation';
    public const EVENT_TYPE_PRODUCT_DELETION = 'product.deletion';
    public const EVENT_TYPE_LINE_ITEM_CREATION = 'line_item.creation';
    public const EVENT_TYPE_LINE_ITEM_DELETION = 'line_item.deletion';
    public const EVENT_TYPE_CONVERSATION_CREATION = 'conversation.creation';
    public const EVENT_TYPE_CONVERSATION_DELETION = 'conversation.deletion';
    public const EVENT_TYPE_CONVERSATION_NEW_MESSAGE = 'conversation.newMessage';
    public const EVENT_TYPE_CONVERSATION_PRIVACY_DELETION = 'conversation.privacyDeletion';
    public const EVENT_TYPE_CONVERSATION_PROPERTY_CHANGE = 'conversation.propertyChange';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getEventTypeAllowableValues()
    {
        return [
            self::EVENT_TYPE_CONTACT_PROPERTY_CHANGE,
            self::EVENT_TYPE_COMPANY_PROPERTY_CHANGE,
            self::EVENT_TYPE_DEAL_PROPERTY_CHANGE,
            self::EVENT_TYPE_TICKET_PROPERTY_CHANGE,
            self::EVENT_TYPE_PRODUCT_PROPERTY_CHANGE,
            self::EVENT_TYPE_LINE_ITEM_PROPERTY_CHANGE,
            self::EVENT_TYPE_CONTACT_CREATION,
            self::EVENT_TYPE_CONTACT_DELETION,
            self::EVENT_TYPE_CONTACT_PRIVACY_DELETION,
            self::EVENT_TYPE_COMPANY_CREATION,
            self::EVENT_TYPE_COMPANY_DELETION,
            self::EVENT_TYPE_DEAL_CREATION,
            self::EVENT_TYPE_DEAL_DELETION,
            self::EVENT_TYPE_TICKET_CREATION,
            self::EVENT_TYPE_TICKET_DELETION,
            self::EVENT_TYPE_PRODUCT_CREATION,
            self::EVENT_TYPE_PRODUCT_DELETION,
            self::EVENT_TYPE_LINE_ITEM_CREATION,
            self::EVENT_TYPE_LINE_ITEM_DELETION,
            self::EVENT_TYPE_CONVERSATION_CREATION,
            self::EVENT_TYPE_CONVERSATION_DELETION,
            self::EVENT_TYPE_CONVERSATION_NEW_MESSAGE,
            self::EVENT_TYPE_CONVERSATION_PRIVACY_DELETION,
            self::EVENT_TYPE_CONVERSATION_PROPERTY_CHANGE,
        ];
    }

    /**
     * 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->container['event_type'] = $data['event_type'] ?? null;
        $this->container['property_name'] = $data['property_name'] ?? null;
        $this->container['active'] = $data['active'] ?? null;
        $this->container['id'] = $data['id'] ?? null;
        $this->container['created_at'] = $data['created_at'] ?? null;
        $this->container['updated_at'] = $data['updated_at'] ?? null;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        if ($this->container['event_type'] === null) {
            $invalidProperties[] = "'event_type' can't be null";
        }
        $allowedValues = $this->getEventTypeAllowableValues();
        if (!is_null($this->container['event_type']) && !in_array($this->container['event_type'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value '%s' for 'event_type', must be one of '%s'",
                $this->container['event_type'],
                implode("', '", $allowedValues)
            );
        }

        if ($this->container['active'] === null) {
            $invalidProperties[] = "'active' can't be null";
        }
        if ($this->container['id'] === null) {
            $invalidProperties[] = "'id' can't be null";
        }
        if ($this->container['created_at'] === null) {
            $invalidProperties[] = "'created_at' 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 event_type
     *
     * @return string
     */
    public function getEventType()
    {
        return $this->container['event_type'];
    }

    /**
     * Sets event_type
     *
     * @param string $event_type Type of event to listen for. Can be one of `create`, `delete`, `deletedForPrivacy`, or `propertyChange`.
     *
     * @return self
     */
    public function setEventType($event_type)
    {
        $allowedValues = $this->getEventTypeAllowableValues();
        if (!in_array($event_type, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'event_type', must be one of '%s'",
                    $event_type,
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['event_type'] = $event_type;

        return $this;
    }

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

    /**
     * Sets property_name
     *
     * @param string|null $property_name The internal name of the property being monitored for changes. Only applies when `eventType` is `propertyChange`.
     *
     * @return self
     */
    public function setPropertyName($property_name)
    {
        $this->container['property_name'] = $property_name;

        return $this;
    }

    /**
     * Gets active
     *
     * @return bool
     */
    public function getActive()
    {
        return $this->container['active'];
    }

    /**
     * Sets active
     *
     * @param bool $active Determines if the subscription is active or paused.
     *
     * @return self
     */
    public function setActive($active)
    {
        $this->container['active'] = $active;

        return $this;
    }

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

    /**
     * Sets id
     *
     * @param string $id The unique ID of the subscription.
     *
     * @return self
     */
    public function setId($id)
    {
        $this->container['id'] = $id;

        return $this;
    }

    /**
     * Gets created_at
     *
     * @return \DateTime
     */
    public function getCreatedAt()
    {
        return $this->container['created_at'];
    }

    /**
     * Sets created_at
     *
     * @param \DateTime $created_at When this subscription was created. Formatted as milliseconds from the [Unix epoch](#).
     *
     * @return self
     */
    public function setCreatedAt($created_at)
    {
        $this->container['created_at'] = $created_at;

        return $this;
    }

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

    /**
     * Sets updated_at
     *
     * @param \DateTime|null $updated_at When this subscription was last updated. Formatted as milliseconds from the [Unix epoch](#).
     *
     * @return self
     */
    public function setUpdatedAt($updated_at)
    {
        $this->container['updated_at'] = $updated_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));
    }
}


