<?php

// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

namespace Algolia\AlgoliaSearch\Model\AgentStudio;

use Algolia\AlgoliaSearch\Model\AbstractModel;
use Algolia\AlgoliaSearch\Model\ModelInterface;

/**
 * MessageResponse Class Doc Comment.
 *
 * @category Class
 *
 * @description Response model for a message.
 */
class MessageResponse extends AbstractModel implements ModelInterface, \ArrayAccess, \JsonSerializable
{
    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $modelTypes = [
        'id' => 'string',
        'conversationId' => 'string',
        'role' => '\Algolia\AlgoliaSearch\Model\AgentStudio\MessageRole',
        'parts' => '\Algolia\AlgoliaSearch\Model\AgentStudio\MessagePart[]',
        'createdAt' => 'string',
        'updatedAt' => 'string',
        'model' => 'string',
        'inputTokens' => 'int',
        'outputTokens' => 'int',
        'turnContext' => 'array<string,string>',
    ];

    /**
     * Array of property to format mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $modelFormats = [
        'id' => null,
        'conversationId' => null,
        'role' => null,
        'parts' => null,
        'createdAt' => null,
        'updatedAt' => null,
        'model' => null,
        'inputTokens' => null,
        'outputTokens' => null,
        'turnContext' => null,
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name.
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'id' => 'id',
        'conversationId' => 'conversationId',
        'role' => 'role',
        'parts' => 'parts',
        'createdAt' => 'createdAt',
        'updatedAt' => 'updatedAt',
        'model' => 'model',
        'inputTokens' => 'inputTokens',
        'outputTokens' => 'outputTokens',
        'turnContext' => 'turnContext',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'id' => 'setId',
        'conversationId' => 'setConversationId',
        'role' => 'setRole',
        'parts' => 'setParts',
        'createdAt' => 'setCreatedAt',
        'updatedAt' => 'setUpdatedAt',
        'model' => 'setModel',
        'inputTokens' => 'setInputTokens',
        'outputTokens' => 'setOutputTokens',
        'turnContext' => 'setTurnContext',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'id' => 'getId',
        'conversationId' => 'getConversationId',
        'role' => 'getRole',
        'parts' => 'getParts',
        'createdAt' => 'getCreatedAt',
        'updatedAt' => 'getUpdatedAt',
        'model' => 'getModel',
        'inputTokens' => 'getInputTokens',
        'outputTokens' => 'getOutputTokens',
        'turnContext' => 'getTurnContext',
    ];

    /**
     * Associative array for storing property values.
     *
     * @var mixed[]
     */
    protected $container = [];

    /**
     * Constructor.
     *
     * @param mixed[] $data Associated array of property values
     */
    public function __construct(?array $data = null)
    {
        if (isset($data['id'])) {
            $this->container['id'] = $data['id'];
        }
        if (isset($data['conversationId'])) {
            $this->container['conversationId'] = $data['conversationId'];
        }
        if (isset($data['role'])) {
            $this->container['role'] = $data['role'];
        }
        if (isset($data['parts'])) {
            $this->container['parts'] = $data['parts'];
        }
        if (isset($data['createdAt'])) {
            $this->container['createdAt'] = $data['createdAt'];
        }
        if (isset($data['updatedAt'])) {
            $this->container['updatedAt'] = $data['updatedAt'];
        }
        if (isset($data['model'])) {
            $this->container['model'] = $data['model'];
        }
        if (isset($data['inputTokens'])) {
            $this->container['inputTokens'] = $data['inputTokens'];
        }
        if (isset($data['outputTokens'])) {
            $this->container['outputTokens'] = $data['outputTokens'];
        }
        if (isset($data['turnContext'])) {
            $this->container['turnContext'] = $data['turnContext'];
        }
    }

    /**
     * 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 property to type mappings. Used for (de)serialization.
     *
     * @return array
     */
    public static function modelTypes()
    {
        return self::$modelTypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization.
     *
     * @return array
     */
    public static function modelFormats()
    {
        return self::$modelFormats;
    }

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

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

        if (!isset($this->container['id']) || null === $this->container['id']) {
            $invalidProperties[] = "'id' can't be null";
        }
        if (!isset($this->container['conversationId']) || null === $this->container['conversationId']) {
            $invalidProperties[] = "'conversationId' can't be null";
        }
        if (!isset($this->container['role']) || null === $this->container['role']) {
            $invalidProperties[] = "'role' can't be null";
        }
        if (!isset($this->container['parts']) || null === $this->container['parts']) {
            $invalidProperties[] = "'parts' can't be null";
        }
        if (!isset($this->container['createdAt']) || null === $this->container['createdAt']) {
            $invalidProperties[] = "'createdAt' can't be null";
        }
        if (!isset($this->container['updatedAt']) || null === $this->container['updatedAt']) {
            $invalidProperties[] = "'updatedAt' 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 0 === count($this->listInvalidProperties());
    }

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

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

        return $this;
    }

    /**
     * Gets conversationId.
     *
     * @return string
     */
    public function getConversationId()
    {
        return $this->container['conversationId'] ?? null;
    }

    /**
     * Sets conversationId.
     *
     * @param string $conversationId conversationId
     *
     * @return self
     */
    public function setConversationId($conversationId)
    {
        $this->container['conversationId'] = $conversationId;

        return $this;
    }

    /**
     * Gets role.
     *
     * @return MessageRole
     */
    public function getRole()
    {
        return $this->container['role'] ?? null;
    }

    /**
     * Sets role.
     *
     * @param MessageRole $role role
     *
     * @return self
     */
    public function setRole($role)
    {
        $this->container['role'] = $role;

        return $this;
    }

    /**
     * Gets parts.
     *
     * @return MessagePart[]
     */
    public function getParts()
    {
        return $this->container['parts'] ?? null;
    }

    /**
     * Sets parts.
     *
     * @param MessagePart[] $parts parts
     *
     * @return self
     */
    public function setParts($parts)
    {
        $this->container['parts'] = $parts;

        return $this;
    }

    /**
     * Gets createdAt.
     *
     * @return string
     */
    public function getCreatedAt()
    {
        return $this->container['createdAt'] ?? null;
    }

    /**
     * Sets createdAt.
     *
     * @param string $createdAt createdAt
     *
     * @return self
     */
    public function setCreatedAt($createdAt)
    {
        $this->container['createdAt'] = $createdAt;

        return $this;
    }

    /**
     * Gets updatedAt.
     *
     * @return string
     */
    public function getUpdatedAt()
    {
        return $this->container['updatedAt'] ?? null;
    }

    /**
     * Sets updatedAt.
     *
     * @param string $updatedAt updatedAt
     *
     * @return self
     */
    public function setUpdatedAt($updatedAt)
    {
        $this->container['updatedAt'] = $updatedAt;

        return $this;
    }

    /**
     * Gets model.
     *
     * @return null|string
     */
    public function getModel()
    {
        return $this->container['model'] ?? null;
    }

    /**
     * Sets model.
     *
     * @param null|string $model model
     *
     * @return self
     */
    public function setModel($model)
    {
        $this->container['model'] = $model;

        return $this;
    }

    /**
     * Gets inputTokens.
     *
     * @return null|int
     */
    public function getInputTokens()
    {
        return $this->container['inputTokens'] ?? null;
    }

    /**
     * Sets inputTokens.
     *
     * @param null|int $inputTokens inputTokens
     *
     * @return self
     */
    public function setInputTokens($inputTokens)
    {
        $this->container['inputTokens'] = $inputTokens;

        return $this;
    }

    /**
     * Gets outputTokens.
     *
     * @return null|int
     */
    public function getOutputTokens()
    {
        return $this->container['outputTokens'] ?? null;
    }

    /**
     * Sets outputTokens.
     *
     * @param null|int $outputTokens outputTokens
     *
     * @return self
     */
    public function setOutputTokens($outputTokens)
    {
        $this->container['outputTokens'] = $outputTokens;

        return $this;
    }

    /**
     * Gets turnContext.
     *
     * @return null|array<string,string>
     */
    public function getTurnContext()
    {
        return $this->container['turnContext'] ?? null;
    }

    /**
     * Sets turnContext.
     *
     * @param null|array<string,string> $turnContext turnContext
     *
     * @return self
     */
    public function setTurnContext($turnContext)
    {
        $this->container['turnContext'] = $turnContext;

        return $this;
    }

    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param int $offset Offset
     */
    public function offsetExists($offset): bool
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param int $offset Offset
     *
     * @return null|mixed
     */
    public function offsetGet($offset): mixed
    {
        return $this->container[$offset] ?? null;
    }

    /**
     * Sets value based on offset.
     *
     * @param null|int $offset Offset
     * @param mixed    $value  Value to be set
     */
    public function offsetSet($offset, $value): void
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param int $offset Offset
     */
    public function offsetUnset($offset): void
    {
        unset($this->container[$offset]);
    }
}
