/** * Make an asynchronous call to the API * * @param string $operationId The name of your operation as described in the API Schema * @param array $params An array of request parameters * * @return Promise */ public function callAsync($operationId, array $params = []) { if (!$this->client instanceof HttpAsyncClient) { throw new \RuntimeException(sprintf('"%s" does not support async request', get_class($this->client))); } $requestDefinition = $this->schema->getRequestDefinition($operationId); $request = $this->createRequestFromDefinition($requestDefinition, $params); $promise = $this->client->sendAsyncRequest($request); return $promise->then(function (ResponseInterface $response) use($request, $requestDefinition) { return $this->getDataFromResponse($response, $requestDefinition->getResponseDefinition($response->getStatusCode()), $request); }); }