3 declare(strict_types=1);
20 use GuzzleHttp\ClientInterface;
21 use GuzzleHttp\Exception\ClientException;
22 use GuzzleHttp\Exception\RequestException;
23 use GuzzleHttp\Exception\ServerException;
24 use GuzzleHttp\Promise\PromiseInterface;
26 use Psr\Http\Message\ResponseInterface;
39 public function __construct(
string $projectKey, $body =
null, array $headers = [], ClientInterface $client =
null)
41 $uri = str_replace([
'{projectKey}'], [$projectKey],
'{projectKey}/import-containers');
42 parent::__construct($client,
'GET', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body);
50 public function mapFromResponse(?ResponseInterface $response,
string $resultType =
null)
52 if (is_null($response)) {
55 if (is_null($resultType)) {
56 switch ($response->getStatusCode()) {
58 $resultType = ImportContainerPagedResponseModel::class;
62 $resultType = JsonObjectModel::class;
77 public function execute(array $options = [],
string $resultType =
null)
80 $response = $this->
send($options);
81 }
catch (ServerException $e) {
82 $response = $e->getResponse();
85 }
catch (ClientException $e) {
86 $response = $e->getResponse();
100 public function executeAsync(array $options = [],
string $resultType =
null)
103 function (ResponseInterface $response) use ($resultType) {
106 function (RequestException $e) use ($resultType) {
107 $response = $e->getResponse();
108 if ($e instanceof ServerException) {
111 if ($e instanceof ClientException) {