<?php

declare(strict_types=1);

namespace Anthropic\Beta\Messages;

use Anthropic\Core\Attributes\Required;
use Anthropic\Core\Concerns\SdkModel;
use Anthropic\Core\Contracts\BaseModel;

/**
 * @phpstan-import-type BetaToolReferenceBlockParamShape from \Anthropic\Beta\Messages\BetaToolReferenceBlockParam
 *
 * @phpstan-type BetaToolSearchToolSearchResultBlockParamShape = array{
 *   toolReferences: list<BetaToolReferenceBlockParam|BetaToolReferenceBlockParamShape>,
 *   type: 'tool_search_tool_search_result',
 * }
 */
final class BetaToolSearchToolSearchResultBlockParam implements BaseModel
{
    /** @use SdkModel<BetaToolSearchToolSearchResultBlockParamShape> */
    use SdkModel;

    /** @var 'tool_search_tool_search_result' $type */
    #[Required]
    public string $type = 'tool_search_tool_search_result';

    /** @var list<BetaToolReferenceBlockParam> $toolReferences */
    #[Required('tool_references', list: BetaToolReferenceBlockParam::class)]
    public array $toolReferences;

    /**
     * `new BetaToolSearchToolSearchResultBlockParam()` is missing required properties by the API.
     *
     * To enforce required parameters use
     * ```
     * BetaToolSearchToolSearchResultBlockParam::with(toolReferences: ...)
     * ```
     *
     * Otherwise ensure the following setters are called
     *
     * ```
     * (new BetaToolSearchToolSearchResultBlockParam)->withToolReferences(...)
     * ```
     */
    public function __construct()
    {
        $this->initialize();
    }

    /**
     * Construct an instance from the required parameters.
     *
     * You must use named parameters to construct any parameters with a default value.
     *
     * @param list<BetaToolReferenceBlockParam|BetaToolReferenceBlockParamShape> $toolReferences
     */
    public static function with(array $toolReferences): self
    {
        $self = new self;

        $self['toolReferences'] = $toolReferences;

        return $self;
    }

    /**
     * @param list<BetaToolReferenceBlockParam|BetaToolReferenceBlockParamShape> $toolReferences
     */
    public function withToolReferences(array $toolReferences): self
    {
        $self = clone $this;
        $self['toolReferences'] = $toolReferences;

        return $self;
    }

    /**
     * @param 'tool_search_tool_search_result' $type
     */
    public function withType(string $type): self
    {
        $self = clone $this;
        $self['type'] = $type;

        return $self;
    }
}
