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

/**
 * Note 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 Note implements ModelInterface, ArrayAccess, JsonSerializable
{
    use RawData;

    public const DISCRIMINATOR = null;

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

    /**
      * 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 = [
        'content' => 'string',
        'lead_id' => 'string',
        'deal_id' => 'int',
        'person_id' => 'int',
        'org_id' => 'int',
        'user_id' => 'int',
        'add_time' => 'string',
        'pinned_to_lead_flag' => '\Pipedrive\Model\NumberBoolean',
        'pinned_to_deal_flag' => '\Pipedrive\Model\NumberBoolean',
        'pinned_to_organization_flag' => '\Pipedrive\Model\NumberBoolean',
        'pinned_to_person_flag' => '\Pipedrive\Model\NumberBoolean'
    ];

    /**
      * 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 = [
        'content' => null,
        'lead_id' => 'uuid',
        'deal_id' => null,
        'person_id' => null,
        'org_id' => null,
        'user_id' => null,
        'add_time' => null,
        'pinned_to_lead_flag' => null,
        'pinned_to_deal_flag' => null,
        'pinned_to_organization_flag' => null,
        'pinned_to_person_flag' => null
    ];

    /**
     * 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 = [
        'content' => 'content',
        'lead_id' => 'lead_id',
        'deal_id' => 'deal_id',
        'person_id' => 'person_id',
        'org_id' => 'org_id',
        'user_id' => 'user_id',
        'add_time' => 'add_time',
        'pinned_to_lead_flag' => 'pinned_to_lead_flag',
        'pinned_to_deal_flag' => 'pinned_to_deal_flag',
        'pinned_to_organization_flag' => 'pinned_to_organization_flag',
        'pinned_to_person_flag' => 'pinned_to_person_flag'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'content' => 'setContent',
        'lead_id' => 'setLeadId',
        'deal_id' => 'setDealId',
        'person_id' => 'setPersonId',
        'org_id' => 'setOrgId',
        'user_id' => 'setUserId',
        'add_time' => 'setAddTime',
        'pinned_to_lead_flag' => 'setPinnedToLeadFlag',
        'pinned_to_deal_flag' => 'setPinnedToDealFlag',
        'pinned_to_organization_flag' => 'setPinnedToOrganizationFlag',
        'pinned_to_person_flag' => 'setPinnedToPersonFlag'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'content' => 'getContent',
        'lead_id' => 'getLeadId',
        'deal_id' => 'getDealId',
        'person_id' => 'getPersonId',
        'org_id' => 'getOrgId',
        'user_id' => 'getUserId',
        'add_time' => 'getAddTime',
        'pinned_to_lead_flag' => 'getPinnedToLeadFlag',
        'pinned_to_deal_flag' => 'getPinnedToDealFlag',
        'pinned_to_organization_flag' => 'getPinnedToOrganizationFlag',
        'pinned_to_person_flag' => 'getPinnedToPersonFlag'
    ];

    /**
     * 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['content'] = $data['content'] ?? null;
        $this->container['lead_id'] = $data['lead_id'] ?? null;
        $this->container['deal_id'] = $data['deal_id'] ?? null;
        $this->container['person_id'] = $data['person_id'] ?? null;
        $this->container['org_id'] = $data['org_id'] ?? null;
        $this->container['user_id'] = $data['user_id'] ?? null;
        $this->container['add_time'] = $data['add_time'] ?? null;
        $this->container['pinned_to_lead_flag'] = $data['pinned_to_lead_flag'] ?? null;
        $this->container['pinned_to_deal_flag'] = $data['pinned_to_deal_flag'] ?? null;
        $this->container['pinned_to_organization_flag'] = $data['pinned_to_organization_flag'] ?? null;
        $this->container['pinned_to_person_flag'] = $data['pinned_to_person_flag'] ?? 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 content
     *
     * @return string|null
     */
    public function getContent()
    {
        return $this->container['content'];
    }

    /**
     * Sets content
     *
     * @param string|null $content The content of the note in HTML format. Subject to sanitization on the back-end.
     *
     * @return self
     */
    public function setContent($content): self
    {
        $this->container['content'] = $content;

        return $this;
    }

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

    /**
     * Sets lead_id
     *
     * @param string|null $lead_id The ID of the lead the note will be attached to
     *
     * @return self
     */
    public function setLeadId($lead_id): self
    {
        $this->container['lead_id'] = $lead_id;

        return $this;
    }

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

    /**
     * Sets deal_id
     *
     * @param int|null $deal_id The ID of the deal the note will be attached to
     *
     * @return self
     */
    public function setDealId($deal_id): self
    {
        $this->container['deal_id'] = $deal_id;

        return $this;
    }

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

    /**
     * Sets person_id
     *
     * @param int|null $person_id The ID of the person the note will be attached to
     *
     * @return self
     */
    public function setPersonId($person_id): self
    {
        $this->container['person_id'] = $person_id;

        return $this;
    }

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

    /**
     * Sets org_id
     *
     * @param int|null $org_id The ID of the organization the note will be attached to
     *
     * @return self
     */
    public function setOrgId($org_id): self
    {
        $this->container['org_id'] = $org_id;

        return $this;
    }

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

    /**
     * Sets user_id
     *
     * @param int|null $user_id The ID of the user who will be marked as the author of the note. Only an admin can change the author.
     *
     * @return self
     */
    public function setUserId($user_id): self
    {
        $this->container['user_id'] = $user_id;

        return $this;
    }

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

    /**
     * Sets add_time
     *
     * @param string|null $add_time The optional creation date & time of the note in UTC. Can be set in the past or in the future. Format: YYYY-MM-DD HH:MM:SS
     *
     * @return self
     */
    public function setAddTime($add_time): self
    {
        $this->container['add_time'] = $add_time;

        return $this;
    }

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

    /**
     * Sets pinned_to_lead_flag
     *
     * @param \Pipedrive\Model\NumberBoolean|null $pinned_to_lead_flag If set, the results are filtered by note to lead pinning state (`lead_id` is also required)
     *
     * @return self
     */
    public function setPinnedToLeadFlag($pinned_to_lead_flag): self
    {
        $this->container['pinned_to_lead_flag'] = $pinned_to_lead_flag;

        return $this;
    }

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

    /**
     * Sets pinned_to_deal_flag
     *
     * @param \Pipedrive\Model\NumberBoolean|null $pinned_to_deal_flag If set, the results are filtered by note to deal pinning state (`deal_id` is also required)
     *
     * @return self
     */
    public function setPinnedToDealFlag($pinned_to_deal_flag): self
    {
        $this->container['pinned_to_deal_flag'] = $pinned_to_deal_flag;

        return $this;
    }

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

    /**
     * Sets pinned_to_organization_flag
     *
     * @param \Pipedrive\Model\NumberBoolean|null $pinned_to_organization_flag If set, the results are filtered by note to organization pinning state (`org_id` is also required)
     *
     * @return self
     */
    public function setPinnedToOrganizationFlag($pinned_to_organization_flag): self
    {
        $this->container['pinned_to_organization_flag'] = $pinned_to_organization_flag;

        return $this;
    }

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

    /**
     * Sets pinned_to_person_flag
     *
     * @param \Pipedrive\Model\NumberBoolean|null $pinned_to_person_flag If set, the results are filtered by note to person pinning state (`person_id` is also required)
     *
     * @return self
     */
    public function setPinnedToPersonFlag($pinned_to_person_flag): self
    {
        $this->container['pinned_to_person_flag'] = $pinned_to_person_flag;

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


