44 public function __construct(
string $projectKey, $body =
null, array $headers = [], ?ClientInterface $client =
null)
46 $uri = str_replace([
'{projectKey}'], [self::encodePathParam($projectKey)],
'{projectKey}/mcp-servers');
47 parent::__construct($client,
'GET', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body);
55 public function mapFromResponse(?ResponseInterface $response, ?
string $resultType =
null)
57 if (is_null($response)) {
60 if (is_null($resultType)) {
61 switch ($response->getStatusCode()) {
63 $resultType = McpServerPagedQueryResponseModel::class;
67 $resultType = ErrorResponseModel::class;
71 $resultType = ErrorResponseModel::class;
75 $resultType = ErrorResponseModel::class;
79 $resultType = ErrorResponseModel::class;
83 $resultType = ErrorResponseModel::class;
87 $resultType = ErrorResponseModel::class;
91 $resultType = JsonObjectModel::class;
106 public function execute(array $options = [], ?
string $resultType =
null)
109 $response = $this->
send($options);
110 }
catch (ServerException $e) {
111 $response = $e->getResponse();
112 $e = ExceptionFactory::createServerException($e, $this, $response, $this->
mapFromResponse($response, $resultType));
114 }
catch (ClientException $e) {
115 $response = $e->getResponse();
116 $e = ExceptionFactory::createClientException($e, $this, $response, $this->
mapFromResponse($response, $resultType));
129 public function executeAsync(array $options = [], ?
string $resultType =
null)
132 function (ResponseInterface $response) use ($resultType) {
135 function (RequestException $e) use ($resultType) {
136 $response = $e->getResponse();
137 if ($e instanceof ServerException) {
138 $e = ExceptionFactory::createServerException($e, $this, $response, $this->
mapFromResponse($response, $resultType));
140 if ($e instanceof ClientException) {
141 $e = ExceptionFactory::createClientException($e, $this, $response, $this->
mapFromResponse($response, $resultType));