Skip to content

Commit

Permalink
Merge pull request #27 from frrrht/main
Browse files Browse the repository at this point in the history
Update Bol.com API to v6
  • Loading branch information
casperbakker committed Sep 9, 2022
2 parents 308fb9e + 2edef09 commit dbe6e63
Show file tree
Hide file tree
Showing 180 changed files with 1,169 additions and 432 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Main pipeline
on: [push, pull_request]
jobs:
Tests:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0']
php-versions: ['7.4', '8.0', '8.1']
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Bol.com Retailer API client for PHP
This is an open source PHP client for the [Bol.com Retailer API](https://api.bol.com/retailer/public/Retailer-API/v5/releasenotes.html) version 5.
This is an open source PHP client for the [Bol.com Retailer API](https://api.bol.com/retailer/public/Retailer-API/v6/releasenotes.html) version 6.

## Installation
This project can easily be installed through Composer:

```
composer require picqer/bol-retailer-php-client "^5"
composer require picqer/bol-retailer-php-client "^6"
```

## Usage
Create an instance of the client and authenticate
```php
$client = new \Picqer\BolRetailerV5\Client();
$client = new \Picqer\BolRetailerV6\Client();
$client->authenticate('your-client-id', 'your-client-secret');
```

Expand All @@ -25,7 +25,7 @@ foreach ($reducedOrders as $reducedOrder) {
```

## Exceptions
Methods on the Client may throw Exceptions. All Exceptions have the parent class `Picqer\BolRetailerV5\Exception\Exception`:
Methods on the Client may throw Exceptions. All Exceptions have the parent class `Picqer\BolRetailerV6\Exception\Exception`:
- `ConnectException` is thrown when a problem occurred in the connection (e.g. API server is down or a network issue). You may retry later.
- `ServerException` (extends `ConnectException`) is thrown when a problem occurred on the Server (e.g. 500 Internal Server Error). You may retry later.
- `ResponseException` is thrown when the received response could not be handled (e.g. not of proper format or unexpected type). Retrying will not help, investigation is needed.
Expand All @@ -50,7 +50,7 @@ The specifications define types for each request and response (if it needs to se

To generate the Client, the following composer script may be used:
```
# Generates Picqer\BolRetailerV5\Client
# Generates Picqer\BolRetailerV6\Client
composer run-script generate-client
```

Expand All @@ -59,7 +59,7 @@ The class names for models are equal to the keys of the array 'definitions' in t

To generate the Models, the following composer script may be used:
```
# Generates all Picqer\BolRetailerV5\Model\* models
# Generates all Picqer\BolRetailerV6\Model\* models
composer run-script generate-models
```

Expand Down
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,28 @@
"guzzlehttp/guzzle": "^6.3|^7.0"
},
"require-dev": {
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "^7|^8",
"phpspec/prophecy": "^1.15",
"phpstan/phpstan": "^1.8",
"phpunit/phpunit": "^7|^8|^9",
"squizlabs/php_codesniffer": "^3.0",
"vimeo/psalm": "^3.5"
"vimeo/psalm": "^4.27"
},
"autoload": {
"psr-4": {
"Picqer\\BolRetailerV5\\": "src"
"Picqer\\BolRetailerV6\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Picqer\\BolRetailerV5\\Tests\\": "tests"
"Picqer\\BolRetailerV6\\Tests\\": "tests"
}
},
"scripts": {
"test": "phpunit",
"check-style": "phpcs src tests",
"fix-style": "phpcbf src tests",
"generate-client": "Picqer\\BolRetailerV5\\OpenApi\\ClientGenerator::run",
"generate-models": "Picqer\\BolRetailerV5\\OpenApi\\ModelGenerator::run"
"generate-client": "Picqer\\BolRetailerV6\\OpenApi\\ClientGenerator::run",
"generate-models": "Picqer\\BolRetailerV6\\OpenApi\\ModelGenerator::run"
},
"extra": {
"branch-alias": {
Expand Down
Binary file added composer.phar
Binary file not shown.
22 changes: 11 additions & 11 deletions src/BaseClient.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<?php

namespace Picqer\BolRetailerV5;
namespace Picqer\BolRetailerV6;

use GuzzleHttp\Client as HttpClient;
use GuzzleHttp\Exception\BadResponseException;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Exception\ConnectException as GuzzleConnectException;
use Picqer\BolRetailerV5\Exception\RateLimitException;
use Picqer\BolRetailerV5\Exception\ServerException;
use Picqer\BolRetailerV5\Model\AbstractModel;
use Picqer\BolRetailerV5\Exception\AuthenticationException;
use Picqer\BolRetailerV5\Exception\ConnectException;
use Picqer\BolRetailerV5\Exception\Exception;
use Picqer\BolRetailerV5\Exception\ResponseException;
use Picqer\BolRetailerV5\Exception\UnauthorizedException;
use Picqer\BolRetailerV5\OpenApi\ModelCreator;
use Picqer\BolRetailerV6\Exception\RateLimitException;
use Picqer\BolRetailerV6\Exception\ServerException;
use Picqer\BolRetailerV6\Model\AbstractModel;
use Picqer\BolRetailerV6\Exception\AuthenticationException;
use Picqer\BolRetailerV6\Exception\ConnectException;
use Picqer\BolRetailerV6\Exception\Exception;
use Picqer\BolRetailerV6\Exception\ResponseException;
use Picqer\BolRetailerV6\Exception\UnauthorizedException;
use Picqer\BolRetailerV6\OpenApi\ModelCreator;
use Psr\Http\Message\ResponseInterface;

class BaseClient
{
protected const API_TOKEN_URI = 'https://login.bol.com/token';
protected const API_ENDPOINT = 'https://api.bol.com/retailer/';
protected const API_DEMO_ENDPOINT = 'https://api.bol.com/retailer-demo/';
protected const API_CONTENT_TYPE_JSON = 'application/vnd.retailer.v5+json';
protected const API_CONTENT_TYPE_JSON = 'application/vnd.retailer.v6+json';

/**
* @var bool Whether request will be sent to the demo endpoint.
Expand Down
Loading

0 comments on commit dbe6e63

Please sign in to comment.