PHP code example of firewalker / fio-client

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

    

firewalker / fio-client example snippets


use Firewalker\FioClient\Client\FioClient;
use GuzzleHttp\Client as HttpClient;
use Http\Discovery\Psr17FactoryDiscovery;

$httpClient = new HttpClient(); // any PSR-18 client
$requestFactory = Psr17FactoryDiscovery::findRequestFactory();

$token = 'YOUR_FIO_API_TOKEN';
$fio = new FioClient($token, $httpClient, $requestFactory);

$from = new \DateTimeImmutable('2024-01-01');
$to = new \DateTimeImmutable('2024-01-31');

$raw = $fio->getTransactionsRaw($from, $to); // string
$data = json_decode($raw, true);             // array

use Firewalker\FioClient\Dto\AccountStatementDto;

$dto = $fio->getTransactionsDTO($from, $to); // AccountStatementDto

echo $dto->accountNumber;
echo count($dto->transactions);

$rawLast = $fio->getLastTransactionsRaw();
$dtoLast = $fio->getLastTransactionsDTO();

$rawSince = $fio->getTransactionsSinceIdRaw(12345);
$dtoSince = $fio->getTransactionsSinceIdDTO(12345);

$response = $fio->setLastId(12345); // raw API response

$xml = $fio->getTransactionsRaw($from, $to, FioClient::FORMAT_XML);
$csv = $fio->getTransactionsRaw($from, $to, FioClient::FORMAT_CSV);

$statement = $fio->getTransactionsDTO($from, $to);

foreach ($statement->transactions as $tx) {
    echo sprintf(
        "%s: %s %.2f (%s)\n",
        $tx->date,
        $tx->counterpartyName,
        $tx->amount,
        $tx->message ?? ''
    );
}