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

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

    public const DISCRIMINATOR = null;

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

    /**
      * 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 = [
        'field_key' => 'string',
        'old_value' => 'string',
        'new_value' => 'string',
        'actor_user_id' => 'int',
        'time' => 'string',
        'change_source' => 'string',
        'change_source_user_agent' => 'string',
        'is_bulk_update_flag' => 'bool'
    ];

    /**
      * 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 = [
        'field_key' => null,
        'old_value' => null,
        'new_value' => null,
        'actor_user_id' => null,
        'time' => null,
        'change_source' => null,
        'change_source_user_agent' => null,
        'is_bulk_update_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 = [
        'field_key' => 'field_key',
        'old_value' => 'old_value',
        'new_value' => 'new_value',
        'actor_user_id' => 'actor_user_id',
        'time' => 'time',
        'change_source' => 'change_source',
        'change_source_user_agent' => 'change_source_user_agent',
        'is_bulk_update_flag' => 'is_bulk_update_flag'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'field_key' => 'setFieldKey',
        'old_value' => 'setOldValue',
        'new_value' => 'setNewValue',
        'actor_user_id' => 'setActorUserId',
        'time' => 'setTime',
        'change_source' => 'setChangeSource',
        'change_source_user_agent' => 'setChangeSourceUserAgent',
        'is_bulk_update_flag' => 'setIsBulkUpdateFlag'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'field_key' => 'getFieldKey',
        'old_value' => 'getOldValue',
        'new_value' => 'getNewValue',
        'actor_user_id' => 'getActorUserId',
        'time' => 'getTime',
        'change_source' => 'getChangeSource',
        'change_source_user_agent' => 'getChangeSourceUserAgent',
        'is_bulk_update_flag' => 'getIsBulkUpdateFlag'
    ];

    /**
     * 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['field_key'] = $data['field_key'] ?? null;
        $this->container['old_value'] = $data['old_value'] ?? null;
        $this->container['new_value'] = $data['new_value'] ?? null;
        $this->container['actor_user_id'] = $data['actor_user_id'] ?? null;
        $this->container['time'] = $data['time'] ?? null;
        $this->container['change_source'] = $data['change_source'] ?? null;
        $this->container['change_source_user_agent'] = $data['change_source_user_agent'] ?? null;
        $this->container['is_bulk_update_flag'] = $data['is_bulk_update_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 field_key
     *
     * @return string|null
     */
    public function getFieldKey()
    {
        return $this->container['field_key'];
    }

    /**
     * Sets field_key
     *
     * @param string|null $field_key The key of the field that was changed
     *
     * @return self
     */
    public function setFieldKey($field_key): self
    {
        $this->container['field_key'] = $field_key;

        return $this;
    }

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

    /**
     * Sets old_value
     *
     * @param string|null $old_value The value of the field before the change
     *
     * @return self
     */
    public function setOldValue($old_value): self
    {
        $this->container['old_value'] = $old_value;

        return $this;
    }

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

    /**
     * Sets new_value
     *
     * @param string|null $new_value The value of the field after the change
     *
     * @return self
     */
    public function setNewValue($new_value): self
    {
        $this->container['new_value'] = $new_value;

        return $this;
    }

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

    /**
     * Sets actor_user_id
     *
     * @param int|null $actor_user_id The ID of the user who made the change
     *
     * @return self
     */
    public function setActorUserId($actor_user_id): self
    {
        $this->container['actor_user_id'] = $actor_user_id;

        return $this;
    }

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

    /**
     * Sets time
     *
     * @param string|null $time The date and time of the change
     *
     * @return self
     */
    public function setTime($time): self
    {
        $this->container['time'] = $time;

        return $this;
    }

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

    /**
     * Sets change_source
     *
     * @param string|null $change_source The source of change, for example 'app', 'mobile', 'api', etc.
     *
     * @return self
     */
    public function setChangeSource($change_source): self
    {
        $this->container['change_source'] = $change_source;

        return $this;
    }

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

    /**
     * Sets change_source_user_agent
     *
     * @param string|null $change_source_user_agent The user agent from which the change was made
     *
     * @return self
     */
    public function setChangeSourceUserAgent($change_source_user_agent): self
    {
        $this->container['change_source_user_agent'] = $change_source_user_agent;

        return $this;
    }

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

    /**
     * Sets is_bulk_update_flag
     *
     * @param bool|null $is_bulk_update_flag Whether the change was made as part of a bulk update
     *
     * @return self
     */
    public function setIsBulkUpdateFlag($is_bulk_update_flag): self
    {
        $this->container['is_bulk_update_flag'] = $is_bulk_update_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);
    }
}


