PHP code example of goosfraba / kontomatik-sdk

1. Go to this page and download the library: Download goosfraba/kontomatik-sdk 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/ */

    

goosfraba / kontomatik-sdk example snippets



use Goosfraba\Kontomatik\Common\ApiFactory;

$apiFactory = new ApiFactory(
    $logger = null // optionally, provide the logger to catch the raw responses from the API, it needs to work with level "Debug"
);



use Goosfraba\Kontomatik\Common\Dsn;

$importingApi = $apiFactory->importingApi(
    Dsn::parse(
        "kontomatik://your-api-key@prod" // or "kontomatik://your-api-key@test"
    );
);



use Goosfraba\Kontomatik\Common\Dsn;

$api = $apiFactory->lendingApi(
    Dsn::parse(
        "kontomatik://your-api-key@prod" // or "kontomatik://your-api-key@test"
    );
);

use Goosfraba\Kontomatik\Importing\Session;

$commandReply = $importingApi->defaultImport(
    new Session("known-id", "known-signature"),
    date_create_immutable("now - 6 months") // import data for last 6 months
);

$commandId = $commandReply->getCommand()->getId();
$ownerExternalId = $commandReply->getOwnerExternalId();

do {
    /** @var \Goosfraba\Kontomatik\Importing\CommandReply $commandReply */
    $commandReply = $importingApi->getCommand($commandId));
} while(!$commandReply->getCommand()->isFinished() && sleep(5) === 0);

if ($commandReply->isSuccessful()) {
    $ownerScoreReply = $lendingApi->getScore($ownerExternalId);
}