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

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

    public const DISCRIMINATOR = null;

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

    /**
      * 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 = [
        'user_id' => 'int',
        'activity_id' => 'int',
        'subject' => 'string',
        'duration' => 'string',
        'outcome' => 'string',
        'from_phone_number' => 'string',
        'to_phone_number' => 'string',
        'start_time' => '\DateTime',
        'end_time' => '\DateTime',
        'person_id' => 'int',
        'org_id' => 'int',
        'deal_id' => 'int',
        'lead_id' => 'string',
        'note' => 'string',
        'id' => 'string',
        'has_recording' => 'bool',
        'company_id' => 'int'
    ];

    /**
      * 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 = [
        'user_id' => null,
        'activity_id' => null,
        'subject' => null,
        'duration' => null,
        'outcome' => null,
        'from_phone_number' => null,
        'to_phone_number' => null,
        'start_time' => 'date-time',
        'end_time' => 'date-time',
        'person_id' => null,
        'org_id' => null,
        'deal_id' => null,
        'lead_id' => 'uuid',
        'note' => null,
        'id' => null,
        'has_recording' => null,
        'company_id' => 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 = [
        'user_id' => 'user_id',
        'activity_id' => 'activity_id',
        'subject' => 'subject',
        'duration' => 'duration',
        'outcome' => 'outcome',
        'from_phone_number' => 'from_phone_number',
        'to_phone_number' => 'to_phone_number',
        'start_time' => 'start_time',
        'end_time' => 'end_time',
        'person_id' => 'person_id',
        'org_id' => 'org_id',
        'deal_id' => 'deal_id',
        'lead_id' => 'lead_id',
        'note' => 'note',
        'id' => 'id',
        'has_recording' => 'has_recording',
        'company_id' => 'company_id'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'user_id' => 'setUserId',
        'activity_id' => 'setActivityId',
        'subject' => 'setSubject',
        'duration' => 'setDuration',
        'outcome' => 'setOutcome',
        'from_phone_number' => 'setFromPhoneNumber',
        'to_phone_number' => 'setToPhoneNumber',
        'start_time' => 'setStartTime',
        'end_time' => 'setEndTime',
        'person_id' => 'setPersonId',
        'org_id' => 'setOrgId',
        'deal_id' => 'setDealId',
        'lead_id' => 'setLeadId',
        'note' => 'setNote',
        'id' => 'setId',
        'has_recording' => 'setHasRecording',
        'company_id' => 'setCompanyId'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'user_id' => 'getUserId',
        'activity_id' => 'getActivityId',
        'subject' => 'getSubject',
        'duration' => 'getDuration',
        'outcome' => 'getOutcome',
        'from_phone_number' => 'getFromPhoneNumber',
        'to_phone_number' => 'getToPhoneNumber',
        'start_time' => 'getStartTime',
        'end_time' => 'getEndTime',
        'person_id' => 'getPersonId',
        'org_id' => 'getOrgId',
        'deal_id' => 'getDealId',
        'lead_id' => 'getLeadId',
        'note' => 'getNote',
        'id' => 'getId',
        'has_recording' => 'getHasRecording',
        'company_id' => 'getCompanyId'
    ];

    /**
     * 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;
    }

    const OUTCOME_CONNECTED = 'connected';
    const OUTCOME_NO_ANSWER = 'no_answer';
    const OUTCOME_LEFT_MESSAGE = 'left_message';
    const OUTCOME_LEFT_VOICEMAIL = 'left_voicemail';
    const OUTCOME_WRONG_NUMBER = 'wrong_number';
    const OUTCOME_BUSY = 'busy';

    /**
     * Gets allowable values of the enum
     *
     * @phpstan-return  array<string|int>
     * @phpsalm-return  array<string|int>
     * @return (string|int)[]
     */
    public function getOutcomeAllowableValues(): array
    {
        return [
            self::OUTCOME_CONNECTED,
            self::OUTCOME_NO_ANSWER,
            self::OUTCOME_LEFT_MESSAGE,
            self::OUTCOME_LEFT_VOICEMAIL,
            self::OUTCOME_WRONG_NUMBER,
            self::OUTCOME_BUSY,
        ];
    }

    /**
     * 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['user_id'] = $data['user_id'] ?? null;
        $this->container['activity_id'] = $data['activity_id'] ?? null;
        $this->container['subject'] = $data['subject'] ?? null;
        $this->container['duration'] = $data['duration'] ?? null;
        $this->container['outcome'] = $data['outcome'] ?? null;
        $this->container['from_phone_number'] = $data['from_phone_number'] ?? null;
        $this->container['to_phone_number'] = $data['to_phone_number'] ?? null;
        $this->container['start_time'] = $data['start_time'] ?? null;
        $this->container['end_time'] = $data['end_time'] ?? null;
        $this->container['person_id'] = $data['person_id'] ?? null;
        $this->container['org_id'] = $data['org_id'] ?? null;
        $this->container['deal_id'] = $data['deal_id'] ?? null;
        $this->container['lead_id'] = $data['lead_id'] ?? null;
        $this->container['note'] = $data['note'] ?? null;
        $this->container['id'] = $data['id'] ?? null;
        $this->container['has_recording'] = $data['has_recording'] ?? null;
        $this->container['company_id'] = $data['company_id'] ?? 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 = [];

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

        if ($this->container['to_phone_number'] === null) {
            $invalidProperties[] = "'to_phone_number' can't be null";
        }
        if ($this->container['start_time'] === null) {
            $invalidProperties[] = "'start_time' can't be null";
        }
        if ($this->container['end_time'] === null) {
            $invalidProperties[] = "'end_time' 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(): bool
    {
        return count($this->listInvalidProperties()) === 0;
    }


    /**
     * 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 owner of the call log. Please note that a user without account settings access cannot create call logs for other users.
     *
     * @return self
     */
    public function setUserId($user_id): self
    {
        $this->container['user_id'] = $user_id;

        return $this;
    }

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

    /**
     * Sets activity_id
     *
     * @param int|null $activity_id If specified, this activity will be converted into a call log, with the information provided. When this field is used, you don't need to specify `deal_id`, `person_id` or `org_id`, as they will be ignored in favor of the values already available in the activity. The `activity_id` must refer to a `call` type activity.
     *
     * @return self
     */
    public function setActivityId($activity_id): self
    {
        $this->container['activity_id'] = $activity_id;

        return $this;
    }

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

    /**
     * Sets subject
     *
     * @param string|null $subject The name of the activity this call is attached to
     *
     * @return self
     */
    public function setSubject($subject): self
    {
        $this->container['subject'] = $subject;

        return $this;
    }

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

    /**
     * Sets duration
     *
     * @param string|null $duration The duration of the call in seconds
     *
     * @return self
     */
    public function setDuration($duration): self
    {
        $this->container['duration'] = $duration;

        return $this;
    }

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

    /**
     * Sets outcome
     *
     * @param string $outcome Describes the outcome of the call
     *
     * @return self
     */
    public function setOutcome($outcome): self
    {
        $allowedValues = $this->getOutcomeAllowableValues();
        if (!in_array($outcome, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'outcome', must be one of '%s'",
                    $outcome,
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['outcome'] = $outcome;

        return $this;
    }

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

    /**
     * Sets from_phone_number
     *
     * @param string|null $from_phone_number The number that made the call
     *
     * @return self
     */
    public function setFromPhoneNumber($from_phone_number): self
    {
        $this->container['from_phone_number'] = $from_phone_number;

        return $this;
    }

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

    /**
     * Sets to_phone_number
     *
     * @param string $to_phone_number The number called
     *
     * @return self
     */
    public function setToPhoneNumber($to_phone_number): self
    {
        $this->container['to_phone_number'] = $to_phone_number;

        return $this;
    }

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

    /**
     * Sets start_time
     *
     * @param \DateTime $start_time The date and time of the start of the call in UTC. Format: YYYY-MM-DD HH:MM:SS.
     *
     * @return self
     */
    public function setStartTime($start_time): self
    {
        $this->container['start_time'] = $start_time;

        return $this;
    }

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

    /**
     * Sets end_time
     *
     * @param \DateTime $end_time The date and time of the end of the call in UTC. Format: YYYY-MM-DD HH:MM:SS.
     *
     * @return self
     */
    public function setEndTime($end_time): self
    {
        $this->container['end_time'] = $end_time;

        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 this call is associated with
     *
     * @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 this call is associated with
     *
     * @return self
     */
    public function setOrgId($org_id): self
    {
        $this->container['org_id'] = $org_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 this call is associated with. A call log can be associated with either a deal or a lead, but not both at once.
     *
     * @return self
     */
    public function setDealId($deal_id): self
    {
        $this->container['deal_id'] = $deal_id;

        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 in the UUID format this call is associated with. A call log can be associated with either a deal or a lead, but not both at once.
     *
     * @return self
     */
    public function setLeadId($lead_id): self
    {
        $this->container['lead_id'] = $lead_id;

        return $this;
    }

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

    /**
     * Sets note
     *
     * @param string|null $note The note for the call log in HTML format
     *
     * @return self
     */
    public function setNote($note): self
    {
        $this->container['note'] = $note;

        return $this;
    }

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

    /**
     * Sets id
     *
     * @param string|null $id The call log ID, generated when the call log was created
     *
     * @return self
     */
    public function setId($id): self
    {
        $this->container['id'] = $id;

        return $this;
    }

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

    /**
     * Sets has_recording
     *
     * @param bool|null $has_recording If the call log has an audio recording attached, the value should be true
     *
     * @return self
     */
    public function setHasRecording($has_recording): self
    {
        $this->container['has_recording'] = $has_recording;

        return $this;
    }

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

    /**
     * Sets company_id
     *
     * @param int|null $company_id The company ID of the owner of the call log
     *
     * @return self
     */
    public function setCompanyId($company_id): self
    {
        $this->container['company_id'] = $company_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
     */
    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);
    }
}


