mstroink / overheid-io
Simple client for consuming OverheidIo API
Installs: 1 586
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
- psr/http-message: ^1.0
Requires (Dev)
- guzzlehttp/guzzle: ^7.3
- phpunit/phpunit: ^8.5
- symfony/var-dumper: ^5.2
Suggests
- guzzlehttp/guzzle: ^7.3
README
Simple PHP wrapper for Overheid.io
This package provides a simple client for consuming the OverheidIo Api.
The API documentation can be found on: https://overheid.io/documentatie. You can get an api-key here https://overheid.io/register
Installing OverheidIo
The recommended way to install Overheid-Io is through Composer.
composer require mstroink/overheid-io
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
Usage
use MStroink\OverheidIo\OverheidIoFactory; $overheid = new OverheidIoFactory::create($apiKey);
Or use your own (authenticated) client. An adapter is required to be an implementation of \MStroink\OverheidIo\Http\HttpClientInterface
use MStroink\OverheidIo\OverheidIo; $overheid = new OverheidIo($client);
Rdw API
// Get car info by licence plate try { $response = $overheid->rdw()->get('76-GP-LH'); } catch(\MStroink\OverheidIo\Exception\NotFoundException $e) { var_dump($e->getMessage()); var_dump($e->getCode()); var_dump($e->getPrevious()); } // Search $rdw = $overheid->rdw(); $response = $rdw ->fields(['merk', 'voertuigsoort', 'kenteken', 'eerste_kleur']) ->query('*laren') ->queryFields(['merk']) ->search();
Bag API
// Get bag info by bag id try { $response = $overheid->bag()->get('3015ba-nieuwe-binnenweg-10-a'); } catch(\MStroink\OverheidIo\Exception\NotFoundException $e) { } // Search $bag = $overheid->bag(); $response = $bag ->filters(['postcode' => '3015BA']) ->search();
Kvk API
// Get company info by kvk id try { $response = $overheid->kvk()->get('hoofdvestiging-57842019-0000-van-der-lei-techniek-bv'); } catch(\MStroink\OverheidIo\Exception\NotFoundException $e) { } // Search $response = $overheid->kvk() ->filters(['dossiernummer' => '52921506']) ->search(); // Suggest $response = $overheid->kvk() ->fields(['handelsnaam']) ->limit(10) ->suggest('Valken');
Filtering (All APIs)
$rdw = $overheid->rdw(); // Number of items returned in the response $rdw->limit(100); // Specify the page of results to return $rdw->page(1); // Control whether results are returned in ascending or descending order $rdw->order('asc'); $rdw->order('desc'); // To limit the fields fetched, you can use the fields() method $rdw->fields(['voertuigsoort', 'kenteken', 'merk', 'eerstekleur']); //Filter results by value $rdw->filters(['merk' => 'dikke-bmw']); // Query for car brand ending with laren $rdw->query('*laren'); // Apply this query on the merk field $rdw->queryFields(['merk']); // Execute $rdw->search();
Run tests
vendor/bin/phpunit