Skip to content

Commit 85cffab

Browse files
committed
default client configuration update
statementor update
1 parent d4e5bd9 commit 85cffab

File tree

5 files changed

+20
-37
lines changed

5 files changed

+20
-37
lines changed

.openapi-generator/templates/ApiClient.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class ApiClient extends \GuzzleHttp\Client
5757
}
5858

5959
if (array_key_exists('token', $config) === false) {
60-
$this->token = \Ease\Shared::cfg('CSAS_API_TOKEN');
60+
$this->token = \Ease\Shared::cfg('CSAS_ACCESS_TOKEN');
6161
} else {
6262
$this->token = $config['token'];
6363
}
@@ -69,7 +69,7 @@ class ApiClient extends \GuzzleHttp\Client
6969
if (array_key_exists('sandbox', $config)) {
7070
$this->sandBoxMode = strtolower((string)$config['sandbox']) == 'true';
7171
} else {
72-
$this->token = strtolower((string)\Ease\Shared::cfg('CSAS_SANDBOX_MODE', 'false')) == 'true';
72+
$this->sandBoxMode = strtolower((string)\Ease\Shared::cfg('CSAS_SANDBOX_MODE', 'false')) == 'true';
7373
}
7474

7575
parent::__construct($config);

.openapi-generator/templates/Statementor.mustache

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,11 @@ class Statementor extends \Ease\Sand
6565
}
6666

6767
/**
68-
* Obtain Statements from RB.
68+
* Obtain Statements from ČSas.
6969
*
70-
* @param string $currencyCode CZK,USD etc
71-
* @param string $statementLine
70+
* @param string $format pdf, xml, xml-data, abo-standard, abo-internal, abo-standard-extended, abo-internal-extended, csv-comma, csv-semicolon, mt940
7271
*/
73-
public function getStatements($currencyCode = 'CZK', $statementLine = 'MAIN'): array
72+
public function getStatements($format = 'pdf'): array
7473
{
7574
$apiInstance = new \SpojeNet\CSas\Accounts\DefaultApi();
7675
$page = 0;
@@ -79,17 +78,9 @@ class Statementor extends \Ease\Sand
7978
8079
try {
8180
do {
82-
$requestBody = new Model\GetStatementsRequest([
83-
'accountNumber' => $this->accountNumber,
84-
'page' => ++$page,
85-
'size' => 60,
86-
'currency' => $currencyCode,
87-
'statementLine' => $statementLine,
88-
'dateFrom' => $this->since->format(self::$dateFormat),
89-
'dateTo' => $this->until->format(self::$dateFormat)]);
90-
91-
$result = $apiInstance->getAccountStatements($requestBody, $page);
9281
82+
$result = $apiInstance->getAccountStatements($this->getAccountNumber(), $this->getSince()->format('Y-m-d'), $this->getUntil()->format('Y-m-d'),$format);
83+
9384
if (empty($result)) {
9485
$this->addStatusMessage(sprintf(_('No transactions from %s to %s'), $this->since->format(self::$dateFormat), $this->until->format(self::$dateFormat)));
9586
$result['lastPage'] = true;

Examples/statements.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
[pageNumber] => 0
5959
[pageCount] => 1
6060
[pageSize] => 7
61-
[nextPage] =>
61+
[nextPage] =>
6262
[accountStatements] => Array
6363
(
6464
[0] => SpojeNet\CSas\Model\GetAccountStatements200ResponseAccountStatementsInner Object
@@ -164,4 +164,4 @@
164164
)
165165
166166
)
167-
*/
167+
*/

lib/ApiClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __construct(array $config = [])
6464
}
6565

6666
if (\array_key_exists('token', $config) === false) {
67-
$this->token = \Ease\Shared::cfg('CSAS_API_TOKEN');
67+
$this->token = \Ease\Shared::cfg('CSAS_ACCESS_TOKEN');
6868
} else {
6969
$this->token = $config['token'];
7070
}
@@ -76,7 +76,7 @@ public function __construct(array $config = [])
7676
if (\array_key_exists('sandbox', $config)) {
7777
$this->sandBoxMode = strtolower((string) $config['sandbox']) === 'true';
7878
} else {
79-
$this->token = strtolower((string) \Ease\Shared::cfg('CSAS_SANDBOX_MODE', 'false')) === 'true';
79+
$this->sandBoxMode = strtolower((string) \Ease\Shared::cfg('CSAS_SANDBOX_MODE', 'false')) === 'true';
8080
}
8181

8282
parent::__construct($config);

lib/Statementor.php

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class Statementor extends \Ease\Sand
2525
use \Ease\Logger\Logging;
2626
public \DateTime $since;
2727
public \DateTime $until;
28-
private string $scope;
2928

3029
/**
3130
* DateTime Formating eg. 2021-08-01T10:00:00.0Z.
@@ -36,6 +35,7 @@ class Statementor extends \Ease\Sand
3635
* DateTime Formating eg. 2021-08-01T10:00:00.0Z.
3736
*/
3837
public static string $dateFormat = 'Y-m-d';
38+
private string $scope;
3939
private string $accountNumber = '';
4040

4141
public function __construct(string $accountNumber = '', string $scope = '')
@@ -65,12 +65,11 @@ public function setAccountNumber($accountNumber)
6565
}
6666

6767
/**
68-
* Obtain Statements from RB.
68+
* Obtain Statements from ČSas.
6969
*
70-
* @param string $currencyCode CZK,USD etc
71-
* @param string $statementLine
70+
* @param string $format pdf, xml, xml-data, abo-standard, abo-internal, abo-standard-extended, abo-internal-extended, csv-comma, csv-semicolon, mt940
7271
*/
73-
public function getStatements($currencyCode = 'CZK', $statementLine = 'MAIN'): array
72+
public function getStatements($format = 'pdf'): array
7473
{
7574
$apiInstance = new \SpojeNet\CSas\Accounts\DefaultApi();
7675
$page = 0;
@@ -79,16 +78,7 @@ public function getStatements($currencyCode = 'CZK', $statementLine = 'MAIN'): a
7978

8079
try {
8180
do {
82-
$requestBody = new Model\GetStatementsRequest([
83-
'accountNumber' => $this->accountNumber,
84-
'page' => ++$page,
85-
'size' => 60,
86-
'currency' => $currencyCode,
87-
'statementLine' => $statementLine,
88-
'dateFrom' => $this->since->format(self::$dateFormat),
89-
'dateTo' => $this->until->format(self::$dateFormat)]);
90-
91-
$result = $apiInstance->getAccountStatements($requestBody, $page);
81+
$result = $apiInstance->getAccountStatements($this->getAccountNumber(), $this->getSince()->format('Y-m-d'), $this->getUntil()->format('Y-m-d'), $format);
9282

9383
if (empty($result)) {
9484
$this->addStatusMessage(sprintf(_('No transactions from %s to %s'), $this->since->format(self::$dateFormat), $this->until->format(self::$dateFormat)));
@@ -210,7 +200,9 @@ public function setScope($scope): \DatePeriod
210200
$this->since = $this->since->setTime(0, 0);
211201
$this->until = $this->until->setTime(23, 59, 59, 999);
212202
}
203+
213204
$this->scope = $scope;
205+
214206
return $this->getScope();
215207
}
216208

@@ -278,8 +270,8 @@ public function getUntil(): \DateTime
278270
return $this->until;
279271
}
280272

281-
public function getAccountNumber(): string {
273+
public function getAccountNumber(): string
274+
{
282275
return $this->accountNumber;
283276
}
284-
285277
}

0 commit comments

Comments
 (0)