private Account waitAccountSynced(BankAccount bankAccount, ApiClient apiClient) throws ApiException { Account account = new AccountsApi(apiClient).getAccount(Long.parseLong(bankAccount.getExternalIdMap().get(bankApi()))); while (account.getStatus() == Account.StatusEnum.DOWNLOAD_IN_PROGRESS) { try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } account = new AccountsApi(apiClient).getAccount(Long.parseLong(bankAccount.getExternalIdMap().get(bankApi()))); } return account; }
@Override public void removeBankAccount(String bankingUrl, BankAccount bankAccount, BankApiUser bankApiUser) { ApiClient apiClient = createUserApiClient(); apiClient.setAccessToken(authorizeUser(bankApiUser)); try { new AccountsApi(apiClient).deleteAccount(Long.parseLong(bankAccount.getExternalIdMap().get(bankApi()))); } catch (ApiException e) { throw new RuntimeException(e); } }
private void filterAccounts(BankAccessEntity bankAccess, OnlineBankingService onlineBankingService, List<BankAccount> bankAccounts) { UserData userData = uds.load(); List<BankAccountData> userBankAccounts = userData.bankAccessDataOrException(bankAccess.getId()).getBankAccounts(); // List<BankAccountEntity> userBankAccounts = loadForBankAccess(bankAccess.getId()); //filter out previous created accounts Iterator<BankAccount> accountIterator = bankAccounts.iterator(); while (accountIterator.hasNext()) { BankAccount newAccount = accountIterator.next(); userBankAccounts.stream().filter(bankAccountData -> { String newAccountExternalID = newAccount.getExternalIdMap().get(onlineBankingService.bankApi()); String existingAccountExternalID = bankAccountData.getBankAccount().getExternalIdMap().get(onlineBankingService.bankApi()); return newAccountExternalID.equals(existingAccountExternalID); }).findFirst().ifPresent(bankAccountEntity -> { accountIterator.remove(); }); } //all accounts created in the past if (bankAccounts.size() == 0) { throw new BankAccessAlreadyExistException(bankAccess.getId()); } bankAccess.setBankName(bankAccounts.get(0).getBankName()); }
private void filterAccounts(BankAccessEntity bankAccess, OnlineBankingService onlineBankingService, List<BankAccount> bankAccounts) { UserData userData = uds.load(); List<BankAccountData> userBankAccounts = userData.bankAccessDataOrException(bankAccess.getId()).getBankAccounts(); // List<BankAccountEntity> userBankAccounts = loadForBankAccess(bankAccess.getId()); //filter out previous created accounts Iterator<BankAccount> accountIterator = bankAccounts.iterator(); while (accountIterator.hasNext()) { BankAccount newAccount = accountIterator.next(); userBankAccounts.stream().filter(bankAccountData -> { String newAccountExternalID = newAccount.getExternalIdMap().get(onlineBankingService.bankApi()); String existingAccountExternalID = bankAccountData.getBankAccount().getExternalIdMap().get(onlineBankingService.bankApi()); return newAccountExternalID.equals(existingAccountExternalID); }).findFirst().ifPresent(bankAccountEntity -> { accountIterator.remove(); }); } //all accounts created in the past if (bankAccounts.size() == 0) { throw new BankAccessAlreadyExistException(bankAccess.getId()); } bankAccess.setBankName(bankAccounts.get(0).getBankName()); }
@Override public void removeBankAccount(String bankingUrl, BankAccount bankAccount, BankApiUser bankApiUser) { try { TokenResponse tokenResponse = figoConnection.credentialLogin(bankApiUser.getApiUserId() + MAIL_SUFFIX, bankApiUser.getApiPassword()); FigoSession session = createSession(tokenResponse.getAccessToken()); session.removeAccount(bankAccount.getExternalIdMap().get(bankApi())); } catch (IOException | FigoException e) { throw new RuntimeException(e); } }
null, Collections.singletonList("standingOrders"), Collections.singletonList(bankAccount.getExternalIdMap().get(bankApi())), true, // disable_notifications 0, // if_not_synced_since List<Booking> bookings = session.getTransactions(bankAccount.getExternalIdMap().get(bankApi())) .stream() .map(transaction -> FigoMapping.mapBooking(transaction, bankApi)) session.getStandingOrders(bankAccount.getExternalIdMap().get(bankApi())) .stream() .map(FigoMapping::mapStandingOrder) .bookings(bookings) .standingOrders(standingOrders) .bankAccountBalance(getBalance(session, bankAccount.getExternalIdMap().get(bankApi()))) .build();
BankAccountEntity dbBankAccount = dbBankAccountData.getBankAccount(); if (apiBankAccount.getAccountNumber().equals(dbBankAccount.getAccountNumber())) { dbBankAccount.externalId(onlineBankingService.bankApi(), apiBankAccount.getExternalIdMap().get(onlineBankingService.bankApi())); if (bankAccess.getId().equals(dbBankAccount.getId())) { bankAccess.externalId(onlineBankingService.bankApi(), apiBankAccount.getExternalIdMap().get(onlineBankingService.bankApi()));
BankAccountEntity dbBankAccount = dbBankAccountData.getBankAccount(); if (apiBankAccount.getAccountNumber().equals(dbBankAccount.getAccountNumber())) { dbBankAccount.externalId(onlineBankingService.bankApi(), apiBankAccount.getExternalIdMap().get(onlineBankingService.bankApi())); if (bankAccess.getId().equals(dbBankAccount.getId())) { bankAccess.externalId(onlineBankingService.bankApi(), apiBankAccount.getExternalIdMap().get(onlineBankingService.bankApi()));
apiClient.setAccessToken(authorizeUser(loadBookingsRequest.getBankApiUser())); List<Long> accountIds = Arrays.asList(Long.parseLong(bankAccount.getExternalIdMap().get(bankApi()))); List<String> order = Arrays.asList("id,desc");