Skip to content

Commit

Permalink
Merge pull request #262 from pagopa/PAGOPA-1298-fiscal-code-filter
Browse files Browse the repository at this point in the history
feat: [PAGOPA-1298] fiscal code filter
  • Loading branch information
cap-ang authored Oct 26, 2023
2 parents f686328 + de69b0d commit 0878975
Show file tree
Hide file tree
Showing 14 changed files with 18,960 additions and 20,250 deletions.
27,200 changes: 12,920 additions & 14,280 deletions openapi/openapi.json

Large diffs are not rendered by default.

11,892 changes: 5,961 additions & 5,931 deletions openapi/openapi_auth.json

Large diffs are not rendered by default.

28 changes: 25 additions & 3 deletions openapi/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"version": "0.54.1"
},
"host": "localhost:8080",
"basePath": "/",
"basePath": "/apiconfig/api/v1",
"schemes": [
"http"
],
Expand Down Expand Up @@ -7101,8 +7101,8 @@
},
"get": {
"produces": [
"application/xml",
"application/json"
"application/json",
"application/xml"
],
"parameters": [
{
Expand Down Expand Up @@ -10751,6 +10751,13 @@
"required": false,
"type": "string"
},
{
"description": "Filter by tax code",
"in": "query",
"name": "taxCode",
"required": false,
"type": "string"
},
{
"default": "CODE",
"description": "Order by code or name",
Expand Down Expand Up @@ -12246,6 +12253,18 @@
"schema": {
"$ref": "#/definitions/ProblemJson"
}
},
"504": {
"description": "Gateway Timeout",
"headers": {
"X-Request-Id": {
"description": "This header identifies the call",
"type": "string"
}
},
"schema": {
"$ref": "#/definitions/ProblemJson"
}
}
},
"security": [
Expand Down Expand Up @@ -14844,6 +14863,9 @@
"psp_code": {
"pattern": "[A-Z0-9_]{6,14}",
"type": "string"
},
"tax_code": {
"type": "string"
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
package it.gov.pagopa.apiconfig.core.controller;

import static it.gov.pagopa.apiconfig.core.util.CommonUtil.getFilterAndOrder;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import it.gov.pagopa.apiconfig.core.model.ProblemJson;
import it.gov.pagopa.apiconfig.core.model.filterandorder.Order;
import it.gov.pagopa.apiconfig.core.model.psp.PaymentServiceProviderDetails;
import it.gov.pagopa.apiconfig.core.model.psp.PaymentServiceProviders;
import it.gov.pagopa.apiconfig.core.model.psp.PaymentServiceProvidersView;
import it.gov.pagopa.apiconfig.core.model.psp.PspChannelCode;
import it.gov.pagopa.apiconfig.core.model.psp.PspChannelList;
import it.gov.pagopa.apiconfig.core.model.psp.PspChannelPaymentTypes;
import it.gov.pagopa.apiconfig.core.service.PspService;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Positive;
import javax.validation.constraints.PositiveOrZero;
import javax.validation.constraints.Size;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus;
Expand All @@ -42,6 +24,26 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import it.gov.pagopa.apiconfig.core.model.ProblemJson;
import it.gov.pagopa.apiconfig.core.model.filterandorder.FilterAndOrder;
import it.gov.pagopa.apiconfig.core.model.filterandorder.Order;
import it.gov.pagopa.apiconfig.core.model.psp.PaymentServiceProviderDetails;
import it.gov.pagopa.apiconfig.core.model.psp.PaymentServiceProviders;
import it.gov.pagopa.apiconfig.core.model.psp.PaymentServiceProvidersView;
import it.gov.pagopa.apiconfig.core.model.psp.PspChannelCode;
import it.gov.pagopa.apiconfig.core.model.psp.PspChannelList;
import it.gov.pagopa.apiconfig.core.model.psp.PspChannelPaymentTypes;
import it.gov.pagopa.apiconfig.core.service.PspService;
import it.gov.pagopa.apiconfig.core.util.CommonUtil;

@RestController()
@RequestMapping(path = "/paymentserviceproviders")
@Tag(name = "Payment Service Providers", description = "Everything about Payment Service Providers")
Expand Down Expand Up @@ -111,15 +113,19 @@ public ResponseEntity<PaymentServiceProviders> getPaymentServiceProviders(
String filterByCode,
@RequestParam(required = false, name = "name") @Parameter(description = "Filter by name")
String filterByName,
@RequestParam(required = false, name = "taxCode") @Parameter(description = "Filter by tax code")
String filterByTaxCode,
@RequestParam(required = false, name = "orderby", defaultValue = "CODE")
@Parameter(description = "Order by code or name")
Order.Psp orderBy,
@RequestParam(required = false, name = "ordering", defaultValue = "DESC")
@Parameter(description = "Direction of ordering")
Sort.Direction ordering) {
FilterAndOrder filterAndOrder = CommonUtil.getFilterAndOrder(filterByCode, filterByName, orderBy, ordering);
filterAndOrder.getFilter().setTaxCode(filterByTaxCode);
return ResponseEntity.ok(
pspService.getPaymentServiceProviders(
limit, page, getFilterAndOrder(filterByCode, filterByName, orderBy, ordering)));
limit, page, filterAndOrder));
}

@Operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public PaymentServiceProvider convert(MappingContext<Psp, PaymentServiceProvider
.pspCode(source.getIdPsp())
.enabled(source.getEnabled())
.businessName(CommonUtil.deNull(source.getRagioneSociale()))
.taxCode(CommonUtil.deNull(source.getCodiceFiscale()))
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

import org.springframework.lang.Nullable;

@Getter
@Setter
@AllArgsConstructor
@Builder
public class Filter {
@Nullable private String code;

@Nullable private String name;
@Nullable private String taxCode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ public class PaymentServiceProvider {
@Schema(required = true)
@NotNull
private String businessName;

@JsonProperty("tax_code")
private String taxCode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ public class PaymentServiceProviderDetails extends PaymentServiceProvider {
@Builder.Default
private Boolean agidPsp = false;

@JsonProperty("tax_code")
private String taxCode;

@JsonProperty("vat_number")
private String vatNumber;
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public PaymentServiceProviders getPaymentServiceProviders(
Psp.builder()
.idPsp(filterAndOrder.getFilter().getCode())
.ragioneSociale(filterAndOrder.getFilter().getName())
.codiceFiscale(filterAndOrder.getFilter().getTaxCode())
.build());
Page<Psp> page = pspRepository.findAll(filters, pageable);
return PaymentServiceProviders.builder()
Expand Down
21 changes: 12 additions & 9 deletions src/main/java/it/gov/pagopa/apiconfig/core/util/CommonUtil.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
package it.gov.pagopa.apiconfig.core.util;

import it.gov.pagopa.apiconfig.core.exception.AppError;
import it.gov.pagopa.apiconfig.core.exception.AppException;
import it.gov.pagopa.apiconfig.core.model.CheckItem;
import it.gov.pagopa.apiconfig.core.model.PageInfo;
import it.gov.pagopa.apiconfig.core.model.filterandorder.Filter;
import it.gov.pagopa.apiconfig.core.model.filterandorder.FilterAndOrder;
import it.gov.pagopa.apiconfig.core.model.filterandorder.Order;
import it.gov.pagopa.apiconfig.core.model.filterandorder.OrderType;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
Expand All @@ -20,6 +12,7 @@
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
Expand All @@ -30,14 +23,24 @@
import javax.xml.transform.stax.StAXSource;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import lombok.experimental.UtilityClass;

import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort;
import org.springframework.web.multipart.MultipartFile;
import org.xml.sax.SAXException;

import it.gov.pagopa.apiconfig.core.exception.AppError;
import it.gov.pagopa.apiconfig.core.exception.AppException;
import it.gov.pagopa.apiconfig.core.model.CheckItem;
import it.gov.pagopa.apiconfig.core.model.PageInfo;
import it.gov.pagopa.apiconfig.core.model.filterandorder.Filter;
import it.gov.pagopa.apiconfig.core.model.filterandorder.FilterAndOrder;
import it.gov.pagopa.apiconfig.core.model.filterandorder.Order;
import it.gov.pagopa.apiconfig.core.model.filterandorder.OrderType;
import lombok.experimental.UtilityClass;

@UtilityClass
public class CommonUtil {

Expand Down
1 change: 1 addition & 0 deletions src/test/java/it/gov/pagopa/apiconfig/TestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ public static PaymentServiceProvider getMockPaymentServiceProvider() {
.businessName("ciao")
.enabled(true)
.pspCode("12345ABC12345")
.taxCode("17103880000")
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ void setUp() {
"/paymentserviceproviders/1234ABC12345",
"/paymentserviceproviders/1234ABC12345/channels",
"/paymentserviceproviders/view?page=0",
"/paymentserviceproviders/view?page=0&pspCode=BPPIITRRHHH"
"/paymentserviceproviders/view?page=0&pspCode=BPPIITRRHHH",
"/paymentserviceproviders/view?page=0&pspCode=BPPIITRRHHH&taxCode=AAABBB000X1A"
})
void getPsp(String url) throws Exception {
mvc.perform(get(url).contentType(MediaType.APPLICATION_JSON))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"psp_code": "50",
"enabled": true,
"business_name": "Poste Italiane"
"business_name": "Poste Italiane",
"tax_code":"AAABBB000X1A"
}
],
"page_info": {
Expand Down
3 changes: 2 additions & 1 deletion src/test/resources/response/get_psp_brokerpsp.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"psp_code": "50",
"enabled": true,
"business_name": "Poste Italiane"
"business_name": "Poste Italiane",
"tax_code":"AAABBB000X1A"
}
],
"page_info": {
Expand Down

0 comments on commit 0878975

Please sign in to comment.