jeffrey-kroonen/bol-retailer-api-php

A PHP Client to interact with the Bol.com Retailer API

v3.0.1 2023-06-22 17:18 UTC

This package is auto-updated.

Last update: 2024-04-21 16:42:04 UTC


README

PHPUnit GitHub issues GitHub forks GitHub stars GitHub

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request