diff --git a/app/src/main/resources/swagger/api-docs.json b/app/src/main/resources/swagger/api-docs.json index ab17d931..2a4075ca 100644 --- a/app/src/main/resources/swagger/api-docs.json +++ b/app/src/main/resources/swagger/api-docs.json @@ -25,6 +25,9 @@ }, { "name" : "institutions-pnpg", "description" : "Pn Pg Controller" + }, { + "name" : "national-registries", + "description" : "National Registry Controller" }, { "name" : "onboarding", "description" : "Onboarding operations" @@ -589,6 +592,68 @@ } ] } }, + "/v2/national-registries/legal-tax/verification" : { + "post" : { + "tags" : [ "external-v2", "national-registries" ], + "summary" : "verifyLegal", + "description" : "Verify if given taxId is legal of given institution identified with vatNumber", + "operationId" : "verifyLegalByPOST", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/VerifyRequestDto" + } + } + } + }, + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/LegalVerificationResource" + } + } + } + }, + "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" ] + } ] + } + }, "/v2/onboarding" : { "post" : { "tags" : [ "onboarding" ], @@ -1862,6 +1927,21 @@ } } }, + "LegalVerificationResource" : { + "title" : "LegalVerificationResource", + "type" : "object", + "properties" : { + "resultCode" : { + "type" : "string" + }, + "resultDetail" : { + "type" : "string" + }, + "verificationResult" : { + "type" : "boolean" + } + } + }, "LegalsResource" : { "title" : "LegalsResource", "type" : "object", @@ -2615,6 +2695,19 @@ "description" : "User's surname" } } + }, + "VerifyRequestDto" : { + "title" : "VerifyRequestDto", + "required" : [ "taxId", "vatNumber" ], + "type" : "object", + "properties" : { + "taxId" : { + "type" : "string" + }, + "vatNumber" : { + "type" : "string" + } + } } }, "securitySchemes" : { diff --git a/connector-api/src/main/java/it/pagopa/selfcare/external_api/api/MsPartyRegistryProxyConnector.java b/connector-api/src/main/java/it/pagopa/selfcare/external_api/api/MsPartyRegistryProxyConnector.java index 4d012400..574ce910 100644 --- a/connector-api/src/main/java/it/pagopa/selfcare/external_api/api/MsPartyRegistryProxyConnector.java +++ b/connector-api/src/main/java/it/pagopa/selfcare/external_api/api/MsPartyRegistryProxyConnector.java @@ -1,9 +1,12 @@ package it.pagopa.selfcare.external_api.api; import it.pagopa.selfcare.external_api.model.institutions.InstitutionResource; +import it.pagopa.selfcare.external_api.model.nationalRegistries.LegalVerification; public interface MsPartyRegistryProxyConnector { InstitutionResource findInstitution(String institutionExternalId); + LegalVerification verifyLegal(String taxId, String vatNumber); + } diff --git a/connector-api/src/main/java/it/pagopa/selfcare/external_api/model/nationalRegistries/LegalVerification.java b/connector-api/src/main/java/it/pagopa/selfcare/external_api/model/nationalRegistries/LegalVerification.java new file mode 100644 index 00000000..a583a43d --- /dev/null +++ b/connector-api/src/main/java/it/pagopa/selfcare/external_api/model/nationalRegistries/LegalVerification.java @@ -0,0 +1,10 @@ +package it.pagopa.selfcare.external_api.model.nationalRegistries; + +import lombok.Data; + +@Data +public class LegalVerification { + private String resultCode; + private String resultDetail; + private Boolean verificationResult; +} diff --git a/connector/rest/docs/openapi/api-selfcare-registry-proxy-docs.json b/connector/rest/docs/openapi/api-selfcare-registry-proxy-docs.json new file mode 100644 index 00000000..fb8510db --- /dev/null +++ b/connector/rest/docs/openapi/api-selfcare-registry-proxy-docs.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/connector/rest/pom.xml b/connector/rest/pom.xml index 73648e6a..40a91036 100644 --- a/connector/rest/pom.xml +++ b/connector/rest/pom.xml @@ -72,13 +72,6 @@ - - - - org.openapitools - openapi-generator-maven-plugin - 6.3.0 - selfcare-ms-onboarding @@ -111,13 +104,6 @@ - - - - org.openapitools - openapi-generator-maven-plugin - 6.3.0 - user-ms @@ -149,6 +135,37 @@ + + registry-proxy-ms + + generate + + process-resources + + ${project.basedir}/docs/openapi/api-selfcare-registry-proxy-docs.json + spring + spring-cloud + + false + false + + true + ${project.groupId}.registry-proxy.generated.openapi.v1 + ${project.groupId}.registry-proxy.generated.openapi.v1.dto + ${project.groupId}.registry-proxy.generated.openapi.v1.api + ${project.groupId}.registry-proxy.generated.openapi.v1.config + @lombok.Builder; @lombok.NoArgsConstructor; @lombok.AllArgsConstructor + java8-localdatetime + true + true + none + source + false + false + true + + + diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/external_api/connector/rest/MsPartyRegistryProxyConnectorImpl.java b/connector/rest/src/main/java/it/pagopa/selfcare/external_api/connector/rest/MsPartyRegistryProxyConnectorImpl.java index 5f8f6d61..5d0af32e 100644 --- a/connector/rest/src/main/java/it/pagopa/selfcare/external_api/connector/rest/MsPartyRegistryProxyConnectorImpl.java +++ b/connector/rest/src/main/java/it/pagopa/selfcare/external_api/connector/rest/MsPartyRegistryProxyConnectorImpl.java @@ -2,9 +2,15 @@ import it.pagopa.selfcare.external_api.api.MsPartyRegistryProxyConnector; import it.pagopa.selfcare.external_api.connector.rest.client.MsPartyRegistryProxyRestClient; +import it.pagopa.selfcare.external_api.connector.rest.client.MsRegistryProxyNationalRegistryRestClient; +import it.pagopa.selfcare.external_api.connector.rest.mapper.RegistryProxyMapper; import it.pagopa.selfcare.external_api.model.institutions.InstitutionResource; +import it.pagopa.selfcare.external_api.model.nationalRegistries.LegalVerification; +import it.pagopa.selfcare.registry_proxy.generated.openapi.v1.dto.LegalVerificationResult; import lombok.extern.slf4j.Slf4j; +import org.owasp.encoder.Encode; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.util.Assert; @@ -14,11 +20,17 @@ public class MsPartyRegistryProxyConnectorImpl implements MsPartyRegistryProxyCo private final MsPartyRegistryProxyRestClient restClient; + private final MsRegistryProxyNationalRegistryRestClient nationalRegistryRestClient; + + private final RegistryProxyMapper registryProxyMapper; + protected static final String EXTERNAL_INSTITUTION_ID_IS_REQUIRED = "An external institution Id is required "; @Autowired - public MsPartyRegistryProxyConnectorImpl(MsPartyRegistryProxyRestClient restClient) { + public MsPartyRegistryProxyConnectorImpl(MsPartyRegistryProxyRestClient restClient, MsRegistryProxyNationalRegistryRestClient nationalRegistryRestClient, RegistryProxyMapper registryProxyMapper) { this.restClient = restClient; + this.nationalRegistryRestClient = nationalRegistryRestClient; + this.registryProxyMapper = registryProxyMapper; } @Override @@ -32,4 +44,13 @@ public InstitutionResource findInstitution(String institutionExternalId) { return result; } + @Override + public LegalVerification verifyLegal(String taxId, String vatNumber){ + log.trace("verifyLegal start"); + log.debug("verifyLegal taxId = {}, vatNumber = {}", Encode.forJava(taxId), Encode.forJava(vatNumber)); + ResponseEntity legalVerificationResultResponseEntity = nationalRegistryRestClient._verifyLegalUsingGET(taxId, vatNumber); + log.trace("verifyLegal end"); + return registryProxyMapper.toLegalVerification(legalVerificationResultResponseEntity.getBody()); + } + } diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/external_api/connector/rest/client/MsRegistryProxyNationalRegistryRestClient.java b/connector/rest/src/main/java/it/pagopa/selfcare/external_api/connector/rest/client/MsRegistryProxyNationalRegistryRestClient.java new file mode 100644 index 00000000..746e8e8a --- /dev/null +++ b/connector/rest/src/main/java/it/pagopa/selfcare/external_api/connector/rest/client/MsRegistryProxyNationalRegistryRestClient.java @@ -0,0 +1,8 @@ +package it.pagopa.selfcare.external_api.connector.rest.client; + +import it.pagopa.selfcare.registry_proxy.generated.openapi.v1.api.NationalRegistriesApi; +import org.springframework.cloud.openfeign.FeignClient; + +@FeignClient(name = "${rest-client.ms-registry-proxy-national-registries.serviceCode}", url = "${rest-client.ms-party-registry-proxy.base-url}") +public interface MsRegistryProxyNationalRegistryRestClient extends NationalRegistriesApi { +} diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/external_api/connector/rest/config/MsPartyRegistryProxyRestClientConfig.java b/connector/rest/src/main/java/it/pagopa/selfcare/external_api/connector/rest/config/MsPartyRegistryProxyRestClientConfig.java index 53c0c70b..7ca4d898 100644 --- a/connector/rest/src/main/java/it/pagopa/selfcare/external_api/connector/rest/config/MsPartyRegistryProxyRestClientConfig.java +++ b/connector/rest/src/main/java/it/pagopa/selfcare/external_api/connector/rest/config/MsPartyRegistryProxyRestClientConfig.java @@ -10,6 +10,6 @@ @Configuration @Import(RestClientBaseConfig.class) @EnableFeignClients(clients = MsPartyRegistryProxyRestClient.class) -@PropertySource("classpath:config/ms-party-registry-proxy-client.properties") +@PropertySource("classpath:config/ms-party-registry-proxy-rest-client.properties") public class MsPartyRegistryProxyRestClientConfig { } diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/external_api/connector/rest/config/MsRegistryProxyNationalRegistriesClientConfig.java b/connector/rest/src/main/java/it/pagopa/selfcare/external_api/connector/rest/config/MsRegistryProxyNationalRegistriesClientConfig.java new file mode 100644 index 00000000..4af09f61 --- /dev/null +++ b/connector/rest/src/main/java/it/pagopa/selfcare/external_api/connector/rest/config/MsRegistryProxyNationalRegistriesClientConfig.java @@ -0,0 +1,15 @@ +package it.pagopa.selfcare.external_api.connector.rest.config; + +import it.pagopa.selfcare.commons.connector.rest.config.RestClientBaseConfig; +import it.pagopa.selfcare.external_api.connector.rest.client.MsRegistryProxyNationalRegistryRestClient; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.PropertySource; + +@Configuration +@Import(RestClientBaseConfig.class) +@EnableFeignClients(clients = {MsRegistryProxyNationalRegistryRestClient.class}) +@PropertySource("classpath:config/ms-party-registry-proxy-rest-client.properties") +public class MsRegistryProxyNationalRegistriesClientConfig { +} diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/external_api/connector/rest/mapper/RegistryProxyMapper.java b/connector/rest/src/main/java/it/pagopa/selfcare/external_api/connector/rest/mapper/RegistryProxyMapper.java new file mode 100644 index 00000000..d6ca6a88 --- /dev/null +++ b/connector/rest/src/main/java/it/pagopa/selfcare/external_api/connector/rest/mapper/RegistryProxyMapper.java @@ -0,0 +1,11 @@ +package it.pagopa.selfcare.external_api.connector.rest.mapper; + +import it.pagopa.selfcare.external_api.model.nationalRegistries.LegalVerification; +import it.pagopa.selfcare.registry_proxy.generated.openapi.v1.dto.LegalVerificationResult; +import org.mapstruct.Mapper; + +@Mapper(componentModel = "spring") +public interface RegistryProxyMapper { + + LegalVerification toLegalVerification(LegalVerificationResult model); +} diff --git a/connector/rest/src/main/resources/config/ms-party-registry-proxy-client.properties b/connector/rest/src/main/resources/config/ms-party-registry-proxy-rest-client.properties similarity index 78% rename from connector/rest/src/main/resources/config/ms-party-registry-proxy-client.properties rename to connector/rest/src/main/resources/config/ms-party-registry-proxy-rest-client.properties index 2f15823a..b173f7c5 100644 --- a/connector/rest/src/main/resources/config/ms-party-registry-proxy-client.properties +++ b/connector/rest/src/main/resources/config/ms-party-registry-proxy-rest-client.properties @@ -6,4 +6,8 @@ feign.client.config.ms-party-registry-proxy.errorDecoder=it.pagopa.selfcare.exte feign.client.config.ms-party-registry-proxy.requestInterceptors[0]=it.pagopa.selfcare.commons.connector.rest.interceptor.AuthorizationHeaderInterceptor feign.client.config.ms-party-registry-proxy.connectTimeout=${USERVICE_PARTY_REGISTRY_PROXY_CONNECT_TIMEOUT:${REST_CLIENT_CONNECT_TIMEOUT:5000}} feign.client.config.ms-party-registry-proxy.readTimeout=${USERVICE_PARTY_REGISTRY_PROXY_READ_TIMEOUT:${REST_CLIENT_READ_TIMEOUT:5000}} -feign.client.config.ms-party-registry-proxy.loggerLevel=${USERVICE_PARTY_REGISTRY_PROXY_LOGGER_LEVEL:${REST_CLIENT_LOGGER_LEVEL:FULL}} \ No newline at end of file +feign.client.config.ms-party-registry-proxy.loggerLevel=${USERVICE_PARTY_REGISTRY_PROXY_LOGGER_LEVEL:${REST_CLIENT_LOGGER_LEVEL:FULL}} + + +rest-client.ms-registry-proxy-national-registries.serviceCode=ms-registry-proxy-national-registries +feign.client.config.ms-registry-proxy-national-registries.requestInterceptors[0]=it.pagopa.selfcare.commons.connector.rest.interceptor.AuthorizationHeaderInterceptor diff --git a/connector/rest/src/test/java/it/pagopa/selfcare/external_api/connector/rest/MsPartyRegistryProxyConnectorImplTest.java b/connector/rest/src/test/java/it/pagopa/selfcare/external_api/connector/rest/MsPartyRegistryProxyConnectorImplTest.java index 1ed7d3db..e1fa1af3 100644 --- a/connector/rest/src/test/java/it/pagopa/selfcare/external_api/connector/rest/MsPartyRegistryProxyConnectorImplTest.java +++ b/connector/rest/src/test/java/it/pagopa/selfcare/external_api/connector/rest/MsPartyRegistryProxyConnectorImplTest.java @@ -2,20 +2,26 @@ import com.fasterxml.jackson.core.type.TypeReference; import it.pagopa.selfcare.external_api.connector.rest.client.MsPartyRegistryProxyRestClient; +import it.pagopa.selfcare.external_api.connector.rest.client.MsRegistryProxyNationalRegistryRestClient; import it.pagopa.selfcare.external_api.connector.rest.config.BaseConnectorTest; +import it.pagopa.selfcare.external_api.connector.rest.mapper.RegistryProxyMapperImpl; import it.pagopa.selfcare.external_api.model.institutions.InstitutionResource; +import it.pagopa.selfcare.external_api.model.nationalRegistries.LegalVerification; +import it.pagopa.selfcare.registry_proxy.generated.openapi.v1.dto.LegalVerificationResult; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Spy; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.core.io.ClassPathResource; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import java.io.IOException; import java.nio.file.Files; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) @@ -24,8 +30,13 @@ class MsPartyRegistryProxyConnectorImplTest extends BaseConnectorTest { @Mock private MsPartyRegistryProxyRestClient msPartyRegistryProxyRestClientMock; + @Mock + private MsRegistryProxyNationalRegistryRestClient msRegistryProxyNationalRegistryRestClient; + @InjectMocks private MsPartyRegistryProxyConnectorImpl msPartyRegistryProxyConnectorImplMock; + @Spy + private RegistryProxyMapperImpl registryProxyMapper; @Test void findInstitutionError(){ @@ -55,4 +66,21 @@ void findInstitutionOk() throws IOException { } + @Test + void verifyLegal(){ + //given + final String taxId = "taxId"; + final String vatNumber = "vatNumber"; + + when(msRegistryProxyNationalRegistryRestClient._verifyLegalUsingGET(anyString(), anyString())).thenReturn(new ResponseEntity<>( new LegalVerificationResult(), HttpStatus.OK)); + + //when + LegalVerification result = msPartyRegistryProxyConnectorImplMock.verifyLegal(taxId, vatNumber); + + //then + assertNotNull(result); + verify(msRegistryProxyNationalRegistryRestClient, times(1))._verifyLegalUsingGET(taxId, vatNumber); + + } + } diff --git a/connector/rest/src/test/java/it/pagopa/selfcare/external_api/connector/rest/client/MsPartyRegistryProxyRestClientTest.java b/connector/rest/src/test/java/it/pagopa/selfcare/external_api/connector/rest/client/MsPartyRegistryProxyRestClientTest.java index db690a63..b169d57e 100644 --- a/connector/rest/src/test/java/it/pagopa/selfcare/external_api/connector/rest/client/MsPartyRegistryProxyRestClientTest.java +++ b/connector/rest/src/test/java/it/pagopa/selfcare/external_api/connector/rest/client/MsPartyRegistryProxyRestClientTest.java @@ -1,7 +1,6 @@ package it.pagopa.selfcare.external_api.connector.rest.client; import com.github.tomakehurst.wiremock.junit5.WireMockExtension; -import feign.FeignException; import it.pagopa.selfcare.commons.connector.rest.BaseFeignRestClientTest; import it.pagopa.selfcare.commons.connector.rest.RestTestUtils; import it.pagopa.selfcare.external_api.connector.rest.config.MsPartyRegistryProxyRestClientTestConfig; @@ -24,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; @TestPropertySource( - locations = "classpath:config/ms-party-registry-proxy-client.properties", + locations = "classpath:config/ms-party-registry-proxy-rest-client.properties", properties = { "logging.level.it.pagopa.selfcare.external_api.connector.rest=DEBUG", "spring.application.name=selc-external-api-connector-rest", @@ -57,6 +56,7 @@ public void initialize(ConfigurableApplicationContext applicationContext) { @Autowired private MsPartyRegistryProxyRestClient restClient; + @Test void findInstitution_fullyValued() { //given diff --git a/core/src/main/java/it/pagopa/selfcare/external_api/core/InstitutionService.java b/core/src/main/java/it/pagopa/selfcare/external_api/core/InstitutionService.java index 0c17e8aa..86d0cd4e 100644 --- a/core/src/main/java/it/pagopa/selfcare/external_api/core/InstitutionService.java +++ b/core/src/main/java/it/pagopa/selfcare/external_api/core/InstitutionService.java @@ -3,6 +3,7 @@ import it.pagopa.selfcare.external_api.model.institutions.GeographicTaxonomy; import it.pagopa.selfcare.external_api.model.institutions.Institution; import it.pagopa.selfcare.external_api.model.institutions.SearchMode; +import it.pagopa.selfcare.external_api.model.nationalRegistries.LegalVerification; import it.pagopa.selfcare.external_api.model.pnpg.CreatePnPgInstitution; import it.pagopa.selfcare.external_api.model.user.UserInfo; import it.pagopa.selfcare.product.entity.Product; @@ -24,4 +25,6 @@ public interface InstitutionService { Collection getInstitutionsByGeoTaxonomies(Set geoTaxIds, SearchMode searchMode); String addInstitution(CreatePnPgInstitution request); + + LegalVerification verifyLegal(String taxId, String vatNumber); } diff --git a/core/src/main/java/it/pagopa/selfcare/external_api/core/InstitutionServiceImpl.java b/core/src/main/java/it/pagopa/selfcare/external_api/core/InstitutionServiceImpl.java index ff2632bd..5d71f51f 100644 --- a/core/src/main/java/it/pagopa/selfcare/external_api/core/InstitutionServiceImpl.java +++ b/core/src/main/java/it/pagopa/selfcare/external_api/core/InstitutionServiceImpl.java @@ -4,18 +4,17 @@ import it.pagopa.selfcare.commons.base.security.PartyRole; import it.pagopa.selfcare.commons.base.security.SelfCareAuthority; import it.pagopa.selfcare.commons.base.security.SelfCareUser; -import it.pagopa.selfcare.external_api.api.MsCoreConnector; -import it.pagopa.selfcare.external_api.api.ProductsConnector; -import it.pagopa.selfcare.external_api.api.UserMsConnector; -import it.pagopa.selfcare.external_api.api.UserRegistryConnector; +import it.pagopa.selfcare.external_api.api.*; import it.pagopa.selfcare.external_api.exceptions.ResourceNotFoundException; import it.pagopa.selfcare.external_api.model.institutions.GeographicTaxonomy; import it.pagopa.selfcare.external_api.model.institutions.Institution; import it.pagopa.selfcare.external_api.model.institutions.SearchMode; +import it.pagopa.selfcare.external_api.model.nationalRegistries.LegalVerification; import it.pagopa.selfcare.external_api.model.pnpg.CreatePnPgInstitution; import it.pagopa.selfcare.external_api.model.user.*; import it.pagopa.selfcare.product.entity.Product; import lombok.extern.slf4j.Slf4j; +import org.owasp.encoder.Encode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.security.core.Authentication; @@ -44,15 +43,18 @@ class InstitutionServiceImpl implements InstitutionService { private static final String TAG_LOG_INSTITUTION_USER_PRODUCTS = "getInstitutionUserProducts"; private final Set serviceType; + private final MsPartyRegistryProxyConnector msPartyRegistryProxyConnector; + @Autowired InstitutionServiceImpl(ProductsConnector productsConnector, MsCoreConnector msCoreConnector, UserRegistryConnector userRegistryConnector, - UserMsConnector userMsConnector, @Value("${external_api.allowed-service-types}")String[] serviceType) { + UserMsConnector userMsConnector, @Value("${external_api.allowed-service-types}")String[] serviceType, MsPartyRegistryProxyConnector msPartyRegistryProxyConnector) { this.productsConnector = productsConnector; this.msCoreConnector = msCoreConnector; this.userRegistryConnector = userRegistryConnector; this.userMsConnector = userMsConnector; this.serviceType = Set.of(serviceType); + this.msPartyRegistryProxyConnector = msPartyRegistryProxyConnector; } @@ -199,4 +201,13 @@ public String addInstitution(CreatePnPgInstitution request) { return institutionInternalId; } + @Override + public LegalVerification verifyLegal(String taxId, String vatNumber) { + log.trace("verifyLegal start"); + log.debug("verifyLegal taxId = {}, vatNumber = {}", Encode.forJava(taxId), Encode.forJava(vatNumber)); + LegalVerification legalVerification = msPartyRegistryProxyConnector.verifyLegal(taxId, vatNumber); + log.trace("verifyLegal end"); + return legalVerification; + } + } diff --git a/core/src/test/java/it/pagopa/selfcare/external_api/core/InstitutionServiceImplTest.java b/core/src/test/java/it/pagopa/selfcare/external_api/core/InstitutionServiceImplTest.java index 1edade7c..df7e5319 100644 --- a/core/src/test/java/it/pagopa/selfcare/external_api/core/InstitutionServiceImplTest.java +++ b/core/src/test/java/it/pagopa/selfcare/external_api/core/InstitutionServiceImplTest.java @@ -3,14 +3,12 @@ import com.fasterxml.jackson.core.type.TypeReference; import it.pagopa.selfcare.commons.base.security.PartyRole; import it.pagopa.selfcare.commons.base.security.SelfCareUser; -import it.pagopa.selfcare.external_api.api.MsCoreConnector; -import it.pagopa.selfcare.external_api.api.ProductsConnector; -import it.pagopa.selfcare.external_api.api.UserMsConnector; -import it.pagopa.selfcare.external_api.api.UserRegistryConnector; +import it.pagopa.selfcare.external_api.api.*; import it.pagopa.selfcare.external_api.exceptions.ResourceNotFoundException; import it.pagopa.selfcare.external_api.model.institutions.GeographicTaxonomy; import it.pagopa.selfcare.external_api.model.institutions.Institution; import it.pagopa.selfcare.external_api.model.institutions.SearchMode; +import it.pagopa.selfcare.external_api.model.nationalRegistries.LegalVerification; import it.pagopa.selfcare.external_api.model.pnpg.CreatePnPgInstitution; import it.pagopa.selfcare.external_api.model.product.PartyProduct; import it.pagopa.selfcare.external_api.model.product.ProductOnboardingStatus; @@ -37,9 +35,9 @@ import java.nio.file.Files; import java.util.*; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.*; @ExtendWith({SpringExtension.class}) @ContextConfiguration(classes = InstitutionServiceImpl.class) @@ -61,6 +59,9 @@ class InstitutionServiceImplTest extends BaseServiceTestUtils { @MockBean private UserMsConnector userMsConnectorMock; + @MockBean + private MsPartyRegistryProxyConnector registryProxyConnector; + @BeforeEach public void setUp() { super.setUp(); @@ -335,6 +336,22 @@ void addInstitutionNotExists() { Mockito.verify(msCoreConnectorMock, Mockito.times(1)).createPnPgInstitution(createPnPgInstitution); } + @Test + void verifyLegal(){ + final String taxId = "taxId"; + final String vatNumber = "vatNumber"; + + when(registryProxyConnector.verifyLegal(anyString(), anyString())).thenReturn(new LegalVerification()); + + //when + LegalVerification result = institutionService.verifyLegal(taxId, vatNumber); + + //then + assertNotNull(result); + verify(registryProxyConnector, times(1)).verifyLegal(taxId, vatNumber); + + } + private Product createDummyProduct(int bias){ Product product = new Product(); product.setId("id"+bias); diff --git a/pom.xml b/pom.xml index f44a5a8f..14e475bb 100644 --- a/pom.xml +++ b/pom.xml @@ -103,6 +103,12 @@ test-jar test + + org.owasp.encoder + encoder + 1.2.3 + compile + core diff --git a/web/src/main/java/it/pagopa/selfcare/external_api/web/controller/NationalRegistryController.java b/web/src/main/java/it/pagopa/selfcare/external_api/web/controller/NationalRegistryController.java new file mode 100644 index 00000000..1ef15021 --- /dev/null +++ b/web/src/main/java/it/pagopa/selfcare/external_api/web/controller/NationalRegistryController.java @@ -0,0 +1,44 @@ +package it.pagopa.selfcare.external_api.web.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.tags.Tags; +import it.pagopa.selfcare.external_api.core.InstitutionService; +import it.pagopa.selfcare.external_api.model.nationalRegistries.LegalVerification; +import it.pagopa.selfcare.external_api.web.model.mapper.NationalRegistryMapper; +import it.pagopa.selfcare.external_api.web.model.national_registries.LegalVerificationResource; +import it.pagopa.selfcare.external_api.web.model.national_registries.VerifyRequestDto; +import lombok.extern.slf4j.Slf4j; +import org.owasp.encoder.Encode; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +@Slf4j +@RestController +@Api(tags = "national-registries") +@RequestMapping(value = "/v2/national-registries", produces = MediaType.APPLICATION_JSON_VALUE) +public class NationalRegistryController { + private final InstitutionService institutionService; + private final NationalRegistryMapper nationalRegistryMapper; + + public NationalRegistryController(InstitutionService institutionService, NationalRegistryMapper nationalRegistryMapper) { + this.institutionService = institutionService; + this.nationalRegistryMapper = nationalRegistryMapper; + } + + @Tags({@Tag(name = "external-v2"), @Tag(name = "national-registries")}) + @PostMapping(value = "/legal-tax/verification", consumes = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.OK) + @ApiOperation(value = "", notes = "${swagger.external-api.national-registries.api.verifyLegal}", nickname = "verifyLegalByPOST") + public LegalVerificationResource verifyLegal(@RequestBody @Valid VerifyRequestDto requestDto){ + log.trace("verifyLegal start"); + log.debug("verifyLegal taxId = {}, vatNumber = {}", Encode.forJava(requestDto.getTaxId()), Encode.forJava(requestDto.getVatNumber())); + LegalVerification legalVerification = institutionService.verifyLegal(requestDto.getTaxId(), requestDto.getVatNumber()); + log.trace("verifyLegal end"); + return nationalRegistryMapper.toResource(legalVerification); + } +} diff --git a/web/src/main/java/it/pagopa/selfcare/external_api/web/model/mapper/NationalRegistryMapper.java b/web/src/main/java/it/pagopa/selfcare/external_api/web/model/mapper/NationalRegistryMapper.java new file mode 100644 index 00000000..45da9929 --- /dev/null +++ b/web/src/main/java/it/pagopa/selfcare/external_api/web/model/mapper/NationalRegistryMapper.java @@ -0,0 +1,10 @@ +package it.pagopa.selfcare.external_api.web.model.mapper; + +import it.pagopa.selfcare.external_api.model.nationalRegistries.LegalVerification; +import it.pagopa.selfcare.external_api.web.model.national_registries.LegalVerificationResource; +import org.mapstruct.Mapper; + +@Mapper(componentModel = "spring") +public interface NationalRegistryMapper { + LegalVerificationResource toResource(LegalVerification model); +} diff --git a/web/src/main/java/it/pagopa/selfcare/external_api/web/model/national_registries/LegalVerificationResource.java b/web/src/main/java/it/pagopa/selfcare/external_api/web/model/national_registries/LegalVerificationResource.java new file mode 100644 index 00000000..150d441c --- /dev/null +++ b/web/src/main/java/it/pagopa/selfcare/external_api/web/model/national_registries/LegalVerificationResource.java @@ -0,0 +1,10 @@ +package it.pagopa.selfcare.external_api.web.model.national_registries; + +import lombok.Data; + +@Data +public class LegalVerificationResource { + private String resultCode; + private String resultDetail; + private Boolean verificationResult; +} diff --git a/web/src/main/java/it/pagopa/selfcare/external_api/web/model/national_registries/VerifyRequestDto.java b/web/src/main/java/it/pagopa/selfcare/external_api/web/model/national_registries/VerifyRequestDto.java new file mode 100644 index 00000000..fbcc0908 --- /dev/null +++ b/web/src/main/java/it/pagopa/selfcare/external_api/web/model/national_registries/VerifyRequestDto.java @@ -0,0 +1,20 @@ +package it.pagopa.selfcare.external_api.web.model.national_registries; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class VerifyRequestDto { + @JsonProperty(required = true) + @NotBlank + private String taxId; + @JsonProperty(required = true) + @NotBlank + private String vatNumber; +} diff --git a/web/src/main/resources/swagger/swagger_en.properties b/web/src/main/resources/swagger/swagger_en.properties index 4a1b26f1..cff3793b 100644 --- a/web/src/main/resources/swagger/swagger_en.properties +++ b/web/src/main/resources/swagger/swagger_en.properties @@ -144,4 +144,5 @@ swagger.external_api.api.tokens.findFromProduct=Service to retrieve tokens from swagger.external_api.api.tokens.productId=Product's identifier swagger.external_api.page.size=Number of elements per page swagger.external_api.page.number=Number of page -swagger.mscore.onboarding.users=Api to persist users to product \ No newline at end of file +swagger.mscore.onboarding.users=Api to persist users to product +swagger.external-api.national-registries.api.verifyLegal=Verify if given taxId is legal of given institution identified with vatNumber \ No newline at end of file diff --git a/web/src/test/java/it/pagopa/selfcare/external_api/web/controller/NationalRegistriesControllerTest.java b/web/src/test/java/it/pagopa/selfcare/external_api/web/controller/NationalRegistriesControllerTest.java new file mode 100644 index 00000000..36695717 --- /dev/null +++ b/web/src/test/java/it/pagopa/selfcare/external_api/web/controller/NationalRegistriesControllerTest.java @@ -0,0 +1,72 @@ +package it.pagopa.selfcare.external_api.web.controller; + +import com.fasterxml.jackson.core.type.TypeReference; +import it.pagopa.selfcare.external_api.core.InstitutionService; +import it.pagopa.selfcare.external_api.model.nationalRegistries.LegalVerification; +import it.pagopa.selfcare.external_api.web.model.mapper.NationalRegistryMapper; +import it.pagopa.selfcare.external_api.web.model.mapper.NationalRegistryMapperImpl; +import it.pagopa.selfcare.external_api.web.model.national_registries.VerifyRequestDto; +import org.apache.commons.lang3.StringUtils; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.core.io.ClassPathResource; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import java.nio.file.Files; + +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@ExtendWith(MockitoExtension.class) +public class NationalRegistriesControllerTest extends BaseControllerTest { + private static final String BASE_URL = "/v2/national-registries"; + + @InjectMocks + private NationalRegistryController nationalRegistryController; + @Mock + private InstitutionService institutionService; + @Spy + private NationalRegistryMapper nationalRegistryMapper = new NationalRegistryMapperImpl(); + + @BeforeEach + void setUp(){super.setUp(nationalRegistryController);} + + + @Test + public void verifyLegal() throws Exception{ + ClassPathResource inputResource = new ClassPathResource("expectations/LegalVerify.json"); + byte[] legalVerifyStream = Files.readAllBytes(inputResource.getFile().toPath()); + LegalVerification legalVerification = objectMapper.readValue(legalVerifyStream, new TypeReference<>() {}); + ClassPathResource outputResource = new ClassPathResource("expectations/LegalVerify.json"); + String expectedResource = StringUtils.deleteWhitespace(new String(Files.readAllBytes(outputResource.getFile().toPath()))); + final String taxId = "taxId"; + final String vatNumber = "vatNumber"; + + VerifyRequestDto verifyRequestDto = new VerifyRequestDto(taxId, vatNumber); + when(institutionService.verifyLegal(anyString(), anyString())).thenReturn(legalVerification); + + mockMvc.perform(MockMvcRequestBuilders + .post(BASE_URL+"/legal-tax/verification") + .content(objectMapper.writeValueAsString(verifyRequestDto)) + .contentType(APPLICATION_JSON_VALUE) + .accept(APPLICATION_JSON_VALUE)) + .andExpect(content().string(expectedResource)) + .andExpect(status().isOk()) + .andReturn(); + + verify(institutionService, times(1)).verifyLegal(taxId, vatNumber); + } + + + + + +} diff --git a/web/src/test/resources/expectations/LegalVerify.json b/web/src/test/resources/expectations/LegalVerify.json new file mode 100644 index 00000000..9443130a --- /dev/null +++ b/web/src/test/resources/expectations/LegalVerify.json @@ -0,0 +1,5 @@ +{ + "resultCode": "resultCode", + "resultDetail": "resultDetail", + "verificationResult": true +} \ No newline at end of file