<?php
namespace boru\ai\Conversation;

class ConversationNote
{
    /** @var string|null */
    protected $id;

    /** @var string */
    protected $kind = 'note';

    /** @var string */
    protected $text = '';

    /** @var float|null */
    protected $confidence;

    /** @var int|null */
    protected $sourceTurnNumber;

    /** @var array */
    protected $metadata = array();

    /** @var string|null */
    protected $createdAt;

    /** @var string|null */
    protected $updatedAt;

    public function id($value = null)
    {
        if ($value !== null) {
            $this->id = (string)$value;
            return $this;
        }
        return $this->id;
    }

    public function kind($value = null)
    {
        if ($value !== null) {
            $this->kind = (string)$value;
            return $this;
        }
        return $this->kind;
    }

    public function text($value = null)
    {
        if ($value !== null) {
            $this->text = (string)$value;
            return $this;
        }
        return $this->text;
    }

    public function confidence($value = null)
    {
        if (func_num_args() > 0) {
            $this->confidence = $value === null ? null : (float)$value;
            return $this;
        }
        return $this->confidence;
    }

    public function sourceTurnNumber($value = null)
    {
        if (func_num_args() > 0) {
            $this->sourceTurnNumber = $value === null ? null : (int)$value;
            return $this;
        }
        return $this->sourceTurnNumber;
    }

    public function metadata($key = null, $value = null)
    {
        if ($key === null) {
            return $this->metadata;
        }
        if (is_array($key)) {
            $this->metadata = $key;
            return $this;
        }
        if (func_num_args() > 1) {
            $this->metadata[$key] = $value;
            return $this;
        }
        return isset($this->metadata[$key]) ? $this->metadata[$key] : null;
    }

    public function createdAt($value = null)
    {
        if ($value !== null) {
            $this->createdAt = (string)$value;
            return $this;
        }
        return $this->createdAt;
    }

    public function updatedAt($value = null)
    {
        if ($value !== null) {
            $this->updatedAt = (string)$value;
            return $this;
        }
        return $this->updatedAt;
    }

    public function toArray()
    {
        return array(
            'id' => $this->id(),
            'kind' => $this->kind(),
            'text' => $this->text(),
            'confidence' => $this->confidence(),
            'source_turn_number' => $this->sourceTurnNumber(),
            'metadata' => $this->metadata(),
            'created_at' => $this->createdAt(),
            'updated_at' => $this->updatedAt(),
        );
    }
}
