use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest in project openbanking-aspsp by OpenBankingToolkit.
the class AccountRequestsApiController method deleteAccountRequest.
@Override
public ResponseEntity deleteAccountRequest(@ApiParam(value = "Unique identification as assigned by the ASPSP to uniquely identify the account request resource.", required = true) @PathVariable("AccountRequestId") String accountRequestId, @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 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 = "Indicates the user-agent that the PSU is using.") @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent) throws OBErrorResponseException {
Optional<FRAccountRequest> accountRequest = frAccountRequestRepository.findByAccountRequestId(accountRequestId);
if (!accountRequest.isPresent()) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Account request '" + accountRequestId + "' not found");
}
LOGGER.debug("Account request revoked with id {}", accountRequestId);
FRAccountRequest frAccountRequest = accountRequest.get();
frAccountRequest.getAccountRequest().getData().setStatus(FRExternalRequestStatusCode.REVOKED);
consentMetricService.sendConsentActivity(new ConsentStatusEntry(frAccountRequest.getAccountRequest().getData().getAccountRequestId(), frAccountRequest.getAccountRequest().getData().getStatus().name()));
frAccountRequestRepository.save(frAccountRequest);
LOGGER.debug("Account request revoked");
return ResponseEntity.ok("Account request '" + accountRequestId + "' deleted");
}
Aggregations