jeffrey-kroonen / bol-retailer-api-php
A PHP Client to interact with the Bol.com Retailer API
Requires
- guzzlehttp/guzzle: ^7.4
- jane-php/json-schema-runtime: ^7.4
- nesbot/carbon: ^2.67
- phpseclib/phpseclib: ^3.0
- symfony/http-foundation: ^6.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.10
- jane-php/json-schema: ^7.4
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.5
- vimeo/psalm: ^4.26
README
Bol.com Retailer API PHP
A PHP Client to interact with the Bol.com Retailer API v8
About the project
The project is built with php v8.1.4 and is not complete. Only the endpoints I needed for my project are included in this project. Their will be no future releases coming from my side, besides when the Bol.com Retailer API releases a new version or if I have to make use of more endpoints.
Feel free to fork this project and contribute your work to improve the project.
Supported endpoints
- Orders
- Returns
- Subscriptions
- Process status
Getting Started
Installation
The project can be easily be installed through Composer
composer require jeffrey-kroonen/bol-retailer-api-php
Usage
Create a new instance of the Client
$client = new Client( bolClientId: '<client-id>', bolClientSecret: '<client-secret>' );
Authenticate at the Bol.com Retailer API
$client->authenticate();
After you have been authenticated at the Bol.com Retailer API, you can get the auth data, such as client id, client secret and access token. These data can be used in future requests. It's good practice to save the access token in your local database to reuse the next time
$client->getAuth();
Set The access token when instantiating Client
$client = new Client( bolClientId: '<client-id>', bolClientSecret: '<client-secret>', accessToken: '<access-token>' );
Next you can call the endpoint you want to use
$ordersEndpoint = $client->orders();
Then you can call the methods available for that endpoint
$ordersEndpoint->orders(); // Retrieve a Paginate class instance containing orders $ordersEndpoint->orderById(id: '<order-id>'); // Retrieve an order by id
To get the data from the currently authenticated application, you can use the accessor on the Client
$client->getAuth(); // Returns an instance of Auth
You can get as example the Unix timestamp when the authentication will expire
$client->getAuth()->getExpiresIn(); // 1661613446
You will receive the exception UnauthorizedException
when the request is no longer authorized. You can check manually when the authentication will expire
$client->isAuthenticated();
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (git checkout -b feature/AmazingFeature)
- Commit your Changes (git commit -m 'Add some AmazingFeature')
- Push to the Branch (git push origin feature/AmazingFeature)
- Open a Pull Request