goosfraba / kontomatik-sdk
Installs: 2 413
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=8.0
- jms/serializer: ^3.23
- kriswallsmith/buzz: ^1.2
- nyholm/psr7: ^1.8
- psr/log: ^3.0
Requires (Dev)
- monolog/monolog: ^3.3
- phpspec/prophecy: ^1.3
- phpunit/phpunit: ^10.1
README
This repository provides the PHP SDK for Kontomatik.
Installation
Via composer
composer require goosfraba/kontomatik-sdk
Usage
ApiFactory
In order to create the particular API, first you need the ApiFactory
instance.
<?php 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" );
ImportingApi
Get the ImportingApi
instance
<?php use Goosfraba\Kontomatik\Common\Dsn; $importingApi = $apiFactory->importingApi( Dsn::parse( "kontomatik://your-api-key@prod" // or "kontomatik://your-api-key@test" ); );
Supported methods:
- defaultImport
- getCommand
- getData
- removeData
- signOut
LendingApi
Get the ImportingApi
instance
<?php use Goosfraba\Kontomatik\Common\Dsn; $api = $apiFactory->lendingApi( Dsn::parse( "kontomatik://your-api-key@prod" // or "kontomatik://your-api-key@test" ); );
Supported methods:
- getScores
Importing data use case / scoring
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); }
Contribution
Feel free to add unsupported endpoints or fix the bugs found.