finTS = new \Fhp\FinTs( $config['fints_url'], $config['fints_port'], $config['fints_bank_code'], $config['fints_username'], Crypt::decrypt($config['fints_password']) ); } public function checkConnection() { try { $this->finTS->getSEPAAccounts(); return true; } catch (\Exception $exception) { return $exception->getMessage(); } } /** * @return SEPAAccount[] * @throws FireflyException */ public function getAccounts() { try { return $this->finTS->getSEPAAccounts(); } catch (\Exception $exception) { throw new FireflyException($exception->getMessage()); } } /** * @param string $accountNumber * @return SEPAAccount * @throws FireflyException */ public function getAccount(string $accountNumber) { $accounts = $this->getAccounts(); $filteredAccounts = array_filter($accounts, function (SEPAAccount $account) use ($accountNumber) { return $account->getAccountNumber() == $accountNumber; }); if (count($filteredAccounts) != 1) { throw new FireflyException("Cannot find account with number " . $accountNumber); } return $filteredAccounts[0]; } /** * @param SEPAAccount $account * @param \DateTime $from * @param \DateTIme $to * @return \Fhp\Model\StatementOfAccount\StatementOfAccount|null * @throws FireflyException */ public function getStatementOfAccount(SEPAAccount $account, \DateTime $from, \DateTIme $to) { try { return $this->finTS->getStatementOfAccount($account, $from, $to); } catch (\Exception $exception) { throw new FireflyException($exception->getMessage()); } } }