Search in sources :

Example 1 with FRCustomerInfo

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);
}
Also used : FRCustomerInfo(com.forgerock.openbanking.common.model.data.FRCustomerInfo) FRCustomerInfoAddress(com.forgerock.openbanking.common.model.data.FRCustomerInfoAddress) DateTime(org.joda.time.DateTime)

Example 2 with FRCustomerInfo

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();
        }
    }
}
Also used : ReadCustomerInfo(uk.org.openbanking.datamodel.customerinfo.ReadCustomerInfo) ResponseEntity(org.springframework.http.ResponseEntity) FRCustomerInfo(com.forgerock.openbanking.common.model.data.FRCustomerInfo) ReadCustomerInfo(uk.org.openbanking.datamodel.customerinfo.ReadCustomerInfo) FRCustomerInfo(com.forgerock.openbanking.common.model.data.FRCustomerInfo) CustomerInfo(uk.org.openbanking.datamodel.customerinfo.CustomerInfo)

Example 3 with FRCustomerInfo

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);
        }
    }
}
Also used : FRCustomerInfo(com.forgerock.openbanking.common.model.data.FRCustomerInfo) ResponseStatusException(org.springframework.web.server.ResponseStatusException)

Example 4 with FRCustomerInfo

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;
}
Also used : FRCustomerInfo(com.forgerock.openbanking.common.model.data.FRCustomerInfo) CustomerInfo(uk.org.openbanking.datamodel.customerinfo.CustomerInfo)

Example 5 with FRCustomerInfo

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());
}
Also used : ReadCustomerInfo(uk.org.openbanking.datamodel.customerinfo.ReadCustomerInfo) FRCustomerInfo(com.forgerock.openbanking.common.model.data.FRCustomerInfo) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

FRCustomerInfo (com.forgerock.openbanking.common.model.data.FRCustomerInfo)12 Test (org.junit.Test)5 FRUserData (com.forgerock.openbanking.common.model.data.FRUserData)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 ReadCustomerInfo (uk.org.openbanking.datamodel.customerinfo.ReadCustomerInfo)3 FRAccountData (com.forgerock.openbanking.common.model.data.FRAccountData)2 FRAccountAccessConsent (com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountAccessConsent)2 SpringSecForTest (com.forgerock.openbanking.integration.test.support.SpringSecForTest)2 CustomerInfo (uk.org.openbanking.datamodel.customerinfo.CustomerInfo)2 FRCustomerInfoAddress (com.forgerock.openbanking.common.model.data.FRCustomerInfoAddress)1 FRFinancialAccount (com.forgerock.openbanking.common.model.openbanking.domain.account.FRFinancialAccount)1 FRPartyData (com.forgerock.openbanking.common.model.openbanking.domain.account.FRPartyData)1 AccountRequest (com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountRequest)1 CustomerInfoConsentDetails (com.forgerock.openbanking.common.model.rcs.consentdetails.CustomerInfoConsentDetails)1 FRPartyConverter.toFRPartyData (com.forgerock.openbanking.common.services.openbanking.converter.account.FRPartyConverter.toFRPartyData)1 OBErrorException (com.forgerock.openbanking.exceptions.OBErrorException)1 Tpp (com.forgerock.openbanking.model.Tpp)1 DateTime (org.joda.time.DateTime)1 ResponseEntity (org.springframework.http.ResponseEntity)1 ResponseStatusException (org.springframework.web.server.ResponseStatusException)1