Skip to content

Commit eb2d9df

Browse files
committed
Be ready for plaintext response #24
1 parent 40f8f20 commit eb2d9df

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/AbraFlexi/Banka.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,35 @@ class Banka extends RW {
3636
*/
3737
public $evidence = 'banka';
3838

39+
/**
40+
* Bank pull mode of Json processing
41+
* @var boolean
42+
*/
43+
private $pullMode = false;
44+
3945
/**
4046
* Stáhne bankovní výpisy ( trvá delší dobu )
4147
*
4248
* @return boolean
4349
*/
4450
public function stahnoutVypisyOnline() {
45-
try {
46-
$this->performRequest('nacteni-vypisu-online.json', 'PUT', 'txt');
47-
} catch (Exception $exc) {
48-
$this->addStatusMessage('Json response is still plaintext', 'debug');
49-
}
51+
$this->pullMode = true;
52+
$this->performRequest('nacteni-vypisu-online.json', 'PUT', 'txt');
53+
$this->pullMode = false;
5054
return $this->lastResponseCode == 200;
5155
}
5256

57+
/**
58+
* Convert AbraFlexi Response JSON to Array
59+
*
60+
* @param string $rawJson
61+
*
62+
* @return array
63+
*/
64+
public function rawJsonToArray($rawJson) {
65+
return $this->pullMode ? explode($rawJson, "\n") : parent::rawJsonToArray($rawJson);
66+
}
67+
5368
/**
5469
* Start invoice automatic matching process ( it takes longer time )
5570
* Spustí proces automatického párování plateb. ( trvá delší dobu )

0 commit comments

Comments
 (0)