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;
46 public function __construct(
string $projectKey, $body =
null, array $headers = [], ClientInterface $client =
null)
48 $uri = str_replace([
'{projectKey}'], [$projectKey],
'{projectKey}/orders');
49 parent::__construct($client,
'GET', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body);
57 public function mapFromResponse(?ResponseInterface $response,
string $resultType =
null)
59 if (is_null($response)) {
62 if (is_null($resultType)) {
63 switch ($response->getStatusCode()) {
65 $resultType = OrderPagedQueryResponseModel::class;
69 $resultType = ErrorResponseModel::class;
73 $resultType = ErrorResponseModel::class;
77 $resultType = ErrorResponseModel::class;
81 $resultType = ErrorResponseModel::class;
85 $resultType = ErrorResponseModel::class;
89 $resultType = ErrorResponseModel::class;
93 $resultType = JsonObjectModel::class;
108 public function execute(array $options = [],
string $resultType =
null)
111 $response = $this->
send($options);
112 }
catch (ServerException $e) {
113 $response = $e->getResponse();
116 }
catch (ClientException $e) {
117 $response = $e->getResponse();
131 public function executeAsync(array $options = [],
string $resultType =
null)
134 function (ResponseInterface $response) use ($resultType) {
137 function (RequestException $e) use ($resultType) {
138 $response = $e->getResponse();
139 if ($e instanceof ServerException) {
142 if ($e instanceof ClientException) {
210 return $this->
withQueryParam(sprintf(
'var.%s', $varName), $predicateVar);