3 declare(strict_types=1);
22 use GuzzleHttp\ClientInterface;
23 use GuzzleHttp\Exception\ClientException;
24 use GuzzleHttp\Exception\RequestException;
25 use GuzzleHttp\Exception\ServerException;
26 use GuzzleHttp\Promise\PromiseInterface;
28 use Psr\Http\Message\ResponseInterface;
45 public function __construct(
string $projectKey, $body =
null, array $headers = [], ClientInterface $client =
null)
47 $uri = str_replace([
'{projectKey}'], [$projectKey],
'{projectKey}/extensions');
48 parent::__construct($client,
'GET', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body);
56 public function mapFromResponse(?ResponseInterface $response,
string $resultType =
null)
58 if (is_null($response)) {
61 if (is_null($resultType)) {
62 switch ($response->getStatusCode()) {
64 $resultType = ExtensionPagedQueryResponseModel::class;
68 $resultType = ErrorResponseModel::class;
72 $resultType = ErrorResponseModel::class;
76 $resultType = ErrorResponseModel::class;
80 $resultType = ErrorResponseModel::class;
84 $resultType = ErrorResponseModel::class;
88 $resultType = ErrorResponseModel::class;
92 $resultType = JsonObjectModel::class;
107 public function execute(array $options = [],
string $resultType =
null)
110 $response = $this->
send($options);
111 }
catch (ServerException $e) {
112 $response = $e->getResponse();
115 }
catch (ClientException $e) {
116 $response = $e->getResponse();
130 public function executeAsync(array $options = [],
string $resultType =
null)
133 function (ResponseInterface $response) use ($resultType) {
136 function (RequestException $e) use ($resultType) {
137 $response = $e->getResponse();
138 if ($e instanceof ServerException) {
141 if ($e instanceof ClientException) {
200 return $this->
withQueryParam(sprintf(
'var.%s', $varName), $predicateVar);