diff --git a/src/Model/Api/Example.php b/src/Model/Api/Example.php new file mode 100644 index 00000000..b2c4b25e --- /dev/null +++ b/src/Model/Api/Example.php @@ -0,0 +1,55 @@ + $item->getProduct()->getSku(), + $this->checkoutSession->getQuote()->getItems() ?? [] + ); + + $baseParams = [ + 'idsOnly' => true, + 'userId' => $this->sessionData->getUserId(), + ]; + + $queryString = http_build_query($baseParams, '', '&', PHP_QUERY_RFC3986); + + foreach ($cartSkus as $sku) { + $queryString .= '&blacklist=' . rawurlencode($sku); + } + + $client = $this->clientBuilder + ->withServerUrl($this->communicationConfig->getAddress()) + ->withApiKey($this->authConfig->getApiKey()) + ->withVersion($this->communicationConfig->getVersion()) + ->build(); + + $result = $client->request( + 'GET', + 'rest/v5/predictivebasket/dev_kastner?' . $queryString + ); + + return array_column($result['hits'] ?? [], 'id'); + } +}