diff --git a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/CompletionServiceDefault.java b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/CompletionServiceDefault.java index 8e98723f3..b73258afb 100644 --- a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/CompletionServiceDefault.java +++ b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/CompletionServiceDefault.java @@ -1,5 +1,6 @@ package it.pagopa.selfcare.onboarding.service; +import it.pagopa.selfcare.onboarding.common.InstitutionPaSubunitType; import it.pagopa.selfcare.onboarding.common.InstitutionType; import it.pagopa.selfcare.onboarding.common.Origin; import it.pagopa.selfcare.onboarding.entity.Institution; @@ -14,10 +15,13 @@ import it.pagopa.selfcare.product.service.ProductService; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; +import jakarta.ws.rs.WebApplicationException; import org.apache.commons.lang3.StringUtils; import org.eclipse.microprofile.rest.client.inject.RestClient; import org.openapi.quarkus.core_json.api.InstitutionApi; import org.openapi.quarkus.core_json.model.*; +import org.openapi.quarkus.party_registry_proxy_json.api.AooApi; +import org.openapi.quarkus.party_registry_proxy_json.api.UoApi; import org.openapi.quarkus.user_registry_json.api.UserApi; import org.openapi.quarkus.user_registry_json.model.CertifiableFieldResourceOfstring; import org.openapi.quarkus.user_registry_json.model.UserResource; @@ -30,7 +34,6 @@ import java.util.stream.Collectors; import static it.pagopa.selfcare.onboarding.common.PartyRole.MANAGER; -import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_INTEROP; import static it.pagopa.selfcare.onboarding.service.OnboardingService.USERS_FIELD_LIST; import static it.pagopa.selfcare.onboarding.service.OnboardingService.USERS_WORKS_FIELD_LIST; import static it.pagopa.selfcare.onboarding.utils.PdfMapper.workContactsKey; @@ -45,6 +48,15 @@ public class CompletionServiceDefault implements CompletionService { @RestClient @Inject UserApi userRegistryApi; + @RestClient + @Inject + AooApi aooApi; + @RestClient + @Inject + UoApi uoApi; + @RestClient + @Inject + org.openapi.quarkus.party_registry_proxy_json.api.InstitutionApi institutionRegistryProxyApi; @Inject InstitutionMapper institutionMapper; @@ -109,10 +121,7 @@ private InstitutionResponse createInstitution(Institution institution, String pr return institutionApi.createInstitutionFromInfocamereUsingPOST(institutionMapper.toInstitutionRequest(institution)); } - if(InstitutionType.PA.equals(institution.getInstitutionType()) || - InstitutionType.SA.equals(institution.getInstitutionType()) || - (isGspAndProdInterop(institution.getInstitutionType(), productId) - && Origin.IPA.equals(institution.getOrigin()))) { + if(isInstitutionPresentOnIpa(institution)) { InstitutionFromIpaPost fromIpaPost = new InstitutionFromIpaPost(); fromIpaPost.setTaxCode(institution.getTaxCode()); @@ -129,9 +138,22 @@ private InstitutionResponse createInstitution(Institution institution, String pr return institutionApi.createInstitutionUsingPOST1(institutionMapper.toInstitutionRequest(institution)); } - private boolean isGspAndProdInterop(InstitutionType institutionType, String productId) { - return InstitutionType.GSP == institutionType - && productId.equals(PROD_INTEROP.getValue()); + private boolean isInstitutionPresentOnIpa(Institution institution) { + try { + if (InstitutionPaSubunitType.AOO.equals(institution.getSubunitType())) { + aooApi.findByUnicodeUsingGET(institution.getSubunitCode(), null); + } else if (InstitutionPaSubunitType.UO.equals(institution.getSubunitType())) { + uoApi.findByUnicodeUsingGET1(institution.getSubunitCode(), null); + } else { + institutionRegistryProxyApi.findInstitutionUsingGET(institution.getTaxCode(), null, null); + } + return true; + } catch (WebApplicationException e) { + if(e.getResponse().getStatus() == 404) { + return false; + } + throw new RuntimeException(e); + } } @Override diff --git a/apps/onboarding-functions/src/main/openapi/party_registry_proxy.json b/apps/onboarding-functions/src/main/openapi/party_registry_proxy.json new file mode 100644 index 000000000..fb8510db8 --- /dev/null +++ b/apps/onboarding-functions/src/main/openapi/party_registry_proxy.json @@ -0,0 +1,2126 @@ +{ + "openapi" : "3.0.3", + "info" : { + "title" : "selc-party-registry-proxy", + "description" : "Party Registry Proxy API documentation", + "version" : "0.0.1-SNAPSHOT" + }, + "servers" : [ { + "url" : "{url}:{port}{basePath}", + "variables" : { + "url" : { + "default" : "http://localhost" + }, + "port" : { + "default" : "80" + }, + "basePath" : { + "default" : "" + } + } + } ], + "tags" : [ { + "name" : "GeographicTaxonomies", + "description" : "Geographic Taxonomies Controller" + }, { + "name" : "aoo", + "description" : "AOO Controller" + }, { + "name" : "category", + "description" : "Category operations" + }, { + "name" : "infocamere", + "description" : "Info Camere Controller" + }, { + "name" : "institution", + "description" : "Institution operations" + }, { + "name" : "insurance-companies", + "description" : "Ivass Controller" + }, { + "name" : "nationalRegistries", + "description" : "National Registries Controller" + }, { + "name" : "stations", + "description" : "Station Controller" + }, { + "name" : "uo", + "description" : "UO Controller" + } ], + "paths" : { + "/aoo" : { + "get" : { + "tags" : [ "aoo" ], + "summary" : "Retrieve all AOO from IPA", + "description" : "Returns the AOO list", + "operationId" : "findAllUsingGET", + "parameters" : [ { + "name" : "page", + "in" : "query", + "description" : "Desired page number for result pagination. It is optional, and the default value is 1 when not specified", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + }, { + "name" : "limit", + "in" : "query", + "description" : "Maximum number of items per page. It is optional, and the default value is 10 when not specified", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/AOOsResource" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, + "/aoo/{codiceUniAoo}" : { + "get" : { + "tags" : [ "aoo" ], + "summary" : "Retrieve an AOO given its code", + "description" : "Returns an AOO", + "operationId" : "findByUnicodeUsingGET", + "parameters" : [ { + "name" : "codiceUniAoo", + "in" : "path", + "description" : "AOO unique identifier, the same of Id", + "required" : true, + "style" : "simple", + "schema" : { + "type" : "string" + } + }, { + "name" : "categories", + "in" : "query", + "description" : "Filter from origin category", + "required" : false, + "style" : "form", + "explode" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/AOOResource" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, + "/categories" : { + "get" : { + "tags" : [ "category" ], + "summary" : "Get all categories", + "description" : "Returns the categories list", + "operationId" : "findCategoriesUsingGET", + "parameters" : [ { + "name" : "origin", + "in" : "query", + "description" : "Describes which is the source of data", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string", + "enum" : [ "ANAC", "INFOCAMERE", "IPA", "IVASS", "static" ] + } + }, { + "name" : "page", + "in" : "query", + "description" : "Desired page number for result pagination. It is optional, and the default value is 1 when not specified", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + }, { + "name" : "limit", + "in" : "query", + "description" : "Maximum number of items per page. It is optional, and the default value is 10 when not specified", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/CategoriesResource" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, + "/origins/{origin}/categories/{code}" : { + "get" : { + "tags" : [ "category" ], + "summary" : "Get a category", + "description" : "Returns a category", + "operationId" : "findCategoryUsingGET", + "parameters" : [ { + "name" : "origin", + "in" : "path", + "description" : "Describes which is the source of data", + "required" : true, + "style" : "simple", + "schema" : { + "type" : "string", + "enum" : [ "ANAC", "INFOCAMERE", "IPA", "IVASS", "static" ] + } + }, { + "name" : "code", + "in" : "path", + "description" : "code", + "required" : true, + "style" : "simple", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/CategoryResource" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, + "/geotaxonomies" : { + "get" : { + "tags" : [ "GeographicTaxonomies" ], + "summary" : "retrieves the geographic taxonomies by description", + "description" : "retrieves the geographic taxonomies by description", + "operationId" : "retrieveGeoTaxonomiesByDescriptionUsingGET", + "parameters" : [ { + "name" : "description", + "in" : "query", + "description" : "geographic taxonomy description", + "required" : true, + "style" : "form", + "schema" : { + "type" : "string" + } + }, { + "name" : "offset", + "in" : "query", + "description" : "identifies the page 0-based index, default to 0", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + }, { + "name" : "limit", + "in" : "query", + "description" : "identifies the number of entries in a page, default to 10", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/GeographicTaxonomyResource" + } + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, + "/geotaxonomies/{geotaxId}" : { + "get" : { + "tags" : [ "GeographicTaxonomies" ], + "summary" : "retrieves the geographic taxonomy by code", + "description" : "retrieves the geographic taxonomy by code", + "operationId" : "retrieveGeoTaxonomiesByCodeUsingGET", + "parameters" : [ { + "name" : "geotaxId", + "in" : "path", + "description" : "Geographic taxonomy unique identifier ", + "required" : true, + "style" : "simple", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/GeographicTaxonomyResource" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, + "/info-camere/institutions" : { + "post" : { + "tags" : [ "infocamere" ], + "summary" : "Get institutions by legal tax id", + "description" : "Get the list of companies represented by the tax code of the person (physical or juridical) passed as a parameter", + "operationId" : "institutionsByLegalTaxIdUsingPOST", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/GetInstitutionsByLegalDto" + } + } + } + }, + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/BusinessesResource" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, + "/institutions" : { + "get" : { + "tags" : [ "institution" ], + "summary" : "Search institutions", + "description" : "Returns a list of Institutions.", + "operationId" : "searchUsingGET", + "parameters" : [ { + "name" : "search", + "in" : "query", + "description" : "if passed, the result is filtered based on the contained value.", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } + }, { + "name" : "page", + "in" : "query", + "description" : "Desired page number for result pagination. It is optional, and the default value is 1 when not specified", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + }, { + "name" : "limit", + "in" : "query", + "description" : "Maximum number of items per page. It is optional, and the default value is 10 when not specified", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + }, { + "name" : "categories", + "in" : "query", + "description" : "Filter from origin category", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/InstitutionsResource" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, + "/institutions/{id}" : { + "get" : { + "tags" : [ "institution" ], + "summary" : "Find institution by ID", + "description" : "Returns a single institution. If 'origin' param is filled, the ID to find is treated as 'originId' ($ref: '#/components/schemas/Institution'); otherwise is treated as 'id' ($ref: '#/components/schemas/Institution') ", + "operationId" : "findInstitutionUsingGET", + "parameters" : [ { + "name" : "id", + "in" : "path", + "description" : "The institution ID. It change semantic based on the origin param value (see notes)", + "required" : true, + "style" : "simple", + "schema" : { + "type" : "string" + } + }, { + "name" : "origin", + "in" : "query", + "description" : "Describes which is the source of data", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string", + "enum" : [ "ANAC", "INFOCAMERE", "IPA", "IVASS", "static" ] + } + }, { + "name" : "categories", + "in" : "query", + "description" : "Filter from origin category", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/InstitutionResource" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, + "/insurance-companies" : { + "get" : { + "tags" : [ "insurance-companies" ], + "summary" : "Search insurance company", + "description" : "Returns a list of insurance companies", + "operationId" : "searchUsingGET_1", + "parameters" : [ { + "name" : "search", + "in" : "query", + "description" : "Optional search field. Users can provide a search string to filter results", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } + }, { + "name" : "page", + "in" : "query", + "description" : "Desired page number for result pagination. It is optional, and the default value is 1 when not specified", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + }, { + "name" : "limit", + "in" : "query", + "description" : "Maximum number of items per page. It is optional, and the default value is 10 when not specified", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/InsuranceCompaniesResource" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, + "/insurance-companies/{taxId}" : { + "get" : { + "tags" : [ "insurance-companies" ], + "summary" : "Search insurance company by its taxCode", + "description" : "Returns only one insurance company.", + "operationId" : "searchByTaxCodeUsingGET", + "parameters" : [ { + "name" : "taxId", + "in" : "path", + "description" : "taxCode of insurance company", + "required" : true, + "style" : "simple", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/InsuranceCompanyResource" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, + "/national-registries/legal-address" : { + "get" : { + "tags" : [ "nationalRegistries" ], + "summary" : "Retrieve data from AdE and InfoCamere", + "description" : "Get the legal address of the business", + "operationId" : "legalAddressUsingGET", + "parameters" : [ { + "name" : "taxId", + "in" : "query", + "description" : "taxId", + "required" : true, + "style" : "form", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/LegalAddressResponse" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, + "/national-registries/verify-legal" : { + "get" : { + "tags" : [ "nationalRegistries" ], + "summary" : "Retrieve data from AdE and InfoCamere", + "description" : "verify if given taxId is legal of given institution identified with vatNumber", + "operationId" : "verifyLegalUsingGET", + "parameters" : [ { + "name" : "taxId", + "in" : "query", + "description" : "taxId", + "required" : true, + "style" : "form", + "schema" : { + "type" : "string" + } + }, { + "name" : "vatNumber", + "in" : "query", + "description" : "vatNumber", + "required" : true, + "style" : "form", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/LegalVerificationResult" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, + "/stations" : { + "get" : { + "tags" : [ "stations" ], + "summary" : "Search station", + "description" : "Returns a list of station.", + "operationId" : "searchUsingGET_2", + "parameters" : [ { + "name" : "search", + "in" : "query", + "description" : "Optional search field. Users can provide a search string to filter results", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } + }, { + "name" : "page", + "in" : "query", + "description" : "Desired page number for result pagination. It is optional, and the default value is 1 when not specified", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + }, { + "name" : "limit", + "in" : "query", + "description" : "Maximum number of items per page. It is optional, and the default value is 10 when not specified", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/StationsResource" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, + "/stations/{taxId}" : { + "get" : { + "tags" : [ "stations" ], + "summary" : "Search station by its taxCode", + "description" : "Returns only one station.", + "operationId" : "searchByTaxCodeUsingGET_1", + "parameters" : [ { + "name" : "taxId", + "in" : "path", + "description" : "taxCode of station", + "required" : true, + "style" : "simple", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/StationResource" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, + "/uo" : { + "get" : { + "tags" : [ "uo" ], + "summary" : "Retrieve all UO from IPA", + "description" : "Returns the UO list", + "operationId" : "findAllUsingGET_1", + "parameters" : [ { + "name" : "page", + "in" : "query", + "description" : "Desired page number for result pagination. It is optional, and the default value is 1 when not specified", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + }, { + "name" : "limit", + "in" : "query", + "description" : "Maximum number of items per page. It is optional, and the default value is 10 when not specified", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/UOsResource" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, + "/uo/{codiceUniAoo}" : { + "get" : { + "tags" : [ "uo" ], + "summary" : "Retrieve a UO given its code", + "description" : "Returns a UO", + "operationId" : "findByUnicodeUsingGET_1", + "parameters" : [ { + "name" : "codiceUniAoo", + "in" : "path", + "description" : "UO unique identifier, the same of Id", + "required" : true, + "style" : "simple", + "schema" : { + "type" : "string" + } + }, { + "name" : "categories", + "in" : "query", + "description" : "Filter from origin category", + "required" : false, + "style" : "form", + "explode" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/UOResource" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + } + }, + "components" : { + "schemas" : { + "AOOResource" : { + "title" : "AOOResource", + "type" : "object", + "properties" : { + "cap" : { + "type" : "string" + }, + "codAoo" : { + "type" : "string", + "description" : "AOO code" + }, + "codiceCatastaleComune" : { + "type" : "string", + "description" : "AOO land registry code" + }, + "codiceComuneISTAT" : { + "type" : "string", + "description" : "AOO istat code" + }, + "codiceFiscaleEnte" : { + "type" : "string", + "description" : "AOO fiscal code" + }, + "codiceIpa" : { + "type" : "string", + "description" : "AOO ipa code" + }, + "codiceUniAoo" : { + "type" : "string", + "description" : "AOO unique identifier, the same of Id" + }, + "cognomeResponsabile" : { + "type" : "string", + "description" : "AOO manager lastname" + }, + "dataAggiornamento" : { + "type" : "string", + "description" : "Identifies date of last update on the specific AOO" + }, + "dataIstituzione" : { + "type" : "string", + "description" : "Identifies date of first creation for AOO" + }, + "denominazioneAoo" : { + "type" : "string", + "description" : "AOO description" + }, + "denominazioneEnte" : { + "type" : "string", + "description" : "AOO parent description" + }, + "fax" : { + "type" : "string", + "description" : "AOO fax" + }, + "id" : { + "type" : "string" + }, + "indirizzo" : { + "type" : "string", + "description" : "AOO address" + }, + "mail1" : { + "type" : "string" + }, + "mailResponsabile" : { + "type" : "string", + "description" : "AOO manager email" + }, + "nomeResponsabile" : { + "type" : "string", + "description" : "AOO manager firstname" + }, + "origin" : { + "type" : "string", + "description" : "{swagger.model.*.origin}", + "enum" : [ "ANAC", "INFOCAMERE", "IPA", "IVASS", "static" ] + }, + "protocolloInformatico" : { + "type" : "string", + "description" : "AOO IT protocol" + }, + "telefono" : { + "type" : "string", + "description" : "AOO phone number" + }, + "telefonoResponsabile" : { + "type" : "string", + "description" : "AOO manager phone number" + }, + "tipoMail1" : { + "type" : "string" + }, + "uriprotocolloInformatico" : { + "type" : "string" + } + } + }, + "AOOsResource" : { + "title" : "AOOsResource", + "required" : [ "count", "items" ], + "type" : "object", + "properties" : { + "count" : { + "type" : "integer", + "description" : "Total count of items", + "format" : "int64" + }, + "items" : { + "type" : "array", + "description" : "List of AOO resource", + "items" : { + "$ref" : "#/components/schemas/AOOResource" + } + } + } + }, + "BusinessResource" : { + "title" : "BusinessResource", + "type" : "object", + "properties" : { + "businessName" : { + "type" : "string" + }, + "businessTaxId" : { + "type" : "string" + } + } + }, + "BusinessesResource" : { + "title" : "BusinessesResource", + "type" : "object", + "properties" : { + "businesses" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/BusinessResource" + } + }, + "legalTaxId" : { + "type" : "string" + }, + "requestDateTime" : { + "type" : "string" + } + } + }, + "CategoriesResource" : { + "title" : "CategoriesResource", + "required" : [ "items" ], + "type" : "object", + "properties" : { + "items" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/CategoryResource" + } + } + } + }, + "CategoryResource" : { + "title" : "CategoryResource", + "type" : "object", + "properties" : { + "code" : { + "type" : "string" + }, + "id" : { + "type" : "string" + }, + "kind" : { + "type" : "string" + }, + "name" : { + "type" : "string" + }, + "origin" : { + "type" : "string", + "description" : "Describes which is the source of data", + "enum" : [ "ANAC", "INFOCAMERE", "IPA", "IVASS", "static" ] + } + } + }, + "GeographicTaxonomyResource" : { + "title" : "GeographicTaxonomyResource", + "type" : "object", + "properties" : { + "code" : { + "type" : "string", + "description" : "Geographic taxonomy unique identifier " + }, + "country" : { + "type" : "string", + "description" : "Geographic taxonomy country" + }, + "country_abbreviation" : { + "type" : "string", + "description" : "Geographic taxonomy country abbreviation" + }, + "desc" : { + "type" : "string", + "description" : "Geographic taxonomy description" + }, + "enabled" : { + "type" : "boolean", + "description" : "Geographic taxonomy enabled", + "example" : false + }, + "istat_code" : { + "type" : "string", + "description" : "Geographic taxonomy istat code" + }, + "province_abbreviation" : { + "type" : "string", + "description" : "Geographic taxonomy province abbreviation" + }, + "province_id" : { + "type" : "string", + "description" : "Geographic taxonomy province unique identifier" + }, + "region_id" : { + "type" : "string", + "description" : "Geographic taxonomy region unique identifier" + } + } + }, + "GetInstitutionsByLegalDto" : { + "title" : "GetInstitutionsByLegalDto", + "type" : "object", + "properties" : { + "filter" : { + "$ref" : "#/components/schemas/GetInstitutionsByLegalFilterDto" + } + } + }, + "GetInstitutionsByLegalFilterDto" : { + "title" : "GetInstitutionsByLegalFilterDto", + "type" : "object", + "properties" : { + "legalTaxId" : { + "type" : "string" + } + } + }, + "InstitutionResource" : { + "title" : "InstitutionResource", + "type" : "object", + "properties" : { + "address" : { + "type" : "string", + "description" : "Institution address" + }, + "aoo" : { + "type" : "string", + "description" : "Area organizzativa omogenea" + }, + "category" : { + "type" : "string", + "description" : "Institution category" + }, + "description" : { + "type" : "string", + "description" : "Institution description" + }, + "digitalAddress" : { + "type" : "string", + "description" : "Institution digital address" + }, + "id" : { + "type" : "string", + "description" : "Semantic id to recognize a party between origins (or externalId)" + }, + "istatCode" : { + "type" : "string", + "description" : "Institution istat Code" + }, + "o" : { + "type" : "string", + "description" : "o" + }, + "origin" : { + "type" : "string", + "description" : "Describes which is the source of data", + "enum" : [ "ANAC", "INFOCAMERE", "IPA", "IVASS", "static" ] + }, + "originId" : { + "type" : "string", + "description" : "Id of the institution from its origin" + }, + "ou" : { + "type" : "string", + "description" : "ou" + }, + "taxCode" : { + "type" : "string", + "description" : "Institution fiscal code" + }, + "zipCode" : { + "type" : "string", + "description" : "Institution zipCode" + } + } + }, + "InstitutionsResource" : { + "title" : "InstitutionsResource", + "required" : [ "count", "items" ], + "type" : "object", + "properties" : { + "count" : { + "type" : "integer", + "format" : "int64" + }, + "items" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/InstitutionResource" + } + } + } + }, + "InsuranceCompaniesResource" : { + "title" : "InsuranceCompaniesResource", + "required" : [ "count", "items" ], + "type" : "object", + "properties" : { + "count" : { + "type" : "integer", + "description" : "list of companies resource size", + "format" : "int64" + }, + "items" : { + "type" : "array", + "description" : "list of insurance companies resource", + "items" : { + "$ref" : "#/components/schemas/InsuranceCompanyResource" + } + } + } + }, + "InsuranceCompanyResource" : { + "title" : "InsuranceCompanyResource", + "type" : "object", + "properties" : { + "address" : { + "type" : "string", + "description" : "Identifies legal address of insurance company" + }, + "description" : { + "type" : "string", + "description" : "insurance company's name" + }, + "digitalAddress" : { + "type" : "string", + "description" : "insurance company's mail address" + }, + "id" : { + "type" : "string", + "description" : "insurance company's unique identifier" + }, + "origin" : { + "type" : "string", + "description" : "Describes which is the source of data", + "enum" : [ "ANAC", "INFOCAMERE", "IPA", "IVASS", "static" ] + }, + "originId" : { + "type" : "string", + "description" : "insurance company's IVASS unique identifier" + }, + "registerType" : { + "type" : "string", + "description" : "Identifies register type for company" + }, + "taxCode" : { + "type" : "string", + "description" : "taxCode of insurance company" + }, + "workType" : { + "type" : "string", + "description" : "Identifies work type for company" + } + } + }, + "InvalidParam" : { + "title" : "InvalidParam", + "required" : [ "name", "reason" ], + "type" : "object", + "properties" : { + "name" : { + "type" : "string", + "description" : "Invalid parameter name." + }, + "reason" : { + "type" : "string", + "description" : "Invalid parameter reason." + } + } + }, + "LegalAddressResponse" : { + "title" : "LegalAddressResponse", + "type" : "object", + "properties" : { + "address" : { + "type" : "string" + }, + "zipCode" : { + "type" : "string" + } + } + }, + "LegalVerificationResult" : { + "title" : "LegalVerificationResult", + "type" : "object", + "properties" : { + "resultCode" : { + "type" : "string" + }, + "resultDetail" : { + "type" : "string" + }, + "verificationResult" : { + "type" : "boolean" + } + } + }, + "Problem" : { + "title" : "Problem", + "required" : [ "status", "title" ], + "type" : "object", + "properties" : { + "detail" : { + "type" : "string", + "description" : "Human-readable description of this specific problem." + }, + "instance" : { + "type" : "string", + "description" : "A URI that describes where the problem occurred." + }, + "invalidParams" : { + "type" : "array", + "description" : "A list of invalid parameters details.", + "items" : { + "$ref" : "#/components/schemas/InvalidParam" + } + }, + "status" : { + "type" : "integer", + "description" : "The HTTP status code.", + "format" : "int32", + "example" : 500 + }, + "title" : { + "type" : "string", + "description" : "Short human-readable summary of the problem." + }, + "type" : { + "type" : "string", + "description" : "A URL to a page with more details regarding the problem." + } + }, + "description" : "A \"problem detail\" as a way to carry machine-readable details of errors (https://datatracker.ietf.org/doc/html/rfc7807)" + }, + "StationResource" : { + "title" : "StationResource", + "type" : "object", + "properties" : { + "anacEnabled" : { + "type" : "boolean", + "description" : "Identifies if ANAC station is enabled", + "example" : false + }, + "anacEngaged" : { + "type" : "boolean", + "description" : "Identifies if ANAC station is engaged", + "example" : false + }, + "description" : { + "type" : "string", + "description" : "station's name" + }, + "digitalAddress" : { + "type" : "string", + "description" : "station's mail address" + }, + "id" : { + "type" : "string", + "description" : "station's unique identifier" + }, + "origin" : { + "type" : "string", + "description" : "Describes which is the source of data", + "enum" : [ "ANAC", "INFOCAMERE", "IPA", "IVASS", "static" ] + }, + "originId" : { + "type" : "string", + "description" : "station's anac unique identifier" + }, + "taxCode" : { + "type" : "string", + "description" : "taxCode of station" + } + } + }, + "StationsResource" : { + "title" : "StationsResource", + "required" : [ "count", "items" ], + "type" : "object", + "properties" : { + "count" : { + "type" : "integer", + "description" : "list of station resource size", + "format" : "int64" + }, + "items" : { + "type" : "array", + "description" : "list of station resource", + "items" : { + "$ref" : "#/components/schemas/StationResource" + } + } + } + }, + "UOResource" : { + "title" : "UOResource", + "type" : "object", + "properties" : { + "cap" : { + "type" : "string" + }, + "codiceCatastaleComune" : { + "type" : "string", + "description" : "UO land registry code" + }, + "codiceComuneISTAT" : { + "type" : "string", + "description" : "UO istat code" + }, + "codiceFiscaleEnte" : { + "type" : "string", + "description" : "UO fiscal code" + }, + "codiceIpa" : { + "type" : "string", + "description" : "UO ipa code" + }, + "codiceUniAoo" : { + "type" : "string", + "description" : "AOO unique identifier, the same of Id" + }, + "codiceUniUo" : { + "type" : "string", + "description" : "UO unique identifier, the same of Id" + }, + "codiceUniUoPadre" : { + "type" : "string", + "description" : "UO parent code" + }, + "cognomeResponsabile" : { + "type" : "string", + "description" : "UO manager lastname" + }, + "dataAggiornamento" : { + "type" : "string", + "description" : "Identifies date of last update on the specific UO" + }, + "dataIstituzione" : { + "type" : "string", + "description" : "Identifies date of first creation for UO" + }, + "denominazioneEnte" : { + "type" : "string", + "description" : "UO parent description" + }, + "descrizioneUo" : { + "type" : "string", + "description" : "UO description" + }, + "fax" : { + "type" : "string", + "description" : "UO fax" + }, + "id" : { + "type" : "string" + }, + "indirizzo" : { + "type" : "string", + "description" : "UO address" + }, + "mail1" : { + "type" : "string" + }, + "mailResponsabile" : { + "type" : "string", + "description" : "UO manager email" + }, + "nomeResponsabile" : { + "type" : "string", + "description" : "UO manager firstname" + }, + "origin" : { + "type" : "string", + "description" : "Describes which is the source of data", + "enum" : [ "ANAC", "INFOCAMERE", "IPA", "IVASS", "static" ] + }, + "telefono" : { + "type" : "string", + "description" : "UO phone number" + }, + "telefonoResponsabile" : { + "type" : "string", + "description" : "UO manager phone number" + }, + "tipoMail1" : { + "type" : "string" + }, + "url" : { + "type" : "string", + "description" : "UO url" + } + } + }, + "UOsResource" : { + "title" : "UOsResource", + "required" : [ "count", "items" ], + "type" : "object", + "properties" : { + "count" : { + "type" : "integer", + "description" : "Total count of items", + "format" : "int64" + }, + "items" : { + "type" : "array", + "description" : "List of UO resource", + "items" : { + "$ref" : "#/components/schemas/UOResource" + } + } + } + } + }, + "securitySchemes" : { + "bearerAuth" : { + "type" : "http", + "description" : "A bearer token in the format of a JWS and conformed to the specifications included in [RFC8725](https://tools.ietf.org/html/RFC8725)", + "scheme" : "bearer", + "bearerFormat" : "JWT" + } + } + } +} \ No newline at end of file diff --git a/apps/onboarding-functions/src/main/resources/application.properties b/apps/onboarding-functions/src/main/resources/application.properties index 9b619d63b..24af3ff0a 100644 --- a/apps/onboarding-functions/src/main/resources/application.properties +++ b/apps/onboarding-functions/src/main/resources/application.properties @@ -33,6 +33,13 @@ quarkus.openapi-generator.codegen.spec.core_json.enable-security-generation=fals quarkus.openapi-generator.codegen.spec.core_json.additional-api-type-annotations=@org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders(it.pagopa.selfcare.onboarding.client.auth.AuthenticationPropagationHeadersFactory.class) quarkus.rest-client."org.openapi.quarkus.core_json.api.InstitutionApi".url=${MS_CORE_URL:http://localhost:8080} +quarkus.openapi-generator.codegen.spec.party_registry_proxy_json.enable-security-generation=false +quarkus.openapi-generator.codegen.spec.party_registry_proxy_json.additional-api-type-annotations=@org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders(it.pagopa.selfcare.onboarding.client.auth.AuthenticationPropagationHeadersFactory.class) +quarkus.rest-client."org.openapi.quarkus.party_registry_proxy_json.api.UoApi".url=${MS_PARTY_REGISTRY_URL:http://localhost:8080} +quarkus.rest-client."org.openapi.quarkus.party_registry_proxy_json.api.AooApi".url=${MS_PARTY_REGISTRY_URL:http://localhost:8080} +quarkus.rest-client."org.openapi.quarkus.party_registry_proxy_json.api.InstitutionApi".url=${MS_PARTY_REGISTRY_URL:http://localhost:8080} + + ## AZURE STORAGE ## onboarding-functions.blob-storage.container-contract=${STORAGE_CONTAINER_CONTRACT:selc-d-contracts-blob} diff --git a/apps/onboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/service/CompletionServiceDefaultTest.java b/apps/onboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/service/CompletionServiceDefaultTest.java index 5fc077aa9..cdc285a9f 100644 --- a/apps/onboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/service/CompletionServiceDefaultTest.java +++ b/apps/onboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/service/CompletionServiceDefaultTest.java @@ -8,22 +8,29 @@ import it.pagopa.selfcare.onboarding.common.Origin; import it.pagopa.selfcare.onboarding.common.PartyRole; import it.pagopa.selfcare.onboarding.entity.*; +import it.pagopa.selfcare.onboarding.entity.Billing; +import it.pagopa.selfcare.onboarding.entity.Institution; +import it.pagopa.selfcare.onboarding.entity.Onboarding; +import it.pagopa.selfcare.onboarding.entity.Token; import it.pagopa.selfcare.onboarding.exception.GenericOnboardingException; import it.pagopa.selfcare.onboarding.repository.OnboardingRepository; import it.pagopa.selfcare.onboarding.repository.TokenRepository; import it.pagopa.selfcare.product.entity.Product; import it.pagopa.selfcare.product.service.ProductService; import jakarta.inject.Inject; +import jakarta.ws.rs.WebApplicationException; import org.bson.types.ObjectId; import org.eclipse.microprofile.rest.client.inject.RestClient; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; import org.openapi.quarkus.core_json.api.InstitutionApi; -import org.openapi.quarkus.core_json.model.InstitutionFromIpaPost; -import org.openapi.quarkus.core_json.model.InstitutionOnboardingRequest; -import org.openapi.quarkus.core_json.model.InstitutionResponse; -import org.openapi.quarkus.core_json.model.InstitutionsResponse; +import org.openapi.quarkus.core_json.model.*; +import org.openapi.quarkus.party_registry_proxy_json.api.AooApi; +import org.openapi.quarkus.party_registry_proxy_json.api.UoApi; +import org.openapi.quarkus.party_registry_proxy_json.model.AOOResource; +import org.openapi.quarkus.party_registry_proxy_json.model.InstitutionResource; +import org.openapi.quarkus.party_registry_proxy_json.model.UOResource; import org.openapi.quarkus.user_registry_json.api.UserApi; import org.openapi.quarkus.user_registry_json.model.CertifiableFieldResourceOfstring; import org.openapi.quarkus.user_registry_json.model.UserResource; @@ -60,6 +67,15 @@ public class CompletionServiceDefaultTest { @RestClient @InjectMock UserApi userRegistryApi; + @RestClient + @InjectMock + AooApi aooApi; + @RestClient + @InjectMock + UoApi uoApi; + @RestClient + @InjectMock + org.openapi.quarkus.party_registry_proxy_json.api.InstitutionApi institutionRegistryProxyApi; final String productId = "productId"; @@ -163,7 +179,7 @@ void createInstitutionAndPersistInstitutionId_notFoundInstitutionAndCreatePgAde( mockOnboardingUpdateAndExecuteCreateInstitution(onboarding, institutionResponse); } @Test - void createInstitutionAndPersistInstitutionId_notFoundInstitutionAndCreatePa() { + void createInstitutionAndPersistInstitutionId_notFoundInstitutionAndCreatePaAOO() { Onboarding onboarding = createOnboarding(); Institution institution = new Institution(); @@ -172,6 +188,45 @@ void createInstitutionAndPersistInstitutionId_notFoundInstitutionAndCreatePa() { institution.setSubunitCode("code"); onboarding.setInstitution(institution); + AOOResource aooResource = new AOOResource(); + when(aooApi.findByUnicodeUsingGET(institution.getSubunitCode(), null)) + .thenReturn(aooResource); + + InstitutionsResponse response = new InstitutionsResponse(); + when(institutionApi.getInstitutionsUsingGET(onboarding.getInstitution().getTaxCode(), + onboarding.getInstitution().getSubunitCode(), null, null)) + .thenReturn(response); + + InstitutionResponse institutionResponse = dummyInstitutionResponse(); + when(institutionApi.createInstitutionFromIpaUsingPOST(any())).thenReturn(institutionResponse); + + mockOnboardingUpdateAndExecuteCreateInstitution(onboarding, institutionResponse); + + ArgumentCaptor captor = ArgumentCaptor.forClass(InstitutionFromIpaPost.class); + ArgumentCaptor subunitCodeCaptor = ArgumentCaptor.forClass(String.class); + verify(aooApi, times(1)) + .findByUnicodeUsingGET(subunitCodeCaptor.capture(), any()); + assertEquals(institution.getSubunitCode(), subunitCodeCaptor.getValue()); + verify(institutionApi, times(1)) + .createInstitutionFromIpaUsingPOST(captor.capture()); + assertEquals(institution.getTaxCode(), captor.getValue().getTaxCode()); + assertEquals(institution.getSubunitCode(), captor.getValue().getSubunitCode()); + } + + @Test + void createInstitutionAndPersistInstitutionId_notFoundInstitutionAndCreatePaUO() { + Onboarding onboarding = createOnboarding(); + + Institution institution = new Institution(); + institution.setInstitutionType(InstitutionType.PA); + institution.setSubunitType(InstitutionPaSubunitType.UO); + institution.setSubunitCode("code"); + onboarding.setInstitution(institution); + + UOResource uoResource = new UOResource(); + when(uoApi.findByUnicodeUsingGET1(institution.getSubunitCode(), institution.getInstitutionType().name())) + .thenReturn(uoResource); + InstitutionsResponse response = new InstitutionsResponse(); when(institutionApi.getInstitutionsUsingGET(onboarding.getInstitution().getTaxCode(), onboarding.getInstitution().getSubunitCode(), null, null)) @@ -183,12 +238,79 @@ void createInstitutionAndPersistInstitutionId_notFoundInstitutionAndCreatePa() { mockOnboardingUpdateAndExecuteCreateInstitution(onboarding, institutionResponse); ArgumentCaptor captor = ArgumentCaptor.forClass(InstitutionFromIpaPost.class); + ArgumentCaptor subunitCodeCaptor = ArgumentCaptor.forClass(String.class); + verify(uoApi, times(1)) + .findByUnicodeUsingGET1(subunitCodeCaptor.capture(), any()); + assertEquals(institution.getSubunitCode(), subunitCodeCaptor.getValue()); verify(institutionApi, times(1)) .createInstitutionFromIpaUsingPOST(captor.capture()); assertEquals(institution.getTaxCode(), captor.getValue().getTaxCode()); assertEquals(institution.getSubunitCode(), captor.getValue().getSubunitCode()); } + @Test + void createInstitutionAndPersistInstitutionId_notFoundInstitutionAndCreatePa() { + Onboarding onboarding = createOnboarding(); + + Institution institution = new Institution(); + institution.setInstitutionType(InstitutionType.PA); + institution.setTaxCode("taxCode"); + onboarding.setInstitution(institution); + + InstitutionResource institutionResource = new InstitutionResource(); + when(institutionRegistryProxyApi.findInstitutionUsingGET(institution.getTaxCode(), null, null)) + .thenReturn(institutionResource); + + InstitutionsResponse response = new InstitutionsResponse(); + when(institutionApi.getInstitutionsUsingGET(onboarding.getInstitution().getTaxCode(), + null, null, null)) + .thenReturn(response); + + InstitutionResponse institutionResponse = dummyInstitutionResponse(); + when(institutionApi.createInstitutionFromIpaUsingPOST(any())).thenReturn(institutionResponse); + + mockOnboardingUpdateAndExecuteCreateInstitution(onboarding, institutionResponse); + + ArgumentCaptor captor = ArgumentCaptor.forClass(InstitutionFromIpaPost.class); + ArgumentCaptor taxCodeCaptor = ArgumentCaptor.forClass(String.class); + verify(institutionRegistryProxyApi, times(1)) + .findInstitutionUsingGET(taxCodeCaptor.capture(), any(), any()); + assertEquals(institution.getTaxCode(), taxCodeCaptor.getValue()); + verify(institutionApi, times(1)) + .createInstitutionFromIpaUsingPOST(captor.capture()); + assertEquals(institution.getTaxCode(), captor.getValue().getTaxCode()); + } + + @Test + void createInstitutionAndPersistInstitutionId_notFoundInstitutionAndCreate() { + Onboarding onboarding = createOnboarding(); + + Institution institution = new Institution(); + institution.setInstitutionType(InstitutionType.GSP); + onboarding.setInstitution(institution); + + WebApplicationException e = new WebApplicationException(404); + when(institutionRegistryProxyApi.findInstitutionUsingGET(institution.getTaxCode(), null ,null)) + .thenThrow(e); + + InstitutionsResponse response = new InstitutionsResponse(); + when(institutionApi.getInstitutionsUsingGET(onboarding.getInstitution().getTaxCode(), + null, null, null)) + .thenReturn(response); + + InstitutionResponse institutionResponse = dummyInstitutionResponse(); + when(institutionApi.createInstitutionUsingPOST1(any())).thenReturn(institutionResponse); + + mockOnboardingUpdateAndExecuteCreateInstitution(onboarding, institutionResponse); + + ArgumentCaptor captor = ArgumentCaptor.forClass(InstitutionRequest.class); + verify(institutionApi, times(1)) + .createInstitutionUsingPOST1(captor.capture()); + assertEquals(institution.getTaxCode(), captor.getValue().getTaxCode()); + } + + + @Test void persistOnboarding_workContractsNotFound() { Onboarding onboarding = createOnboarding(); diff --git a/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/controller/request/BillingPaRequest.java b/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/controller/request/BillingPaRequest.java index 1cd1ba060..825f7dc53 100644 --- a/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/controller/request/BillingPaRequest.java +++ b/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/controller/request/BillingPaRequest.java @@ -7,7 +7,6 @@ public class BillingPaRequest { @NotEmpty(message = "vatNumber is required") private String vatNumber; - @NotEmpty(message = "recipientCode is required") private String recipientCode; private boolean publicServices; } diff --git a/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/service/util/OnboardingUtils.java b/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/service/util/OnboardingUtils.java index cbec9d689..ec405c638 100644 --- a/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/service/util/OnboardingUtils.java +++ b/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/service/util/OnboardingUtils.java @@ -12,8 +12,14 @@ public class OnboardingUtils { private static final String ADDITIONAL_INFORMATIONS_REQUIRED = "Additional Informations is required when institutionType is GSP and productId is pagopa"; private static final String OTHER_NOTE_REQUIRED = "Other Note is required when other boolean are false"; + private static final String BILLING_OR_RECIPIENT_CODE_REQUIRED = "Billing and/or recipient code are required"; public static Uni customValidationOnboardingData(Onboarding onboarding) { + if(InstitutionType.PA.equals(onboarding.getInstitution().getInstitutionType()) && + !ProductId.PROD_INTEROP.getValue().equals(onboarding.getProductId())){ + if(Objects.isNull(onboarding.getBilling()) || Objects.isNull(onboarding.getBilling().getRecipientCode())) + return Uni.createFrom().failure(new InvalidRequestException(BILLING_OR_RECIPIENT_CODE_REQUIRED)); + } if(InstitutionType.GSP == onboarding.getInstitution().getInstitutionType() && ProductId.PROD_PAGOPA.getValue().equals(onboarding.getProductId())) { if(Objects.isNull(onboarding.getAdditionalInformations())) { diff --git a/apps/onboarding-ms/src/test/java/it/pagopa/selfcare/onboarding/service/util/OnboardingUtilsTest.java b/apps/onboarding-ms/src/test/java/it/pagopa/selfcare/onboarding/service/util/OnboardingUtilsTest.java index 98766a886..2ea099d1a 100644 --- a/apps/onboarding-ms/src/test/java/it/pagopa/selfcare/onboarding/service/util/OnboardingUtilsTest.java +++ b/apps/onboarding-ms/src/test/java/it/pagopa/selfcare/onboarding/service/util/OnboardingUtilsTest.java @@ -11,6 +11,7 @@ import it.pagopa.selfcare.onboarding.common.ProductId; import it.pagopa.selfcare.onboarding.controller.response.OnboardingGet; import it.pagopa.selfcare.onboarding.entity.AdditionalInformations; +import it.pagopa.selfcare.onboarding.entity.Billing; import it.pagopa.selfcare.onboarding.entity.Institution; import it.pagopa.selfcare.onboarding.entity.Onboarding; import it.pagopa.selfcare.onboarding.exception.InvalidRequestException; @@ -36,9 +37,13 @@ public class OnboardingUtilsTest { @ParameterizedTest @ValueSource(strings = {"ipa", "regulatedMarket", "establishedByRegulatoryProvision", "agentOfPublicService"}) void shouldOnboardingInstitutionWithAdditionalInfo(String type) { + + Billing billing = new Billing(); + billing.setRecipientCode("recipientCode"); Onboarding onboarding = new Onboarding(); Institution institution = new Institution(); institution.setInstitutionType(InstitutionType.GSP); + onboarding.setBilling(billing); onboarding.setInstitution(institution); onboarding.setProductId(ProductId.PROD_PAGOPA.getValue()); onboarding.setAdditionalInformations(createSimpleAdditionalInformations(type)); @@ -55,9 +60,12 @@ void shouldOnboardingInstitutionWithAdditionalInfo(String type) { @Test void shouldOnboardingInstitutionWithAdditionalInfoRequiredException() { + Billing billing = new Billing(); + billing.setRecipientCode("recipientCode"); Onboarding onboarding = new Onboarding(); Institution institution = new Institution(); institution.setInstitutionType(InstitutionType.GSP); + onboarding.setBilling(billing); onboarding.setInstitution(institution); onboarding.setProductId(ProductId.PROD_PAGOPA.getValue()); onboarding.setAdditionalInformations(createSimpleAdditionalInformations("other")); @@ -74,10 +82,51 @@ void shouldOnboardingInstitutionWithAdditionalInfoRequiredException() { @Test void shouldOnboardingInstitutionWithOtherNoteRequiredException() { + Billing billing = new Billing(); + billing.setRecipientCode("recipientCode"); Onboarding onboarding = new Onboarding(); Institution institution = new Institution(); institution.setInstitutionType(InstitutionType.GSP); + onboarding.setBilling(billing); + onboarding.setInstitution(institution); + onboarding.setProductId(ProductId.PROD_PAGOPA.getValue()); + + UniAssertSubscriber subscriber = OnboardingUtils + .customValidationOnboardingData(onboarding) + .subscribe() + .withSubscriber(UniAssertSubscriber.create()); + + subscriber.assertFailedWith(InvalidRequestException.class); + + } + + @Test + void shouldOnboardingInstitutionWithBillingRequiredException() { + + Onboarding onboarding = new Onboarding(); + Institution institution = new Institution(); + institution.setInstitutionType(InstitutionType.PA); + onboarding.setInstitution(institution); + onboarding.setProductId(ProductId.PROD_PAGOPA.getValue()); + + UniAssertSubscriber subscriber = OnboardingUtils + .customValidationOnboardingData(onboarding) + .subscribe() + .withSubscriber(UniAssertSubscriber.create()); + + subscriber.assertFailedWith(InvalidRequestException.class); + + } + + @Test + void shouldOnboardingInstitutionWithRecipientCodeRequiredException() { + + Billing billing = new Billing(); + Onboarding onboarding = new Onboarding(); + Institution institution = new Institution(); + institution.setInstitutionType(InstitutionType.PA); onboarding.setInstitution(institution); + onboarding.setBilling(billing); onboarding.setProductId(ProductId.PROD_PAGOPA.getValue()); UniAssertSubscriber subscriber = OnboardingUtils diff --git a/infra/functions/onboarding-functions/env/dev/terraform.tfvars b/infra/functions/onboarding-functions/env/dev/terraform.tfvars index 13e073d69..c94164dea 100644 --- a/infra/functions/onboarding-functions/env/dev/terraform.tfvars +++ b/infra/functions/onboarding-functions/env/dev/terraform.tfvars @@ -64,5 +64,6 @@ app_settings = { "MAIL_ONBOARDING_REJECTION_LINK" = "https://dev.selfcare.pagopa.it/onboarding/cancel?jwt=", "MAIL_ONBOARDING_URL" : "https://dev.selfcare.pagopa.it/onboarding/", "MS_CORE_URL" = "https://selc.internal.dev.selfcare.pagopa.it/ms-core/v1", - "JWT_BEARER_TOKEN" = "@Microsoft.KeyVault(SecretUri=https://selc-d-kv.vault.azure.net/secrets/jwt-bearer-token-functions/)" + "JWT_BEARER_TOKEN" = "@Microsoft.KeyVault(SecretUri=https://selc-d-kv.vault.azure.net/secrets/jwt-bearer-token-functions/)", + "MS_PARTY_REGISTRY_URL" = "http://selc.internal.dev.selfcare.pagopa.it/party-registry-proxy/v1" } \ No newline at end of file diff --git a/infra/functions/onboarding-functions/env/prod/terraform.tfvars b/infra/functions/onboarding-functions/env/prod/terraform.tfvars index 277ab2da3..34abe7e44 100644 --- a/infra/functions/onboarding-functions/env/prod/terraform.tfvars +++ b/infra/functions/onboarding-functions/env/prod/terraform.tfvars @@ -64,5 +64,6 @@ app_settings = { "MAIL_ONBOARDING_REJECTION_LINK" = "https://uat.selfcare.pagopa.it/onboarding/cancel?jwt=", "MAIL_ONBOARDING_URL" : "https://uat.selfcare.pagopa.it/onboarding/", "MS_CORE_URL" : "https://selc.internal.uat.selfcare.pagopa.it/ms-core/v1", - "JWT_BEARER_TOKEN" = "@Microsoft.KeyVault(SecretUri=https://selc-u-kv.vault.azure.net/secrets/jwt-bearer-token-functions/)" + "JWT_BEARER_TOKEN" = "@Microsoft.KeyVault(SecretUri=https://selc-u-kv.vault.azure.net/secrets/jwt-bearer-token-functions/)", + "MS_PARTY_REGISTRY_URL" = "http://selc.internal.selfcare.pagopa.it/party-registry-proxy/v1", } \ No newline at end of file diff --git a/infra/functions/onboarding-functions/env/uat/terraform.tfvars b/infra/functions/onboarding-functions/env/uat/terraform.tfvars index b37eb204a..29ed0976e 100644 --- a/infra/functions/onboarding-functions/env/uat/terraform.tfvars +++ b/infra/functions/onboarding-functions/env/uat/terraform.tfvars @@ -64,5 +64,6 @@ app_settings = { "MAIL_ONBOARDING_REJECTION_LINK" = "https://uat.selfcare.pagopa.it/onboarding/cancel?jwt=", "MAIL_ONBOARDING_URL" : "https://uat.selfcare.pagopa.it/onboarding/", "MS_CORE_URL" : "https://selc.internal.uat.selfcare.pagopa.it/ms-core/v1", - "JWT_BEARER_TOKEN" = "@Microsoft.KeyVault(SecretUri=https://selc-u-kv.vault.azure.net/secrets/jwt-bearer-token-functions/)" + "JWT_BEARER_TOKEN" = "@Microsoft.KeyVault(SecretUri=https://selc-u-kv.vault.azure.net/secrets/jwt-bearer-token-functions/)", + "MS_PARTY_REGISTRY_URL" = "http://selc.internal.uat.selfcare.pagopa.it/party-registry-proxy/v1" } \ No newline at end of file