endeavour/groeigids-api-client
The Groeigids API Client is a PHP library designed to interact with the Elkander Groeigids API, making it easy to fetch and manage articles and themes. Swagger documentation of the API can be found here.
To install the Groeigids API Client, use Composer:
composer require endeavour/groeigids-api-client
To run integration tests, a .env file should be created in the root of the project with the following content:
GROEIGIDS_API_KEY=your-api-key-here
To use the Groeigids API Client, create an instance of the GroeigidsApiClient class:
use Endeavour\GroeigidsApiClient\Infrastructure\HttpClient\GroeigidsClient;
$client = new GroeigidsClient(
ClientInterface,
RequestFactoryInterface,
new ResponseDataBuilder(),
new ResponseValidator(new Opis\Validator()),
getenv('GROEIGIDS_API_KEY')
);
Now fetching articles and themes is as simple as calling the fetchArticles and fetchThemeArticles methods:
$articles = $client->fetchArticles();
$themes = $client->fetchThemeArticles();
The fetchArticles and fetchThemeArticles methods accept an optional array of query parameters:
$articles = $client->fetchArticles(page: 1, size: 10);
$themes = $client->fetchThemeArticles(page: 2, size: 50);
The fetchArticles and fetchThemeArticles methods also accept an optional TypedArray object containing sorting parameters:
$sortParameters = new TypedArray(SortParameter::class, [
new SortParameter('title', 'asc'),
new SortParameter('order', 'desc')
]);
$articles = $client->fetchArticles(sort: $sortParameters);
Other functions are available to fetch articles by ID, by breadcrumb or those modified after a certain date:
$articleById = $client->fetchArticle(1);
$articleByBreadcrumb = $client->fetchArticleByBreadcrumb('article-breadcrumb');
$articlesAfterDate = $client->fetchModfifiedArticlesAfterDate(new DateTime('2020-01-01'))
To run the unit tests, use PHPUnit (make sure a .env file is present in the root of the project):
make up
make test
Contributions are welcome!
This project is licensed under the MIT License.
How can I help you explore Laravel packages today?