diff --git a/app/src/main/resources/swagger/api-docs.json b/app/src/main/resources/swagger/api-docs.json index ddfdf27b..7149b47d 100644 --- a/app/src/main/resources/swagger/api-docs.json +++ b/app/src/main/resources/swagger/api-docs.json @@ -2210,6 +2210,44 @@ } } }, + "AggregateInstitution" : { + "title" : "AggregateInstitution", + "required" : [ "description", "taxCode" ], + "type" : "object", + "properties" : { + "address" : { + "type" : "string" + }, + "description" : { + "type" : "string" + }, + "geographicTaxonomies" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/GeographicTaxonomy" + } + }, + "origin" : { + "type" : "string", + "enum" : [ "ADE", "ANAC", "INFOCAMERE", "IPA", "IVASS", "MOCK", "SELC", "UNKNOWN" ] + }, + "originId" : { + "type" : "string" + }, + "subunitCode" : { + "type" : "string" + }, + "subunitType" : { + "type" : "string" + }, + "taxCode" : { + "type" : "string" + }, + "zipCode" : { + "type" : "string" + } + } + }, "AssistanceContactsDto" : { "title" : "AssistanceContactsDto", "type" : "object", @@ -2512,6 +2550,18 @@ } } }, + "GeographicTaxonomy" : { + "title" : "GeographicTaxonomy", + "type" : "object", + "properties" : { + "code" : { + "type" : "string" + }, + "desc" : { + "type" : "string" + } + } + }, "GeographicTaxonomyDto" : { "title" : "GeographicTaxonomyDto", "required" : [ "code", "desc" ], @@ -2825,6 +2875,13 @@ "description" : "GSP institution's additional informations", "$ref" : "#/components/schemas/AdditionalInformationsDto" }, + "aggregates" : { + "type" : "array", + "description" : "List of Aggregate Institutions, not empty only if isAggregator field's value is True", + "items" : { + "$ref" : "#/components/schemas/AggregateInstitution" + } + }, "assistanceContacts" : { "description" : "Institution's assistance contacts", "$ref" : "#/components/schemas/AssistanceContactsDto" @@ -2853,6 +2910,11 @@ "description" : "Institution's type", "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] }, + "isAggregator" : { + "type" : "boolean", + "description" : "specified if given institution is an Aggregator", + "example" : false + }, "origin" : { "type" : "string", "description" : "Institution data origin" diff --git a/web/src/main/java/it/pagopa/selfcare/onboarding/web/model/AggregateInstitution.java b/web/src/main/java/it/pagopa/selfcare/onboarding/web/model/AggregateInstitution.java new file mode 100644 index 00000000..37319153 --- /dev/null +++ b/web/src/main/java/it/pagopa/selfcare/onboarding/web/model/AggregateInstitution.java @@ -0,0 +1,27 @@ +package it.pagopa.selfcare.onboarding.web.model; + +import it.pagopa.selfcare.onboarding.common.Origin; +import it.pagopa.selfcare.onboarding.connector.model.onboarding.GeographicTaxonomy; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +@Data +public class AggregateInstitution { + + @NotNull(message = "taxCode is required") + private String taxCode; + + @NotNull(message = "description is required") + private String description; + + private String subunitCode; + private String subunitType; + private List geographicTaxonomies; + private String address; + private String zipCode; + private String originId; + private Origin origin; + +} diff --git a/web/src/main/java/it/pagopa/selfcare/onboarding/web/model/OnboardingProductDto.java b/web/src/main/java/it/pagopa/selfcare/onboarding/web/model/OnboardingProductDto.java index 7ff86fe0..896b6832 100644 --- a/web/src/main/java/it/pagopa/selfcare/onboarding/web/model/OnboardingProductDto.java +++ b/web/src/main/java/it/pagopa/selfcare/onboarding/web/model/OnboardingProductDto.java @@ -68,4 +68,10 @@ public class OnboardingProductDto { @ApiModelProperty(value = "${swagger.onboarding.institutions.model.additionalInformations}") private AdditionalInformationsDto additionalInformations; + + @ApiModelProperty(value = "${swagger.onboarding.institutions.model.isAggregator}") + private Boolean isAggregator; + + @ApiModelProperty(value = "${swagger.onboarding.institutions.model.aggregates}") + private List aggregates; } diff --git a/web/src/main/resources/swagger/swagger_en.properties b/web/src/main/resources/swagger/swagger_en.properties index 0a2bbddc..8eafd1cd 100644 --- a/web/src/main/resources/swagger/swagger_en.properties +++ b/web/src/main/resources/swagger/swagger_en.properties @@ -142,4 +142,7 @@ swagger.onboarding.institutions.model.additionalInformations.agentOfPublicServic swagger.onboarding.institutions.model.additionalInformations.agentOfPublicServiceNote=agentOfPublicService Note swagger.onboarding.institutions.model.additionalInformations.otherNote=Other note +swagger.onboarding.institutions.model.aggregates=List of Aggregate Institutions, not empty only if isAggregator field's value is True +swagger.onboarding.institutions.model.isAggregator=specified if given institution is an Aggregator + diff --git a/web/src/test/java/it/pagopa/selfcare/onboarding/web/controller/InstitutionV2ControllerTest.java b/web/src/test/java/it/pagopa/selfcare/onboarding/web/controller/InstitutionV2ControllerTest.java index 313d22e0..29ed6056 100644 --- a/web/src/test/java/it/pagopa/selfcare/onboarding/web/controller/InstitutionV2ControllerTest.java +++ b/web/src/test/java/it/pagopa/selfcare/onboarding/web/controller/InstitutionV2ControllerTest.java @@ -54,6 +54,25 @@ void onboardingProductAsync(@Value("classpath:stubs/onboardingProductsDtoWithout verifyNoMoreInteractions(institutionServiceMock); } + @Test + void onboardingProductForAggregatorAsync(@Value("classpath:stubs/onboardingProductsDtoWithAggregates.json") Resource onboardingDto) throws Exception { + // given + String institutionId = "institutionId"; + String productId = "productId"; + // when + mvc.perform(MockMvcRequestBuilders + .post(BASE_URL + "/onboarding", institutionId, productId) + .content(onboardingDto.getInputStream().readAllBytes()) + .contentType(APPLICATION_JSON_VALUE) + .accept(APPLICATION_JSON_VALUE)) + .andExpect(status().isCreated()) + .andExpect(content().string(emptyString())); + // then + verify(institutionServiceMock, times(1)) + .onboardingProductV2(any(OnboardingData.class)); + verifyNoMoreInteractions(institutionServiceMock); + } + @Test void onboardingCompany(@Value("classpath:stubs/onboardingCompanyDto.json") Resource onboardingDto) throws Exception { diff --git a/web/src/test/resources/stubs/onboardingProductsDtoWithAggregates.json b/web/src/test/resources/stubs/onboardingProductsDtoWithAggregates.json new file mode 100644 index 00000000..750320f5 --- /dev/null +++ b/web/src/test/resources/stubs/onboardingProductsDtoWithAggregates.json @@ -0,0 +1,37 @@ +{ + "billingData": { + "businessName": "string", + "digitalAddress": "string", + "publicServices": false, + "recipientCode": "string", + "registeredOffice": "string", + "taxCode": "string", + "vatNumber": "string", + "zipCode": "string" + }, + "institutionType": "PA", + "origin": "string", + "pricingPlan": "string", + "taxCode": "string", + "subunitCode": "string", + "subunitType": "AOO", + "productId": "prod-io", + "users": [ + { + "email": "email@example.com", + "name": "string", + "role": "DELEGATE", + "surname": "string", + "taxCode": "string" + } + ], + "isAggregate": true, + "aggregates": [ + { + "taxCode": "taxCode", + "subunitCode": "152652", + "subunitType": "AOO", + "description": "description" + } + ] +}