Skip to content

Commit

Permalink
feat(STEUN-399): update module for api V8
Browse files Browse the repository at this point in the history
  • Loading branch information
wimvdputten committed Mar 20, 2023
1 parent a5f310a commit 526262e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "bol-com/retailer-api",
"type": "library",
"version": "3.0.1",
"version": "3.0.2",
"authors": [
{
"name": "Reach Digital",
"email": "[email protected]",
"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",
Expand Down
4 changes: 3 additions & 1 deletion src/Client/ClientConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/Handler/ProcessStatus/GetStatusByEntityHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
],
]);

Expand Down
6 changes: 5 additions & 1 deletion src/Handler/ProcessStatus/GetStatusByProcessIdsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
],
]);
}
Expand Down

0 comments on commit 526262e

Please sign in to comment.