| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace Nexus\Mcp\Core\Schema\Request; |
| 15: | |
| 16: | use Nexus\Assert\Assert; |
| 17: | use Nexus\Mcp\Core\Schema\JsonRpc\JsonRpcRequest; |
| 18: | use Nexus\Mcp\Core\Schema\RequestId; |
| 19: | use Nexus\Mcp\Core\Schema\RequestParams\UnsubscribeRequestParams; |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | final readonly class UnsubscribeRequest extends JsonRpcRequest implements ClientRequest |
| 32: | { |
| 33: | public function __construct(RequestId $id, UnsubscribeRequestParams $params) |
| 34: | { |
| 35: | parent::__construct($id, $params); |
| 36: | } |
| 37: | |
| 38: | #[\Override] |
| 39: | public static function getMethod(): string |
| 40: | { |
| 41: | return 'resources/unsubscribe'; |
| 42: | } |
| 43: | |
| 44: | #[\Override] |
| 45: | public static function fromArray(array $data): static |
| 46: | { |
| 47: | Assert::that($data)->hasOffset('id', 'missing the required "id" key.'); |
| 48: | $id = $data['id']; |
| 49: | Assert::that($id)->isArrayKey('"id" must be an int or string, {type} given.'); |
| 50: | |
| 51: | Assert::that($data)->hasOffset('params', 'missing the required "params" key.'); |
| 52: | Assert::that($data['params']) |
| 53: | ->isArray('"params" must be an object, {type} given.') |
| 54: | ->isMap('"params" must be a string-keyed object.') |
| 55: | ; |
| 56: | |
| 57: | return new self( |
| 58: | new RequestId($id), |
| 59: | UnsubscribeRequestParams::fromArray($data['params']), |
| 60: | ); |
| 61: | } |
| 62: | } |
| 63: | |