dmt-software/insolvency-client

Client for insolvency SOAP service

v1.0.0 2022-07-19 19:07 UTC

This package is auto-updated.

Last update: 2024-04-20 00:41:17 UTC


README

Build Status Scrutinizer Code Quality Code Coverage

This is a client for the Dutch insolvency web service from rechtspraak.nl.

Installation

composer require dmt-software/insolvency-client

Usage

Before using this server please visit rechtspraak.nl and read the technical documentation (Dutch)

use DMT\Insolvency\Client;
use DMT\Insolvency\Config;
use DMT\Insolvency\Exception\Exception;
use DMT\Insolvency\Exception\RequestException;
use DMT\CommandBus\Validator\ValidationException;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
 
$client = new Client(
    new Config([
        'user' => '{{ username }}',
        'password' => '{{ password }}'
    ]),
    /** @var ClientInterface $httpClient */
    $httpClient,
    /** @var RequestFactoryInterface $requestFactory */
    $requestFactory,
);

try {
    $publicatieLijst = $client->searchUndertaking(
       '{{ company name }}',
       '{{ kvk-number }}' // chamber of commerce number
    );

    foreach ($publicatieLijst->publicaties as $publicatie) {
        if (!in_array($publicatie->publicatieKenmerk, (array)$cachedPublications)) {
            $insolvente = $publicatie->insolvente; // lazy loads insolvency 
        }
    }
} catch (RequestException $exception) {
    // user input errors
    $message = $exception->getMessage();
    if ($exception->getPrevious() instanceof ValidationException) {
        $message = (string) $exception->getPrevious()->getViolations();
    }
    echo $message;
} catch (Exception $exception) {
    // server error
}