Skip to content

Commit

Permalink
fix: fixing client types
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj committed Jan 9, 2024
1 parent 1b3962e commit 3bc3ae2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 2 additions & 0 deletions backend/src/main/java/ca/bc/gov/app/ApplicationConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,7 @@ left join nrfc.province_code pc on (pc.province_code = sl.province_code and pc.c
public static final String REFRESH_TOKEN = "refreshToken";
public static final String ID_TOKEN = "idToken";
public static final String ACCESS_TOKEN = "accessToken";
public static final List<String> AVAILABLE_CLIENT_TYPES = List.of("A", "I", "S", "SP", "RSP",
"USP", "BC", "GP");
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ca.bc.gov.app.service.client;

import ca.bc.gov.app.ApplicationConstant;
import ca.bc.gov.app.dto.bcregistry.BcRegistryDocumentDto;
import ca.bc.gov.app.dto.bcregistry.BcRegistryFacetSearchResultEntryDto;
import ca.bc.gov.app.dto.bcregistry.BcRegistryPartyDto;
Expand Down Expand Up @@ -206,6 +207,13 @@ public Mono<ClientDetailsDto> getClientDetails(
)
.map(BcRegistryDocumentDto.class::cast)

.flatMap(client ->{
if(ApplicationConstant.AVAILABLE_CLIENT_TYPES.contains(client.business().legalType())){
return Mono.just(client);
}
return Mono.error(new UnsuportedClientTypeException(client.business().legalType()));
})

//if document type is SP and party contains only one entry that is not a person, fail
.filter(document ->
!("SP".equalsIgnoreCase(document.business().legalType())
Expand Down Expand Up @@ -237,14 +245,7 @@ public Flux<ClientLookUpDto> findByClientNameOrIncorporation(String value) {
entry.status(),
entry.legalType()
)
)
.flatMap(client ->{
if(List.of("A", "I", "S", "SP","RSP","USP").contains(client.legalType())){
return Mono.just(client);
}
return Mono.error(new UnsuportedClientTypeException(client.legalType()));
})
.doOnError(System.out::println);
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private void validateBusinessInformation(
validateBirthdate(businessInformation.birthdate(), errors);
}

if (!List.of("A", "I", "S", "USP", "RSP","SP").contains(clientType)) {
if (!ApplicationConstant.AVAILABLE_CLIENT_TYPES.contains(clientType)) {
errors.rejectValue("businessType",
String.format("%s %s is not supported at the moment", "Business type",clientType));
}
Expand Down

0 comments on commit 3bc3ae2

Please sign in to comment.