From 490c817fc11cb316b01c894def100b75a23c4e47 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 25 Apr 2018 16:01:51 +0200 Subject: [PATCH] Some fixes for #1378 --- app/Import/Routine/BunqRoutine.php | 3 ++- app/Services/Bunq/Request/InstallationTokenRequest.php | 10 +++++++++- resources/lang/en_US/firefly.php | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Import/Routine/BunqRoutine.php b/app/Import/Routine/BunqRoutine.php index 18098a214c..b522f4e4bf 100644 --- a/app/Import/Routine/BunqRoutine.php +++ b/app/Import/Routine/BunqRoutine.php @@ -798,6 +798,7 @@ class BunqRoutine implements RoutineInterface $mapping = $config['accounts-mapped']; $token = new SessionToken($config['session_token']); $count = 0; + $all = []; if (0 === $user->getId()) { $user = new UserCompany($config['user_company']); Log::debug(sprintf('Will try to get transactions for company #%d', $user->getId())); @@ -826,7 +827,7 @@ class BunqRoutine implements RoutineInterface 'import_id' => $importId, 'payments' => $payments, ]; - $count += count($payments); + $count += \count($payments); } Log::debug(sprintf('Total number of payments: %d', $count)); $this->addStep(); diff --git a/app/Services/Bunq/Request/InstallationTokenRequest.php b/app/Services/Bunq/Request/InstallationTokenRequest.php index b612a9aed2..d22614654a 100644 --- a/app/Services/Bunq/Request/InstallationTokenRequest.php +++ b/app/Services/Bunq/Request/InstallationTokenRequest.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace FireflyIII\Services\Bunq\Request; +use FireflyIII\Exceptions\FireflyException; use FireflyIII\Services\Bunq\Id\InstallationId; use FireflyIII\Services\Bunq\Object\ServerPublicKey; use FireflyIII\Services\Bunq\Token\InstallationToken; @@ -96,12 +97,19 @@ class InstallationTokenRequest extends BunqRequest * @param array $response * * @return InstallationId + * @throws FireflyException */ private function extractInstallationId(array $response): InstallationId { $installationId = new InstallationId; $data = $this->getKeyFromResponse('Id', $response); - $installationId->setId((int)$data['id']); + + if (!isset($data['id'])) { + Log::error('No installation token in bunq response.', $response); + throw new FireflyException('There is no installation token in the bunq response. Sorry, I cannot continue.'); + } + + $installationId->setId($data['id']); return $installationId; } diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index 7e83a1ac11..1493ce7863 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -583,6 +583,7 @@ return [ 'converted_to_Deposit' => 'The transaction has been converted to a deposit', 'converted_to_Transfer' => 'The transaction has been converted to a transfer', 'invalid_convert_selection' => 'The account you have selected is already used in this transaction or does not exist.', + 'source_or_dest_invalid' => 'Cannot find the correct transaction details. Conversion is not possible.', // create new stuff: 'create_new_withdrawal' => 'Create new withdrawal',