mstroink/overheid-io

There is no license information available for the latest version (v1.2.2) of this package.

Simple client for consuming OverheidIo API

v1.2.2 2021-10-05 07:30 UTC

This package is auto-updated.

Last update: 2024-04-19 21:35:40 UTC


README

Build Status Coverage Status Stable php Version

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