From 526262e10c13bf70705e84e56d06a8532c9c2aed Mon Sep 17 00:00:00 2001 From: Wim Date: Mon, 20 Mar 2023 16:16:01 +0100 Subject: [PATCH] feat(STEUN-399): update module for api V8 --- README.md | 7 ++++--- composer.json | 4 ++-- src/Client/ClientConfig.php | 4 +++- src/Handler/ProcessStatus/GetStatusByEntityHandler.php | 5 ++++- src/Handler/ProcessStatus/GetStatusByProcessIdsHandler.php | 6 +++++- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 19adf4a..2afd682 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,13 @@ # BolCom_Api -Bol.com API documentation can be found -[here](https://api.bol.com/retailer/public/redoc/v6). +Bol.com retailer API documentation can be found +[here](https://api.bol.com/retailer/public/redoc/v8/retailer.html) +and the shared api [here](https://api.bol.com/retailer/public/redoc/v8/shared.html). ## Features -- Uses bol.com API v6. +- Uses bol.com API v8. - Strict type checking. - Support multiple bol.com accounts. diff --git a/composer.json b/composer.json index 0364159..576ec7c 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "bol-com/retailer-api", "type": "library", - "version": "3.0.1", + "version": "3.0.2", "authors": [ { "name": "Reach Digital", @@ -9,7 +9,7 @@ "homepage": "https://www.reachdigital.nl/" } ], - "description": "Package to talk to the bol.com v6 API.", + "description": "Package to talk to the bol.com v8 API.", "license": "Apache-2.0", "require": { "guzzlehttp/guzzle": "~6.0", diff --git a/src/Client/ClientConfig.php b/src/Client/ClientConfig.php index ff1292f..b895eb4 100644 --- a/src/Client/ClientConfig.php +++ b/src/Client/ClientConfig.php @@ -10,8 +10,10 @@ class ClientConfig implements ClientConfigInterface { const API_URL = 'https://api.bol.com/retailer/'; + CONST SHARED_API_URL = 'https://api.bol.com/shared/'; const TEST_API_URL = 'https://api.bol.com/retailer-demo/'; - const ACCEPT_HEADER = 'application/vnd.retailer.v6+json'; + CONST SHARED_TEST_API_URL = 'https://api.bol.com/shared-demo/'; + const ACCEPT_HEADER = 'application/vnd.retailer.v8+json'; /** @var string $clientId */ private $clientId; diff --git a/src/Handler/ProcessStatus/GetStatusByEntityHandler.php b/src/Handler/ProcessStatus/GetStatusByEntityHandler.php index 4c7e44b..376cc8c 100644 --- a/src/Handler/ProcessStatus/GetStatusByEntityHandler.php +++ b/src/Handler/ProcessStatus/GetStatusByEntityHandler.php @@ -8,6 +8,7 @@ namespace BolCom\RetailerApi\Handler\ProcessStatus; use BolCom\RetailerApi\Client; +use BolCom\RetailerApi\Client\ClientConfig; use BolCom\RetailerApi\Model\ProcessStatus\ProcessStatuses; use BolCom\RetailerApi\Model\ProcessStatus\Query\GetStatusByEntity; use BolCom\RetailerApi\Model\ProcessStatus\QueryHandler\GetStatusByEntityHandlerInterface; @@ -30,14 +31,16 @@ public function __construct(Client $client) */ public function __invoke(GetStatusByEntity $getStatusByEntity) { + $sharedBaseUri = $this->client->getConfig('base_uri')->__toString() === ClientConfig::TEST_API_URL ? ClientConfig::SHARED_TEST_API_URL : ClientConfig::SHARED_API_URL; $response = $this->client->get('process-status', [ + 'base_uri' => $sharedBaseUri, 'query' => [ 'entity-id' => $getStatusByEntity->entityId()->toString(), 'event-type' => $getStatusByEntity->eventType()->toString(), 'page' => $getStatusByEntity->page(), ], 'headers' => [ - 'Accept' => \BolCom\RetailerApi\Client\ClientConfig::ACCEPT_HEADER, + 'Accept' => ClientConfig::ACCEPT_HEADER, ], ]); diff --git a/src/Handler/ProcessStatus/GetStatusByProcessIdsHandler.php b/src/Handler/ProcessStatus/GetStatusByProcessIdsHandler.php index ed53492..667e5d9 100644 --- a/src/Handler/ProcessStatus/GetStatusByProcessIdsHandler.php +++ b/src/Handler/ProcessStatus/GetStatusByProcessIdsHandler.php @@ -8,6 +8,7 @@ namespace BolCom\RetailerApi\Handler\ProcessStatus; use BolCom\RetailerApi\Client; +use BolCom\RetailerApi\Client\ClientConfig; use BolCom\RetailerApi\Model\ProcessStatus\ProcessStatuses; use BolCom\RetailerApi\Model\ProcessStatus\Query\GetStatusByProcessIds; use BolCom\RetailerApi\Model\ProcessStatus\QueryHandler\GetStatusByProcessIdsHandlerInterface; @@ -31,11 +32,14 @@ public function __construct(Client $client) */ public function __invoke(GetStatusByProcessIds $getStatusByProcessIds): ProcessStatuses { + $promises = []; + $sharedBaseUri = $this->client->getConfig('base_uri')->__toString() === ClientConfig::TEST_API_URL ? ClientConfig::SHARED_TEST_API_URL : ClientConfig::SHARED_API_URL; foreach ($getStatusByProcessIds->ids() as $id) { $promises[] = $this->client->getAsync("process-status/{$id}", [ + 'base_uri' => $sharedBaseUri, 'headers' => [ - 'Accept' => \BolCom\RetailerApi\Client\ClientConfig::ACCEPT_HEADER, + 'Accept' => ClientConfig::ACCEPT_HEADER, ], ]); }