Created
January 29, 2018 17:44
-
-
Save Vitexus/61ba48d06e3d3abce49236a005a04b3c to your computer and use it in GitHub Desktop.
How to Fix Cutted Banking Labels in FlexiBee using https://packagist.org/packages/mhujer/fio-api-php and https://packagist.org/packages/spoje.net/flexipeehp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('EASE_LOGGER', 'console|syslog'); | |
define('EASE_APPNAME', 'FioCaptions'); | |
require_once 'config.php'; //SetUp FlexiBee and Fio constatnts | |
$banker = new \FlexiPeeHP\Banka(); | |
$downloader = new \FioApi\Downloader(constant('FIO_RO_TOKEN')); | |
try { | |
$transactionList = $downloader->downloadSince(new \DateTime('-1 day')); | |
foreach ($transactionList->getTransactions() as $transaction) { | |
$id = $transaction->getId(); | |
$message = $transaction->getUserMessage(); | |
if (strlen($message > 20)) { | |
$banker->setFilter(['vypisCisDokl' => '00'.$id]); | |
$banker->insertToFlexiBee(['id' => 'ext:fio:'.$id, 'popis' => $message]); | |
$banker->addStatusMessage(sprintf(_('Updating the Banking Label %s to %s'), | |
$id,$message), | |
($banker->lastResponseCode == 201) ? 'success' : 'error' ); | |
} | |
} | |
} catch (\GuzzleHttp\Exception\BadResponseException $e) { | |
if ($e->getCode() == 409) { | |
$banker->addStatusMessage($e->getCode().': '._('You can use one token for API call every 30 seconds'), | |
'error'); | |
} | |
if ($e->getCode() == 500) { | |
$banker->addStatusMessage($e->getCode().': '._('Server returned 500 Internal Error (probably invalid token?)', | |
'error')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment