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;
50 public function __construct(
string $projectKey, $body =
null, array $headers = [], ClientInterface $client =
null)
52 $uri = str_replace([
'{projectKey}'], [$projectKey],
'{projectKey}/product-projections');
53 parent::__construct($client,
'GET', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body);
61 public function mapFromResponse(?ResponseInterface $response,
string $resultType =
null)
63 if (is_null($response)) {
66 if (is_null($resultType)) {
67 switch ($response->getStatusCode()) {
69 $resultType = ProductProjectionPagedQueryResponseModel::class;
73 $resultType = ErrorResponseModel::class;
77 $resultType = ErrorResponseModel::class;
81 $resultType = ErrorResponseModel::class;
85 $resultType = ErrorResponseModel::class;
89 $resultType = ErrorResponseModel::class;
93 $resultType = ErrorResponseModel::class;
97 $resultType = JsonObjectModel::class;
112 public function execute(array $options = [],
string $resultType =
null)
115 $response = $this->
send($options);
116 }
catch (ServerException $e) {
117 $response = $e->getResponse();
120 }
catch (ClientException $e) {
121 $response = $e->getResponse();
135 public function executeAsync(array $options = [],
string $resultType =
null)
138 function (ResponseInterface $response) use ($resultType) {
141 function (RequestException $e) use ($resultType) {
142 $response = $e->getResponse();
143 if ($e instanceof ServerException) {
146 if ($e instanceof ClientException) {
187 return $this->
withQueryParam(
'priceCustomerGroup', $priceCustomerGroup);
205 return $this->
withQueryParam(
'localeProjection', $localeProjection);
214 return $this->
withQueryParam(
'storeProjection', $storeProjection);
277 return $this->
withQueryParam(sprintf(
'var.%s', $varName), $predicateVar);