use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class MoneyServiceTest method shouldCreateTransaction.
@Test
public void shouldCreateTransaction() throws CurrencyConverterException {
// Given
FRBalance balance = defaultBalance(DEBIT_ACCOUNT, "20");
given(balanceStoreService.getBalance(DEBIT_ACCOUNT, OBBalanceType1Code.INTERIMAVAILABLE)).willReturn(Optional.of(balance));
CreateTransaction<FRPaymentSetup> createTransaction = mock(CreateTransaction.class);
FRAccount account = defaultAccount(DEBIT_ACCOUNT);
FRPaymentSetup payment = new FRPaymentSetup();
FRTransaction transaction = JMockData.mock(FRTransaction.class);
FRAmount amount = defaultAmount();
given(createTransaction.createTransaction(account, payment, FRCreditDebitIndicator.DEBIT, balance, amount)).willReturn(transaction);
// When
moneyService.moveMoney(account, amount, FRCreditDebitIndicator.DEBIT, payment, createTransaction);
// Then
verify(transactionStoreService).create(transaction);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class AccountStoreServiceImpl method get.
@Override
public List<FRAccount> get(String userID) {
// This is necessary as auth server always uses lowercase user id
String lowercaseUserId = userID.toLowerCase();
log.debug("Searching for accounts with user ID: {}", lowercaseUserId);
ParameterizedTypeReference<List<FRAccount>> ptr = new ParameterizedTypeReference<List<FRAccount>>() {
};
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(rsStoreRoot + "/api/accounts/search/findByUserId");
builder.queryParam("userId", lowercaseUserId);
URI uri = builder.build().encode().toUri();
ResponseEntity<List<FRAccount>> entity = restTemplate.exchange(uri, HttpMethod.GET, null, ptr);
return entity.getBody();
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class AccountsApiController method getAccount.
public ResponseEntity<OBReadAccount2> getAccount(@ApiParam(value = "A unique identifier used to identify the account resource.", required = true) @PathVariable("AccountId") String accountId, @ApiParam(value = "The unique id of the ASPSP to which the request is issued. The unique id will be issued by OB.", required = true) @RequestHeader(value = "x-fapi-financial-id", required = true) String xFapiFinancialId, @ApiParam(value = "An Authorisation Token as per https://tools.ietf.org/html/rfc6750", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, @ApiParam(value = "The time when the PSU last logged in with the TPP. All dates in the HTTP headers are represented as RFC 7231 Full Dates. An example is below: Sun, 10 Sep 2017 19:43:31 UTC") @RequestHeader(value = "x-fapi-customer-last-logged-time", required = false) @DateTimeFormat(pattern = HTTP_DATE_FORMAT) DateTime xFapiCustomerLastLoggedTime, @ApiParam(value = "The PSU's IP address if the PSU is currently logged in with the TPP.") @RequestHeader(value = "x-fapi-customer-ip-address", required = false) String xFapiCustomerIpAddress, @ApiParam(value = "An RFC4122 UID used as a correlation id.") @RequestHeader(value = "x-fapi-interaction-id", required = false) String xFapiInteractionId, @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent, @RequestHeader(value = "x-ob-permissions", required = true) List<OBExternalPermissions1Code> permissions, @RequestHeader(value = "x-ob-url", required = true) String httpUrl) throws OBErrorResponseException {
LOGGER.info("Read account {} with permission {}", accountId, permissions);
FRAccount response = frAccountRepository.byAccountId(accountId, toFRExternalPermissionsCodeList(permissions));
List<OBAccount2> obAccount2s = singletonList(toOBAccount2(response.getAccount()));
return ResponseEntity.ok(new OBReadAccount2().data(new OBReadAccount2Data().account(obAccount2s)).links(PaginationUtil.generateLinksOnePager(httpUrl)).meta(PaginationUtil.generateMetaData(1)));
}
Aggregations