<?php
/**
 * BaseMailThreadMessagesAllOf
 *
 * PHP version 7.3
 *
 * @category Class
 * @package  Pipedrive
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * Pipedrive API v1
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.0.0
 * Generated by: https://openapi-generator.tech
 * OpenAPI Generator version: 5.3.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 Pipedrive\Model;

use ArrayAccess;
use JsonException;
use JsonSerializable;
use Pipedrive\Traits\RawData;
use Pipedrive\ObjectSerializer;

/**
 * BaseMailThreadMessagesAllOf Class Doc Comment
 *
 * @category Class
 * @package  Pipedrive
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 * @implements ArrayAccess<TKey, TValue>
 * @template TKey int|null
 * @template TValue mixed|null
 */
class BaseMailThreadMessagesAllOf implements ModelInterface, ArrayAccess, JsonSerializable
{
    use RawData;

    public const DISCRIMINATOR = null;

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      * @phpstan-var array<string, string>
      * @phpsalm-var array<string, string>
      */
    protected static array $openAPITypes = [
        'from' => '\Pipedrive\Model\MailThreadParticipant[]',
        'to' => '\Pipedrive\Model\MailThreadParticipant[]',
        'cc' => '\Pipedrive\Model\MailThreadParticipant[]',
        'bcc' => '\Pipedrive\Model\MailThreadParticipant[]',
        'body_url' => 'string',
        'mail_thread_id' => 'int',
        'draft' => 'string',
        'has_body_flag' => '\Pipedrive\Model\NumberBooleanDefault0',
        'sent_flag' => '\Pipedrive\Model\NumberBooleanDefault0',
        'sent_from_pipedrive_flag' => '\Pipedrive\Model\NumberBooleanDefault0',
        'message_time' => '\DateTime',
        'add_time' => '\DateTime',
        'update_time' => '\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 = [
        'from' => null,
        'to' => null,
        'cc' => null,
        'bcc' => null,
        'body_url' => null,
        'mail_thread_id' => null,
        'draft' => null,
        'has_body_flag' => null,
        'sent_flag' => null,
        'sent_from_pipedrive_flag' => null,
        'message_time' => 'date-time',
        'add_time' => 'date-time',
        'update_time' => 'date-time'
    ];

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @phpstan-return array<string, string>
     * @psalm-return array<string, string>
     * @return array
     */
    public static function openAPITypes(): array
    {
        return self::$openAPITypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization
     *
     * @phpstan-return array<string, string|null>
     * @psalm-return array<string, string|null>
     * @return array
     */
    public static function openAPIFormats(): array
    {
        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 = [
        'from' => 'from',
        'to' => 'to',
        'cc' => 'cc',
        'bcc' => 'bcc',
        'body_url' => 'body_url',
        'mail_thread_id' => 'mail_thread_id',
        'draft' => 'draft',
        'has_body_flag' => 'has_body_flag',
        'sent_flag' => 'sent_flag',
        'sent_from_pipedrive_flag' => 'sent_from_pipedrive_flag',
        'message_time' => 'message_time',
        'add_time' => 'add_time',
        'update_time' => 'update_time'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'from' => 'setFrom',
        'to' => 'setTo',
        'cc' => 'setCc',
        'bcc' => 'setBcc',
        'body_url' => 'setBodyUrl',
        'mail_thread_id' => 'setMailThreadId',
        'draft' => 'setDraft',
        'has_body_flag' => 'setHasBodyFlag',
        'sent_flag' => 'setSentFlag',
        'sent_from_pipedrive_flag' => 'setSentFromPipedriveFlag',
        'message_time' => 'setMessageTime',
        'add_time' => 'setAddTime',
        'update_time' => 'setUpdateTime'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'from' => 'getFrom',
        'to' => 'getTo',
        'cc' => 'getCc',
        'bcc' => 'getBcc',
        'body_url' => 'getBodyUrl',
        'mail_thread_id' => 'getMailThreadId',
        'draft' => 'getDraft',
        'has_body_flag' => 'getHasBodyFlag',
        'sent_flag' => 'getSentFlag',
        'sent_from_pipedrive_flag' => 'getSentFromPipedriveFlag',
        'message_time' => 'getMessageTime',
        'add_time' => 'getAddTime',
        'update_time' => 'getUpdateTime'
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @phpstan-return array<string, string>
     * @psalm-return array<string, string>
     * @return array
     */
    public static function attributeMap(): array
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @phpstan-return array<string, string>
     * @psalm-return array<string, string>
     * @return array
     */
    public static function setters(): array
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @phpstan-return array<string, string>
     * @psalm-return array<string, string>
     * @return array
     */
    public static function getters(): array
    {
        return self::$getters;
    }

    /**
     * The original name of the model.
     *
     * @return string
     */
    public function getModelName(): string
    {
        return self::$openAPIModelName;
    }


    /**
     * Associative array for storing property values
     *
     * @var array
     * @phpstan-var array<int|string, mixed>
     * @psalm-var array<int|string, mixed>
     */
    protected array $container = [];

    /**
     * Constructor
     *
     * @phpstan-param array<string, mixed>|null $data
     * @psalm-param array<string, mixed>|null $data
     * @param array|null $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(array $data = null)
    {
        $this->container['from'] = $data['from'] ?? null;
        $this->container['to'] = $data['to'] ?? null;
        $this->container['cc'] = $data['cc'] ?? null;
        $this->container['bcc'] = $data['bcc'] ?? null;
        $this->container['body_url'] = $data['body_url'] ?? null;
        $this->container['mail_thread_id'] = $data['mail_thread_id'] ?? null;
        $this->container['draft'] = $data['draft'] ?? null;
        $this->container['has_body_flag'] = $data['has_body_flag'] ?? null;
        $this->container['sent_flag'] = $data['sent_flag'] ?? null;
        $this->container['sent_from_pipedrive_flag'] = $data['sent_from_pipedrive_flag'] ?? null;
        $this->container['message_time'] = $data['message_time'] ?? null;
        $this->container['add_time'] = $data['add_time'] ?? null;
        $this->container['update_time'] = $data['update_time'] ?? null;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     * @phpstan-return array<int, string>
     * @psalm-return array<int, string>
     */
    public function listInvalidProperties(): array
    {
        $invalidProperties = [];

        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed
     *
     * @return bool True if all properties are valid
     */
    public function valid(): bool
    {
        return count($this->listInvalidProperties()) === 0;
    }


    /**
     * Gets from
     *
     * @return \Pipedrive\Model\MailThreadParticipant[]|null
     */
    public function getFrom()
    {
        return $this->container['from'];
    }

    /**
     * Sets from
     *
     * @param \Pipedrive\Model\MailThreadParticipant[]|null $from Senders of the mail thread
     *
     * @return self
     */
    public function setFrom($from): self
    {
        $this->container['from'] = $from;

        return $this;
    }

    /**
     * Gets to
     *
     * @return \Pipedrive\Model\MailThreadParticipant[]|null
     */
    public function getTo()
    {
        return $this->container['to'];
    }

    /**
     * Sets to
     *
     * @param \Pipedrive\Model\MailThreadParticipant[]|null $to Recipients of the mail thread
     *
     * @return self
     */
    public function setTo($to): self
    {
        $this->container['to'] = $to;

        return $this;
    }

    /**
     * Gets cc
     *
     * @return \Pipedrive\Model\MailThreadParticipant[]|null
     */
    public function getCc()
    {
        return $this->container['cc'];
    }

    /**
     * Sets cc
     *
     * @param \Pipedrive\Model\MailThreadParticipant[]|null $cc Participants of the Cc
     *
     * @return self
     */
    public function setCc($cc): self
    {
        $this->container['cc'] = $cc;

        return $this;
    }

    /**
     * Gets bcc
     *
     * @return \Pipedrive\Model\MailThreadParticipant[]|null
     */
    public function getBcc()
    {
        return $this->container['bcc'];
    }

    /**
     * Sets bcc
     *
     * @param \Pipedrive\Model\MailThreadParticipant[]|null $bcc Participants of the Bcc
     *
     * @return self
     */
    public function setBcc($bcc): self
    {
        $this->container['bcc'] = $bcc;

        return $this;
    }

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

    /**
     * Sets body_url
     *
     * @param string|null $body_url A link to the mail thread message
     *
     * @return self
     */
    public function setBodyUrl($body_url): self
    {
        $this->container['body_url'] = $body_url;

        return $this;
    }

    /**
     * Gets mail_thread_id
     *
     * @return int|null
     */
    public function getMailThreadId()
    {
        return $this->container['mail_thread_id'];
    }

    /**
     * Sets mail_thread_id
     *
     * @param int|null $mail_thread_id ID of the mail thread
     *
     * @return self
     */
    public function setMailThreadId($mail_thread_id): self
    {
        $this->container['mail_thread_id'] = $mail_thread_id;

        return $this;
    }

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

    /**
     * Sets draft
     *
     * @param string|null $draft If the mail message has a draft status then the value is the mail message object as JSON formatted string, otherwise `null`.
     *
     * @return self
     */
    public function setDraft($draft): self
    {
        $this->container['draft'] = $draft;

        return $this;
    }

    /**
     * Gets has_body_flag
     *
     * @return \Pipedrive\Model\NumberBooleanDefault0|null
     */
    public function getHasBodyFlag()
    {
        return $this->container['has_body_flag'];
    }

    /**
     * Sets has_body_flag
     *
     * @param \Pipedrive\Model\NumberBooleanDefault0|null $has_body_flag Whether the mail thread message has a body
     *
     * @return self
     */
    public function setHasBodyFlag($has_body_flag): self
    {
        $this->container['has_body_flag'] = $has_body_flag;

        return $this;
    }

    /**
     * Gets sent_flag
     *
     * @return \Pipedrive\Model\NumberBooleanDefault0|null
     */
    public function getSentFlag()
    {
        return $this->container['sent_flag'];
    }

    /**
     * Sets sent_flag
     *
     * @param \Pipedrive\Model\NumberBooleanDefault0|null $sent_flag Whether the mail thread message is sent
     *
     * @return self
     */
    public function setSentFlag($sent_flag): self
    {
        $this->container['sent_flag'] = $sent_flag;

        return $this;
    }

    /**
     * Gets sent_from_pipedrive_flag
     *
     * @return \Pipedrive\Model\NumberBooleanDefault0|null
     */
    public function getSentFromPipedriveFlag()
    {
        return $this->container['sent_from_pipedrive_flag'];
    }

    /**
     * Sets sent_from_pipedrive_flag
     *
     * @param \Pipedrive\Model\NumberBooleanDefault0|null $sent_from_pipedrive_flag Whether the mail thread message is sent from Pipedrive
     *
     * @return self
     */
    public function setSentFromPipedriveFlag($sent_from_pipedrive_flag): self
    {
        $this->container['sent_from_pipedrive_flag'] = $sent_from_pipedrive_flag;

        return $this;
    }

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

    /**
     * Sets message_time
     *
     * @param \DateTime|null $message_time The time when the mail message was received or created
     *
     * @return self
     */
    public function setMessageTime($message_time): self
    {
        $this->container['message_time'] = $message_time;

        return $this;
    }

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

    /**
     * Sets add_time
     *
     * @param \DateTime|null $add_time The time when the mail message was inserted to database
     *
     * @return self
     */
    public function setAddTime($add_time): self
    {
        $this->container['add_time'] = $add_time;

        return $this;
    }

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

    /**
     * Sets update_time
     *
     * @param \DateTime|null $update_time The time when the mail message was updated in database received
     *
     * @return self
     */
    public function setUpdateTime($update_time): self
    {
        $this->container['update_time'] = $update_time;

        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
     */
    public function offsetGet($offset): mixed
    {
        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.
     */
    public function jsonSerialize(): mixed
    {
       return ObjectSerializer::sanitizeForSerialization($this);
    }

    /**
     * Gets the string presentation of the object
     *
     * @throws JsonException
     * @return string
     */
    public function __toString()
    {
        return json_encode(
            ObjectSerializer::sanitizeForSerialization($this),
            JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR
        );
    }

    /**
     * Gets a header-safe presentation of the object
     *
     * @throws JsonException
     * @return string
     */
    public function toHeaderValue(): string
    {
        return json_encode(ObjectSerializer::sanitizeForSerialization($this), JSON_THROW_ON_ERROR);
    }
}


