Skip to content

Commit 55d1e69

Browse files
author
Vítězslav Dvořák
committed
Adds account mapping utilities and updates dependencies
Introduces utility methods to map IBANs to account IDs and retrieve accounts by IBAN for better account management. Updates PHPStan and PHP CS Fixer dependencies to newer versions. Enhances Makefile with a token refresh command. Removes redundant code in various classes for improved readability.
1 parent 5a596c5 commit 55d1e69

File tree

10 files changed

+140
-10
lines changed

10 files changed

+140
-10
lines changed

.openapi-generator/templates/Statementor.mustache

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,4 +289,58 @@ class Statementor extends \Ease\Sand
289289
{
290290
return $this->accountUuid;
291291
}
292+
293+
/**
294+
* IBAN=>UUID listing of accounts
295+
*
296+
* @param Accounts\DefaultApi $apiInstance
297+
*
298+
* @return array<string,string>
299+
*/
300+
public static function getAccountIDs(Accounts\DefaultApi $apiInstance): array
301+
{
302+
$accounts = [];
303+
$accountsRaw = $apiInstance->getAccounts()->getAccounts();
304+
305+
if (isset($accountsRaw) && \is_array($accountsRaw)) {
306+
foreach ($accountsRaw as $account) {
307+
$accounts[$account->getIdentification()->getIban()] = $account->getId();
308+
}
309+
}
310+
311+
return $accounts;
312+
}
313+
314+
// Helper function to map IBAN to account ID
315+
public static function getAccountIdByIban(Accounts\DefaultApi $apiInstance, string $iban): ?string
316+
{
317+
$accountsRaw = $apiInstance->getAccounts()->getAccounts();
318+
$accId = null;
319+
if (isset($accountsRaw) && \is_array($accountsRaw)) {
320+
foreach ($accountsRaw as $account) {
321+
if ($account->getIdentification()->getIban() === $iban) {
322+
$accId = $account->getId();
323+
break;
324+
}
325+
}
326+
}
327+
328+
return $accId;
329+
}
330+
331+
public static function getAccountByIban(Accounts\DefaultApi $apiInstance, string $iban): ?\SpojeNet\CSas\Model\Account
332+
{
333+
$accountsRaw = $apiInstance->getAccounts()->getAccounts();
334+
$account = null;
335+
if (isset($accountsRaw) && \is_array($accountsRaw)) {
336+
foreach ($accountsRaw as $account) {
337+
if ($account->getIdentification()->getIban() === $iban) {
338+
break;
339+
}
340+
}
341+
}
342+
343+
return $account;
344+
}
345+
292346
}

.openapi-generator/templates/composer.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"friendsofphp/php-cs-fixer": "^3.61",
4343
"ergebnis/composer-normalize": "^2.43",
4444
"ergebnis/php-cs-fixer-config": "^6.34",
45-
"phpstan/phpstan-phpunit": "2.0.x-dev"
45+
"phpstan/phpstan-phpunit": "^2.0"
4646
},
4747
"autoload": {
4848
"psr-4": {

.vscode/settings.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"workbench.colorCustomizations": {
3+
"activityBar.background": "#c6a409",
4+
"titleBar.activeBackground": "#c6a409",
5+
"titleBar.activeForeground": "#FFFFFF",
6+
"titleBar.inactiveBackground": "#c6a409",
7+
"titleBar.inactiveForeground": "#FFFFFF",
8+
"titleBar.border": "#c6a409",
9+
"activityBar.foreground": "#FFFFFF",
10+
"statusBar.background": "#c6a409",
11+
"statusBar.foreground": "#FFFFFF",
12+
"statusBar.debuggingBackground": "#c6a409",
13+
"statusBar.debuggingForeground": "#FFFFFF",
14+
"tab.activeBorder": "#c6a409",
15+
"iLoveWorkSpaceColors": true,
16+
"iLoveWorkSpaceRandom": false,
17+
"activityBar.inactiveForeground": "#a7a989",
18+
"activityBar.activeBorder": "#c8adf4",
19+
"activityBar.activeBackground": "#66930C",
20+
"activityBar.border": "#66930C",
21+
"statusBar.border": "#66930C"
22+
}
23+
}

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
help: ## Displays this list of targets with descriptions
44
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
55

6+
.PHONY: token
7+
token: ## Refresh token
8+
csas-access-token -t`csas-access-token -l | head -n 1 | awk '{print $$2}'` -o.env
9+
610
.PHONY: static-code-analysis
711
static-code-analysis: vendor ## Runs a static code analysis with phpstan/phpstan
812
vendor/bin/phpstan analyse --configuration=phpstan-default.neon.dist --memory-limit=-1

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
"require-dev": {
3535
"phpunit/phpunit": "*",
3636
"phpstan/phpstan": "*",
37-
"friendsofphp/php-cs-fixer": "^3.61",
37+
"friendsofphp/php-cs-fixer": "^3.82",
3838
"ergebnis/composer-normalize": "^2.43",
3939
"ergebnis/php-cs-fixer-config": "^6.34",
40-
"phpstan/phpstan-phpunit": "2.0.x-dev"
40+
"phpstan/phpstan-phpunit": "^2.0"
4141
},
4242
"autoload": {
4343
"psr-4": {

debian/changelog

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
php-spojenet-csas-accountsapi (0.7.1) UNRELEASED; urgency=medium
1+
php-spojenet-csas-accountsapi (0.7.1) noble; urgency=medium
22

3+
[ vitex ]
34
* beta version
45

5-
-- vitex <info@vitexsoftware.cz> Tue, 18 Mar 2025 18:07:33 +0100
6+
-- Vitex <vitezslav.dvorak@spojenet.cz> Fri, 11 Jul 2025 21:32:07 +0200
67

78
php-spojenet-csas-accountsapi (0.7.0) noble; urgency=medium
89

lib/Accounts/DefaultApi.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,8 @@ class DefaultApi
7676
'application/json',
7777
],
7878
];
79-
8079
protected ClientInterface $client;
81-
8280
protected Configuration $config;
83-
8481
protected HeaderSelector $headerSelector;
8582

8683
/**

lib/ApiClient.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class ApiClient extends \GuzzleHttp\Client
3737
* ClientID obtained from Developer Portal - when you registered your app with us.
3838
*/
3939
protected string $apiKey;
40-
4140
protected string $token;
4241

4342
/**

lib/Configuration.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ class Configuration
105105
* Debug file location (log to STDOUT by default).
106106
*/
107107
protected string $tempFolderPath;
108-
109108
private static Configuration $defaultConfiguration;
110109

111110
/**

lib/Statementor.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,57 @@ public function getAccountUuid(): string
287287
{
288288
return $this->accountUuid;
289289
}
290+
291+
/**
292+
* IBAN=>UUID listing of accounts
293+
*
294+
* @param Accounts\DefaultApi $apiInstance
295+
*
296+
* @return array<string,string>
297+
*/
298+
public static function getAccountIDs(Accounts\DefaultApi $apiInstance): array
299+
{
300+
$accounts = [];
301+
$accountsRaw = $apiInstance->getAccounts()->getAccounts();
302+
303+
if (isset($accountsRaw) && \is_array($accountsRaw)) {
304+
foreach ($accountsRaw as $account) {
305+
$accounts[$account->getIdentification()->getIban()] = $account->getId();
306+
}
307+
}
308+
309+
return $accounts;
310+
}
311+
312+
// Helper function to map IBAN to account ID
313+
public static function getAccountIdByIban(Accounts\DefaultApi $apiInstance, string $iban): ?string
314+
{
315+
$accountsRaw = $apiInstance->getAccounts()->getAccounts();
316+
$accId = null;
317+
if (isset($accountsRaw) && \is_array($accountsRaw)) {
318+
foreach ($accountsRaw as $account) {
319+
if ($account->getIdentification()->getIban() === $iban) {
320+
$accId = $account->getId();
321+
break;
322+
}
323+
}
324+
}
325+
326+
return $accId;
327+
}
328+
329+
public static function getAccountByIban(Accounts\DefaultApi $apiInstance, string $iban): ?\SpojeNet\CSas\Model\Account
330+
{
331+
$accountsRaw = $apiInstance->getAccounts()->getAccounts();
332+
$account = null;
333+
if (isset($accountsRaw) && \is_array($accountsRaw)) {
334+
foreach ($accountsRaw as $account) {
335+
if ($account->getIdentification()->getIban() === $iban) {
336+
break;
337+
}
338+
}
339+
}
340+
341+
return $account;
342+
}
290343
}

0 commit comments

Comments
 (0)