PHP code example of dmt-software / insolvency-client

1. Go to this page and download the library: Download dmt-software/insolvency-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dmt-software / insolvency-client example snippets


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
}