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

/**
 * Episode Class Doc Comment.
 *
 * @category Class
 *
 * @description Episodic memory schema following LangMem's OTAR pattern: Observation → Thoughts → Action → Result  Captures complete interaction experiences for agent learning. See https://langchain-ai.github.io/langmem/concepts/conceptual_guide/#episodic-memory-past-experiences.
 */
class Episode extends AbstractModel implements ModelInterface, \ArrayAccess, \JsonSerializable
{
    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $modelTypes = [
        'observation' => 'string',
        'thoughts' => 'string',
        'action' => 'string',
        'result' => 'string',
    ];

    /**
     * Array of property to format mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $modelFormats = [
        'observation' => null,
        'thoughts' => null,
        'action' => null,
        'result' => null,
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name.
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'observation' => 'observation',
        'thoughts' => 'thoughts',
        'action' => 'action',
        'result' => 'result',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'observation' => 'setObservation',
        'thoughts' => 'setThoughts',
        'action' => 'setAction',
        'result' => 'setResult',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'observation' => 'getObservation',
        'thoughts' => 'getThoughts',
        'action' => 'getAction',
        'result' => 'getResult',
    ];

    /**
     * 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['observation'])) {
            $this->container['observation'] = $data['observation'];
        }
        if (isset($data['thoughts'])) {
            $this->container['thoughts'] = $data['thoughts'];
        }
        if (isset($data['action'])) {
            $this->container['action'] = $data['action'];
        }
        if (isset($data['result'])) {
            $this->container['result'] = $data['result'];
        }
    }

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

    /**
     * Sets observation.
     *
     * @param string $observation What user wanted + key context (1-2 sentences). Include prior failed attempts if they informed the approach.
     *
     * @return self
     */
    public function setObservation($observation)
    {
        $this->container['observation'] = $observation;

        return $this;
    }

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

    /**
     * Sets thoughts.
     *
     * @param string $thoughts WHY this approach was chosen, which constraints/preferences drove decisions (1-3 sentences). Capture reasoning that applies to similar future scenarios.
     *
     * @return self
     */
    public function setThoughts($thoughts)
    {
        $this->container['thoughts'] = $thoughts;

        return $this;
    }

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

    /**
     * Sets action.
     *
     * @param string $action What was done with PRECISE details (1-3 sentences). WITH tool calls: use arrow notation `tool(param:value) → feedback → tool(refined_param:new_value)`. WITHOUT tool calls: capture communication/workflow pattern.
     *
     * @return self
     */
    public function setAction($action)
    {
        $this->container['action'] = $action;

        return $this;
    }

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

    /**
     * Sets result.
     *
     * @param string $result Learned pattern + effectiveness (1-3 sentences). What worked and WHY it's replicable. Note efficiency: multi-turn refinements, which results were relevant, what made final attempt succeed. Use strict `param:value` syntax for learnings. Format: 'For [context], use [param:value] because [reason]'.
     *
     * @return self
     */
    public function setResult($result)
    {
        $this->container['result'] = $result;

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