<?php

/*
 * This file is part of the official PHP MCP SDK.
 *
 * A collaboration between Symfony and the PHP Foundation.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Matomo\Dependencies\McpServer\Mcp\Schema\Request;

use Matomo\Dependencies\McpServer\Mcp\Exception\InvalidArgumentException;
use Matomo\Dependencies\McpServer\Mcp\Schema\JsonRpc\Request;
/**
 * Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a
 * previous resources/subscribe request.
 *
 * @author Kyrian Obikwelu <koshnawaza@gmail.com>
 */
final class ResourceUnsubscribeRequest extends Request
{
    /**
     * @param non-empty-string $uri the URI of the resource to unsubscribe from
     */
    public function __construct(public readonly string $uri)
    {
    }
    public static function getMethod() : string
    {
        return 'resources/unsubscribe';
    }
    protected static function fromParams(?array $params) : static
    {
        if (!isset($params['uri']) || !\is_string($params['uri']) || empty($params['uri'])) {
            throw new InvalidArgumentException('Missing or invalid "uri" parameter for resources/unsubscribe.');
        }
        return new self($params['uri']);
    }
    /**
     * @return array{uri: non-empty-string}
     */
    protected function getParams() : array
    {
        return ['uri' => $this->uri];
    }
}
