From c117ad69b84a56993d0865087b4ee2eec804e1da Mon Sep 17 00:00:00 2001 From: Pasquale Spica <36746022+pasqualespica@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:08:49 +0100 Subject: [PATCH] feat: Add toPublish (#56) * add-toPublish-and-fix-apim * fix: Add param toPublish API create debt positions --------- Co-authored-by: svariant --- infra/04_apim_api.tf | 2 +- infra/policy/_base_policy.xml | 2 +- .../pagopa/spontaneouspayment/service/PaymentsService.java | 2 +- .../pagopa/spontaneouspayment/service/client/GpdClient.java | 4 +++- .../spontaneouspayment/service/PaymentsServiceTest.java | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/infra/04_apim_api.tf b/infra/04_apim_api.tf index 24a6cbe..1593fcb 100644 --- a/infra/04_apim_api.tf +++ b/infra/04_apim_api.tf @@ -3,7 +3,7 @@ locals { display_name = "pagopa-spontaneous-payments" description = "App for handling the spontaneous payments" - path = "gps/spontaneous-payments-service/v1" + path = "spontaneous-payments-service" host = "api.${var.apim_dns_zone_prefix}.${var.external_domain}" hostname = var.hostname diff --git a/infra/policy/_base_policy.xml b/infra/policy/_base_policy.xml index 1bf5f39..45bfc74 100644 --- a/infra/policy/_base_policy.xml +++ b/infra/policy/_base_policy.xml @@ -1,7 +1,7 @@ - + diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/service/PaymentsService.java b/src/main/java/it/gov/pagopa/spontaneouspayment/service/PaymentsService.java index 3d250c2..b4cf29b 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/service/PaymentsService.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/service/PaymentsService.java @@ -172,7 +172,7 @@ private PaymentPositionModel createDebtPosition(String organizationFiscalCode, pp.setSwitchToExpired(enrollment.isSwitchToExpired()); pp.addPaymentOptions(po); - PaymentPositionModel gpdResponse = gpdClient.createDebtPosition(organizationFiscalCode, pp); + PaymentPositionModel gpdResponse = gpdClient.createDebtPosition(organizationFiscalCode, pp, true); // Forced set fiscal code -> https://editor.swagger.io/?url=https://raw.githubusercontent.com/pagopa/pagopa-debt-position/main/openapi/openapi_internal.json gpdResponse.getPaymentOption().get(0).setOrganizationFiscalCode(organizationFiscalCode); diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/service/client/GpdClient.java b/src/main/java/it/gov/pagopa/spontaneouspayment/service/client/GpdClient.java index 30eaee2..b2a11d4 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/service/client/GpdClient.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/service/client/GpdClient.java @@ -10,6 +10,7 @@ import feign.FeignException; import it.gov.pagopa.spontaneouspayment.config.FeignConfig; import it.gov.pagopa.spontaneouspayment.model.response.PaymentPositionModel; +import org.springframework.web.bind.annotation.RequestParam; @FeignClient(value = "gpd", url = "${service.gpd.host}", configuration = FeignConfig.class) @@ -19,6 +20,7 @@ public interface GpdClient { backoff = @Backoff(delayExpression = "${retry.gpd.maxDelay}")) @PostMapping(value = "/organizations/{organizationfiscalcode}/debtpositions") PaymentPositionModel createDebtPosition(@PathVariable("organizationfiscalcode") String organizationFiscalCode, - @RequestBody PaymentPositionModel paymentPositionModel); + @RequestBody PaymentPositionModel paymentPositionModel, + @RequestParam Boolean toPublish); } diff --git a/src/test/java/it/gov/pagopa/spontaneouspayment/service/PaymentsServiceTest.java b/src/test/java/it/gov/pagopa/spontaneouspayment/service/PaymentsServiceTest.java index 06055cf..0cc8ff9 100644 --- a/src/test/java/it/gov/pagopa/spontaneouspayment/service/PaymentsServiceTest.java +++ b/src/test/java/it/gov/pagopa/spontaneouspayment/service/PaymentsServiceTest.java @@ -230,7 +230,7 @@ void createSpontaneousPayment() throws IOException { when(iuvGeneratorClient.generateIUV(anyString(), any(IuvGenerationModel.class))) .thenReturn(IuvGenerationModelResponse.builder().iuv("12345678901234567").build()); - when(gpdClient.createDebtPosition(anyString(), any(PaymentPositionModel.class))).thenReturn(paymentModel); + when(gpdClient.createDebtPosition(anyString(), any(PaymentPositionModel.class), any(Boolean.class))).thenReturn(paymentModel); ArrayList paymentOption = new ArrayList<>(); paymentOption.add(getMockPaymentOptionModel());