| 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\GetPromptRequestParams; |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | final readonly class GetPromptRequest extends JsonRpcRequest implements ClientRequest |
| 31: | { |
| 32: | public function __construct(RequestId $id, GetPromptRequestParams $params) |
| 33: | { |
| 34: | parent::__construct($id, $params); |
| 35: | } |
| 36: | |
| 37: | #[\Override] |
| 38: | public static function getMethod(): string |
| 39: | { |
| 40: | return 'prompts/get'; |
| 41: | } |
| 42: | |
| 43: | #[\Override] |
| 44: | public static function fromArray(array $data): static |
| 45: | { |
| 46: | Assert::that($data)->hasOffset('id', 'missing the required "id" key.'); |
| 47: | $id = $data['id']; |
| 48: | Assert::that($id)->isArrayKey('"id" must be an int or string, {type} given.'); |
| 49: | |
| 50: | Assert::that($data)->hasOffset('params', 'missing the required "params" key.'); |
| 51: | Assert::that($data['params']) |
| 52: | ->isArray('"params" must be an object, {type} given.') |
| 53: | ->isMap('"params" must be a string-keyed object.') |
| 54: | ; |
| 55: | |
| 56: | return new self(new RequestId($id), GetPromptRequestParams::fromArray($data['params'])); |
| 57: | } |
| 58: | } |
| 59: | |