Skip to content

Commit

Permalink
SELC-4720 feature: added originId mapping using ivassCode (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
empassaro authored Apr 17, 2024
1 parent 5a0b79b commit 2acf188
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class OnboardingData {
private InstitutionUpdate institutionUpdate;
private InstitutionType institutionType;
private String origin;
private String originId;
private String pricingPlan;
private String businessName;
private boolean existsInRegistry;
Expand Down
22 changes: 16 additions & 6 deletions connector/rest/docs/openapi/api-selfcare-onboarding-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
"title" : "onboarding-ms API",
"version" : "1.0.0"
},
"servers" : [ {
"url" : "http://localhost:8080",
"description" : "Auto generated value"
}, {
"url" : "http://0.0.0.0:8080",
"description" : "Auto generated value"
} ],
"paths" : {
"/v1/onboarding" : {
"get" : {
Expand Down Expand Up @@ -759,11 +766,9 @@
}
},
"BillingRequest" : {
"required" : [ "vatNumber" ],
"type" : "object",
"properties" : {
"vatNumber" : {
"minLength" : 1,
"type" : "string"
},
"recipientCode" : {
Expand Down Expand Up @@ -814,14 +819,13 @@
}
},
"InstitutionBaseRequest" : {
"required" : [ "institutionType", "taxCode", "digitalAddress" ],
"required" : [ "institutionType", "digitalAddress" ],
"type" : "object",
"properties" : {
"institutionType" : {
"$ref" : "#/components/schemas/InstitutionType"
},
"taxCode" : {
"minLength" : 1,
"type" : "string"
},
"subunitCode" : {
Expand All @@ -833,6 +837,9 @@
"origin" : {
"$ref" : "#/components/schemas/Origin"
},
"originId" : {
"type" : "string"
},
"city" : {
"type" : "string"
},
Expand Down Expand Up @@ -953,14 +960,13 @@
"type" : "string"
},
"InstitutionPspRequest" : {
"required" : [ "institutionType", "taxCode", "digitalAddress", "paymentServiceProvider" ],
"required" : [ "institutionType", "digitalAddress", "paymentServiceProvider" ],
"type" : "object",
"properties" : {
"institutionType" : {
"$ref" : "#/components/schemas/InstitutionType"
},
"taxCode" : {
"minLength" : 1,
"type" : "string"
},
"subunitCode" : {
Expand All @@ -972,6 +978,9 @@
"origin" : {
"$ref" : "#/components/schemas/Origin"
},
"originId" : {
"type" : "string"
},
"city" : {
"type" : "string"
},
Expand Down Expand Up @@ -1306,6 +1315,7 @@
"$ref" : "#/components/schemas/Origin"
},
"digitalAddress" : {
"pattern" : "\\S",
"type" : "string"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;

@Mapper(componentModel = "spring")
public interface OnboardingMapper {
Expand Down Expand Up @@ -42,6 +41,9 @@ default InstitutionBaseRequest toInstitutionBase(OnboardingData onboardingData)
.map(InstitutionPaSubunitType::valueOf)
.orElse(null));
institution.setOrigin(Optional.ofNullable(onboardingData.getOrigin()).map(Origin::fromValue).orElse(null));
if(Objects.nonNull(onboardingData.getOriginId())) {
institution.setOriginId(onboardingData.getOriginId());
}
if(Objects.nonNull(onboardingData.getLocation())) {
institution.setCity(onboardingData.getLocation().getCity());
institution.setCountry(onboardingData.getLocation().getCountry());
Expand All @@ -54,7 +56,7 @@ default InstitutionBaseRequest toInstitutionBase(OnboardingData onboardingData)
institution.geographicTaxonomies(Optional.ofNullable(onboardingData.getInstitutionUpdate().getGeographicTaxonomies())
.map(geotaxes -> geotaxes.stream()
.map(this::toGeographicTaxonomyDto)
.collect(Collectors.toList()))
.toList())
.orElse(null));
institution.rea(onboardingData.getInstitutionUpdate().getRea());
institution.shareCapital(onboardingData.getInstitutionUpdate().getShareCapital());
Expand All @@ -77,6 +79,9 @@ default InstitutionPspRequest toInstitutionPsp(OnboardingData onboardingData) {
.orElse(null));

institutionPsp.setOrigin(Optional.ofNullable(onboardingData.getOrigin()).map(Origin::fromValue).orElse(null));
if(Objects.nonNull(onboardingData.getOriginId())) {
institutionPsp.setOriginId(onboardingData.getOriginId());
}
if(Objects.nonNull(onboardingData.getLocation())) {
institutionPsp.setCity(onboardingData.getLocation().getCity());
institutionPsp.setCountry(onboardingData.getLocation().getCountry());
Expand All @@ -89,7 +94,7 @@ default InstitutionPspRequest toInstitutionPsp(OnboardingData onboardingData) {
institutionPsp.geographicTaxonomies(Optional.ofNullable(onboardingData.getInstitutionUpdate().getGeographicTaxonomies())
.map(geotaxes -> geotaxes.stream()
.map(this::toGeographicTaxonomyDto)
.collect(Collectors.toList()))
.toList())
.orElse(null));
institutionPsp.rea(onboardingData.getInstitutionUpdate().getRea());
institutionPsp.shareCapital(onboardingData.getInstitutionUpdate().getShareCapital());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void onboarding_institutionDefault() {
institutionUpdate.setDescription("description");
onboardingData.setBilling(billing);
onboardingData.setUsers(List.of(mockInstance(new User())));
onboardingData.setOriginId("originId");
onboardingData.setInstitutionUpdate(institutionUpdate);
// when
onboardingMsConnector.onboarding(onboardingData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public interface OnboardingResourceMapper {
@Mapping(source = "assistanceContacts.supportEmail", target = "institutionUpdate.supportEmail")
@Mapping(source = "assistanceContacts.supportPhone", target = "institutionUpdate.supportPhone")
@Mapping(source = "additionalInformations", target = "institutionUpdate.additionalInformations")
@Mapping(source = "ivassCode", target = "originId")
OnboardingData toEntity(OnboardingProductDto dto);

@Mapping(source = "billingData", target = "billing")
Expand Down

0 comments on commit 2acf188

Please sign in to comment.