<?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;

/**
 * ToolPartV5 Class Doc Comment.
 *
 * @category Class
 *
 * @description Model for tool invocation in a Message.
 */
class ToolPartV5 extends AbstractModel implements ModelInterface, \ArrayAccess, \JsonSerializable
{
    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $modelTypes = [
        'type' => 'string',
        'toolCallId' => 'string',
        'state' => '\Algolia\AlgoliaSearch\Model\AgentStudio\ToolState',
        'input' => 'array<string,mixed>',
        'output' => 'array<string,mixed>',
        'errorText' => 'string',
        'providerOptions' => 'array<string,mixed>',
        'requiresApproval' => 'bool',
        'description' => 'string',
        'argsHash' => 'string',
    ];

    /**
     * Array of property to format mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $modelFormats = [
        'type' => null,
        'toolCallId' => null,
        'state' => null,
        'input' => null,
        'output' => null,
        'errorText' => null,
        'providerOptions' => null,
        'requiresApproval' => null,
        'description' => null,
        'argsHash' => null,
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name.
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'type' => 'type',
        'toolCallId' => 'toolCallId',
        'state' => 'state',
        'input' => 'input',
        'output' => 'output',
        'errorText' => 'errorText',
        'providerOptions' => 'providerOptions',
        'requiresApproval' => 'requiresApproval',
        'description' => 'description',
        'argsHash' => 'argsHash',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'type' => 'setType',
        'toolCallId' => 'setToolCallId',
        'state' => 'setState',
        'input' => 'setInput',
        'output' => 'setOutput',
        'errorText' => 'setErrorText',
        'providerOptions' => 'setProviderOptions',
        'requiresApproval' => 'setRequiresApproval',
        'description' => 'setDescription',
        'argsHash' => 'setArgsHash',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'type' => 'getType',
        'toolCallId' => 'getToolCallId',
        'state' => 'getState',
        'input' => 'getInput',
        'output' => 'getOutput',
        'errorText' => 'getErrorText',
        'providerOptions' => 'getProviderOptions',
        'requiresApproval' => 'getRequiresApproval',
        'description' => 'getDescription',
        'argsHash' => 'getArgsHash',
    ];

    /**
     * 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['type'])) {
            $this->container['type'] = $data['type'];
        }
        if (isset($data['toolCallId'])) {
            $this->container['toolCallId'] = $data['toolCallId'];
        }
        if (isset($data['state'])) {
            $this->container['state'] = $data['state'];
        }
        if (isset($data['input'])) {
            $this->container['input'] = $data['input'];
        }
        if (isset($data['output'])) {
            $this->container['output'] = $data['output'];
        }
        if (isset($data['errorText'])) {
            $this->container['errorText'] = $data['errorText'];
        }
        if (isset($data['providerOptions'])) {
            $this->container['providerOptions'] = $data['providerOptions'];
        }
        if (isset($data['requiresApproval'])) {
            $this->container['requiresApproval'] = $data['requiresApproval'];
        }
        if (isset($data['description'])) {
            $this->container['description'] = $data['description'];
        }
        if (isset($data['argsHash'])) {
            $this->container['argsHash'] = $data['argsHash'];
        }
    }

    /**
     * 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['type']) || null === $this->container['type']) {
            $invalidProperties[] = "'type' can't be null";
        }
        if (!isset($this->container['toolCallId']) || null === $this->container['toolCallId']) {
            $invalidProperties[] = "'toolCallId' 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 type.
     *
     * @return string
     */
    public function getType()
    {
        return $this->container['type'] ?? null;
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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