use of com.forgerock.openbanking.common.model.data.FRCustomerInfo in project openbanking-aspsp by OpenBankingToolkit.
the class FakeDataApiController method generateCustomerInfo.
private void generateCustomerInfo(String userId) {
DateTime birthdate = DateTime.now().minusYears(19);
FRCustomerInfoAddress address = FRCustomerInfoAddress.builder().streetAddress(List.of("999", "Letsbe Avenue", "Hull")).country("UK").postalCode("HU11 3FU").addressType(FRAddressTypeCode.RESIDENTIAL).build();
FRCustomerInfo customerInfo = FRCustomerInfo.builder().address(address).birthdate(birthdate).email("fred.blogs@acme.com").phoneNumber("07123123123").familyName("blogs").givenName("fred").partyId("r9082345kjf").initials("F. R.").title("Mr").userID(userId).build();
this.customerInfoRepository.save(customerInfo);
}
use of com.forgerock.openbanking.common.model.data.FRCustomerInfo in project openbanking-aspsp by OpenBankingToolkit.
the class InfoApiController method getCustomerInfo.
@Override
public ResponseEntity<ReadCustomerInfo> getCustomerInfo(String authorization, String xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, String xObPsuUserId) {
log.debug("getCustomerInfo called()");
if (!rsConfiguration.isCustomerInfoEnabled()) {
return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED);
} else {
FRCustomerInfo frCustomerInfo = customerInfoRepository.findByUserID(xObPsuUserId);
if (frCustomerInfo != null) {
//
CustomerInfo customerInfo = FRCustomerInfoConverter.toCustomerInfo(frCustomerInfo);
ReadCustomerInfo readCustomerInfo = new ReadCustomerInfo();
readCustomerInfo.setData(customerInfo);
log.info("getCustomerInfo() returning customerInfo; '{}'", customerInfo);
return ResponseEntity.ok(readCustomerInfo);
} else {
log.info("getCustomerInfo() returning NO_CONTENT as no customerInfo found");
return ResponseEntity.noContent().build();
}
}
}
use of com.forgerock.openbanking.common.model.data.FRCustomerInfo in project openbanking-aspsp by OpenBankingToolkit.
the class DataUpdater method updateCustomerInfo.
void updateCustomerInfo(FRUserData userData) {
FRCustomerInfo existingCustomerInfo = customerInfoRepository.findByUserID(userData.getUserName());
if (existingCustomerInfo != null) {
FRCustomerInfo newCustomerInfo = userData.getCustomerInfo();
if (newCustomerInfo != null) {
if (!newCustomerInfo.getId().equals(existingCustomerInfo.getId())) {
String errorMessage = String.format("The customerInfo ID '%s' in the provided data does not match " + "that in the existing data '%s' for user '%s'", newCustomerInfo.getId(), existingCustomerInfo.getId(), userData.getUserName());
log.info("updateCustomerInfo() - {}", errorMessage);
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, errorMessage);
}
if (newCustomerInfo.getAddress() != null) {
existingCustomerInfo.setAddress(newCustomerInfo.getAddress());
}
if (newCustomerInfo.getPartyId() != null) {
existingCustomerInfo.setPartyId(newCustomerInfo.getPartyId());
}
if (newCustomerInfo.getBirthdate() != null) {
existingCustomerInfo.setBirthdate(newCustomerInfo.getBirthdate());
}
if (newCustomerInfo.getEmail() != null) {
existingCustomerInfo.setEmail(newCustomerInfo.getEmail());
}
if (newCustomerInfo.getFamilyName() != null) {
existingCustomerInfo.setFamilyName(newCustomerInfo.getFamilyName());
}
if (newCustomerInfo.getGivenName() != null) {
existingCustomerInfo.setGivenName(existingCustomerInfo.getGivenName());
}
if (newCustomerInfo.getInitials() != null) {
existingCustomerInfo.setInitials(newCustomerInfo.getInitials());
}
if (newCustomerInfo.getPhoneNumber() != null) {
existingCustomerInfo.setPhoneNumber(newCustomerInfo.getPhoneNumber());
}
if (newCustomerInfo.getTitle() != null) {
existingCustomerInfo.setTitle(newCustomerInfo.getTitle());
}
customerInfoRepository.save(existingCustomerInfo);
}
}
}
use of com.forgerock.openbanking.common.model.data.FRCustomerInfo in project openbanking-aspsp by OpenBankingToolkit.
the class FRCustomerInfoConverter method toCustomerInfo.
public static CustomerInfo toCustomerInfo(FRCustomerInfo frCustomerInfo) {
CustomerInfo customerInfo = new CustomerInfo();
customerInfo.setInitials(frCustomerInfo.getInitials());
customerInfo.setBirthdate(frCustomerInfo.getBirthdate().toLocalDate());
customerInfo.setEmail(frCustomerInfo.getEmail());
customerInfo.setFamilyName(frCustomerInfo.getFamilyName());
customerInfo.setGivenName(frCustomerInfo.getGivenName());
customerInfo.setPartyId(frCustomerInfo.getPartyId());
customerInfo.setTitle(frCustomerInfo.getTitle());
customerInfo.setPhoneNumber(frCustomerInfo.getPhoneNumber());
customerInfo.setAddress(toCustomerInfoAddress(frCustomerInfo.getAddress()));
return customerInfo;
}
use of com.forgerock.openbanking.common.model.data.FRCustomerInfo in project openbanking-aspsp by OpenBankingToolkit.
the class InfoApiControllerIT method shouldReturnNoContentIfNoData_testGetCustomerInfo.
@Test
public void shouldReturnNoContentIfNoData_testGetCustomerInfo() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_AISP);
FRCustomerInfo customerInfo = FRCustomerInfoTestHelper.aValidFRCustomerInfo();
// When
HttpResponse<ReadCustomerInfo> response = Unirest.get("https://rs-store:" + port + "/customer-info/v1.0/info").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.getFinancialId()).header(OBHeaders.AUTHORIZATION, "token").header("x-ob-psu-user-id", customerInfo.getUserID()).asObject(ReadCustomerInfo.class);
// Then
assertThat(response.getStatus()).isEqualTo(HttpStatus.NO_CONTENT.value());
}
Aggregations