Skip to content

Commit 413b399

Browse files
committed
Added more functionalities
1 parent 09af10d commit 413b399

16 files changed

+280
-113
lines changed

example/index.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use SpojeNet\KbAccountsApi\Entity\TransactionSelection;
1111
use SpojeNet\KbAccountsApi\Exception\KbClientException;
1212
use SpojeNet\KbAccountsApi\KbClient;
13+
use SpojeNet\KbAccountsApi\Utils\Random;
1314
use Tracy\Debugger;
1415

1516
require_once __DIR__ . '/../vendor/autoload.php';
@@ -155,7 +156,7 @@ function registration(): void
155156
client: new Client(
156157
name: sanitizeInput('clientName'),
157158
type: 'web',
158-
encryptionKey: $kbClient::createEncryptionKey($kbClient->config->sandbox),
159+
encryptionKey: Random::encryptionKey($kbClient->config->sandbox),
159160
),
160161
);
161162

@@ -247,10 +248,10 @@ function application(): void
247248
HTML;
248249
$accountIdForTransactions = null;
249250
foreach ($accounts as $account) {
250-
$accountIdForTransactions ??= $account->id;
251-
$accountId = short($account->id);
251+
$accountIdForTransactions ??= $account->accountId;
252+
$accountId = short($account->accountId);
252253
echo <<<HTML
253-
<tr><td>{$accountId}</td><td>{$account->iban}</td><td>{$account->currencyCode}</td></tr>
254+
<tr><td>{$accountId}</td><td>{$account->iban}</td><td>{$account->currency}</td></tr>
254255
HTML;
255256
}
256257
echo '</table>';
@@ -259,11 +260,11 @@ function application(): void
259260
$transactions = $kbClient->transactions($app->tokens->access->token, new TransactionSelection($accountIdForTransactions));
260261
echo <<<HTML
261262
<table>
262-
<tr><th>Items:</th><td>{$transactions->totalItems}</td></tr>
263+
<tr><th>Items:</th><td>{$transactions->numberOfElements}</td></tr>
263264
<tr><th>Pages:</th><td>{$transactions->totalPages}</td></tr>
264265
</table>
265266
HTML;
266-
array_walk($transactions->items, fn($item) => writeOutput($item));
267+
array_map(fn($item) => writeOutput($item), $transactions->content);
267268
}
268269

269270
function delete(): void {

src/Config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace SpojeNet\KbAccountsApi;
44

55
use SplFileInfo;
6+
use SpojeNet\KbAccountsApi\Utils\DotEnv;
67

78
class Config
89
{

src/Entity/Account.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
class Account
66
{
77
public function __construct(
8-
public readonly string $id,
8+
public readonly string $accountId,
99
public readonly string $iban,
10-
public readonly string $currencyCode,
10+
public readonly string $currency,
1111
) {
1212
}
1313
}

src/Entity/Amount.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace SpojeNet\KbAccountsApi\Entity;
4+
5+
class Amount
6+
{
7+
public function __construct(
8+
public readonly float $value,
9+
public readonly string $currency
10+
) {
11+
}
12+
}

src/Entity/BankTransactionCode.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace SpojeNet\KbAccountsApi\Entity;
4+
5+
class BankTransactionCode
6+
{
7+
public function __construct(
8+
public readonly string $code,
9+
public readonly string $issuer,
10+
) {
11+
}
12+
}

src/Entity/PageSlice.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace SpojeNet\KbAccountsApi\Entity;
4+
5+
/**
6+
* @template T
7+
*/
8+
abstract class PageSlice
9+
{
10+
/**
11+
* @param T[] $content
12+
*/
13+
public function __construct(
14+
public readonly array $content,
15+
public readonly int $totalPages,
16+
public readonly int $pageNumber,
17+
public readonly int $pageSize,
18+
public readonly bool $numberOfElements,
19+
public readonly int $first,
20+
public readonly bool $last,
21+
public readonly bool $empty,
22+
) {
23+
}
24+
}

src/Entity/Transaction.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,26 @@
22

33
namespace SpojeNet\KbAccountsApi\Entity;
44

5-
use DateTimeImmutable;
6-
75
class Transaction
86
{
97
public function __construct(
10-
public readonly DateTimeImmutable $lastUpdated,
11-
public readonly ?DateTimeImmutable $bookingDate,
8+
public readonly \DateTimeImmutable $lastUpdated,
9+
public readonly TransactionAccountType $accountType,
10+
public readonly ?string $entryReference,
11+
public readonly string $iban,
1212
public readonly CreditDebit $creditDebitIndicator,
1313
public readonly TransactionType $transactionType,
14+
public readonly BankTransactionCode $bankTransactionCode,
15+
public readonly Amount $amount,
16+
public readonly ?\DateTimeImmutable $bookingDate,
17+
public readonly ?\DateTimeImmutable $valueDate,
18+
public readonly ?Amount $instructed,
19+
public readonly ?bool $reversalIndicator,
1420
public readonly ?TransactionStatus $status,
15-
public readonly string $counterPartyIban,
16-
public readonly string $counterPartyName,
17-
public readonly float $amountValue,
18-
public readonly string $currency,
19-
public readonly string $variable,
20-
public readonly string $constant,
21-
public readonly string $specific,
22-
public readonly string $note,
23-
public readonly string $additionalTransactionInformation,
21+
public readonly ?TransactionCounterParty $counterParty,
22+
public readonly ?TransactionReferences $references,
23+
public readonly ?string $additionalTransactionInformation,
24+
public readonly ?TransactionCardDetails $cardTransactionDetails,
2425
) {
2526
}
2627
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace SpojeNet\KbAccountsApi\Entity;
4+
5+
enum TransactionAccountType: string
6+
{
7+
case KBAccounts = 'KB';
8+
case AggregateAccounts = 'AG';
9+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace SpojeNet\KbAccountsApi\Entity;
4+
5+
class TransactionCardDetails
6+
{
7+
public function __construct(
8+
public readonly ?\DateTimeImmutable $holdExpirationDate,
9+
) {
10+
}
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace SpojeNet\KbAccountsApi\Entity;
4+
5+
class TransactionCounterParty
6+
{
7+
public function __construct(
8+
public readonly ?string $iban,
9+
public readonly ?string $name,
10+
public readonly ?string $accountNo,
11+
public readonly ?string $bankBic,
12+
public readonly ?string $bankCode,
13+
public readonly ?string $bankName,
14+
) {
15+
}
16+
}

0 commit comments

Comments
 (0)