3 declare(strict_types=1);
18 use GuzzleHttp\ClientInterface;
19 use GuzzleHttp\Exception\ClientException;
20 use GuzzleHttp\Exception\RequestException;
21 use GuzzleHttp\Exception\ServerException;
22 use GuzzleHttp\Promise\PromiseInterface;
24 use Psr\Http\Message\ResponseInterface;
37 public function __construct(
string $projectKey, $body =
null, array $headers = [], ClientInterface $client =
null)
39 $uri = str_replace([
'{projectKey}'], [$projectKey],
'{projectKey}');
40 parent::__construct($client,
'HEAD', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body);
48 public function mapFromResponse(?ResponseInterface $response,
string $resultType =
null)
50 if (is_null($response)) {
53 if (is_null($resultType)) {
54 switch ($response->getStatusCode()) {
56 $resultType = JsonObjectModel::class;
71 public function execute(array $options = [],
string $resultType =
null)
74 $response = $this->
send($options);
75 }
catch (ServerException $e) {
76 $response = $e->getResponse();
79 }
catch (ClientException $e) {
80 $response = $e->getResponse();
94 public function executeAsync(array $options = [],
string $resultType =
null)
97 function (ResponseInterface $response) use ($resultType) {
100 function (RequestException $e) use ($resultType) {
101 $response = $e->getResponse();
102 if ($e instanceof ServerException) {
105 if ($e instanceof ClientException) {