From 492b8e4a1cb4dd1f21af17f466f361b859781973 Mon Sep 17 00:00:00 2001 From: aacitelli Date: Mon, 20 Jun 2022 14:40:51 +0200 Subject: [PATCH 01/16] [PPD-206] crud gps: added enrollments api (no business code) --- .../controller/IEnrollmentsController.java | 127 ++++++++++++++++++ .../impl/EnrollmentsController.java | 61 +++++++++ .../model/EnrollmentModel.java | 20 +++ .../model/OrganizationEnrollmentModel.java | 24 ++++ .../model/OrganizationModel.java | 20 +++ .../model/enumeration/Status.java | 5 + .../response/EnrollmentModelResponse.java | 27 ++++ .../response/OrganizationModelResponse.java | 39 ++++++ src/main/resources/application-dev.properties | 28 ++++ .../resources/application-local.properties | 5 +- 10 files changed, 352 insertions(+), 4 deletions(-) create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/controller/IEnrollmentsController.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/EnrollmentsController.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/model/EnrollmentModel.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationEnrollmentModel.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationModel.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/model/enumeration/Status.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/model/response/EnrollmentModelResponse.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/model/response/OrganizationModelResponse.java create mode 100644 src/main/resources/application-dev.properties diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IEnrollmentsController.java b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IEnrollmentsController.java new file mode 100644 index 0000000..904d5b3 --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IEnrollmentsController.java @@ -0,0 +1,127 @@ +package it.gov.pagopa.spontaneouspayment.controller; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; + +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.spontaneouspayment.model.EnrollmentModel; +import it.gov.pagopa.spontaneouspayment.model.OrganizationEnrollmentModel; +import it.gov.pagopa.spontaneouspayment.model.OrganizationModel; +import it.gov.pagopa.spontaneouspayment.model.ProblemJson; +import it.gov.pagopa.spontaneouspayment.model.response.EnrollmentModelResponse; +import it.gov.pagopa.spontaneouspayment.model.response.OrganizationModelResponse; + + +@Tag(name = "Enrollments API") +@RequestMapping +@Validated +public interface IEnrollmentsController { + + @Operation(summary = "The organization creates a creditor institution with its subscription to the 1st service.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "createECAndFirstServiceEnrollment") + @ApiResponses(value = { + @ApiResponse(responseCode = "201", description = "Request created.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "OrganizationModelResponse", implementation = OrganizationModelResponse.class))), + @ApiResponse(responseCode = "400", description = "Malformed request.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())), + @ApiResponse(responseCode = "404", description = "Not Found the enroll service.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))}) + @PostMapping(value = "/organizations/{organizationFiscalCode}/services/{serviceId}", + produces = MediaType.APPLICATION_JSON_VALUE, + consumes = MediaType.APPLICATION_JSON_VALUE) + ResponseEntity createECAndFirstServiceEnrollment( + @Parameter(description = "The fiscal code of the Organization.", required = true) + @NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode, + @Parameter(description = "The service id to enroll.", required = true) + @NotBlank @PathVariable("serviceId") String serviceId, + @Valid @RequestBody OrganizationEnrollmentModel organizationEnrollmentModel); + + @Operation(summary = "The organization updates the enrollment to service for the creditor institution.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "updateECEnrollment") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Request updated.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "OrganizationModelResponse", implementation = OrganizationModelResponse.class))), + @ApiResponse(responseCode = "400", description = "Malformed request.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())), + @ApiResponse(responseCode = "404", description = "Not Found the creditor institution or the enroll service.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))}) + @PutMapping(value = "/organizations/{organizationFiscalCode}/services/{serviceId}", + produces = MediaType.APPLICATION_JSON_VALUE, + consumes = MediaType.APPLICATION_JSON_VALUE) + ResponseEntity updateECEnrollment( + @Parameter(description = "The fiscal code of the Organization.", required = true) + @NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode, + @Parameter(description = "The service id to enroll.", required = true) + @NotBlank @PathVariable("serviceId") String serviceId, + @Valid @RequestBody EnrollmentModel enrollmentModel); + + @Operation(summary = "The organization updates the creditor institution.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "updateEC") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Request updated.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "OrganizationModelResponse", implementation = OrganizationModelResponse.class))), + @ApiResponse(responseCode = "400", description = "Malformed request.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())), + @ApiResponse(responseCode = "404", description = "Not Found the creditor institution.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))}) + @PutMapping(value = "/organizations/{organizationFiscalCode}", + produces = MediaType.APPLICATION_JSON_VALUE, + consumes = MediaType.APPLICATION_JSON_VALUE) + ResponseEntity updateEC( + @Parameter(description = "The fiscal code of the Organization.", required = true) + @NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode, + @Valid @RequestBody OrganizationModel organizationModel); + + @Operation(summary = "The organization deletes the enrollment to service for the creditor institution.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "deleteECEnrollment") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Request deleted."), + @ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())), + @ApiResponse(responseCode = "404", description = "Not Found the creditor institution or the enroll service.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))}) + @DeleteMapping(value = "/organizations/{organizationFiscalCode}/services/{serviceId}", + produces = MediaType.APPLICATION_JSON_VALUE, + consumes = MediaType.APPLICATION_JSON_VALUE) + ResponseEntity deleteECEnrollment( + @Parameter(description = "The fiscal code of the Organization.", required = true) + @NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode, + @Parameter(description = "The service id to enroll.", required = true) + @NotBlank @PathVariable("serviceId") String serviceId); + + @Operation(summary = "Return the single enrollment to a service.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "getSingleEnrollment") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Obtained single enrollment.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "EnrollmentModelResponse", implementation = EnrollmentModelResponse.class))), + @ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())), + @ApiResponse(responseCode = "404", description = "No payment option found.", content = @Content(schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))}) + @GetMapping(value = "/organizations/{organizationFiscalCode}/services/{serviceId}", + produces = {"application/json"}) + ResponseEntity getSingleEnrollment( + @Parameter(description = "The fiscal code of the Organization.", required = true) + @NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode, + @Parameter(description = "The service id to enroll.", required = true) + @NotBlank @PathVariable("serviceId") String serviceId); + + @Operation(summary = "Return all enrollments for a creditor institution.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "getECEnrollments") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Obtained all enrollments for the creditor institution.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "OrganizationModelResponse", implementation = OrganizationModelResponse.class))), + @ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())), + @ApiResponse(responseCode = "404", description = "No payment option found.", content = @Content(schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))}) + @GetMapping(value = "/organizations/{organizationFiscalCode}", + produces = {"application/json"}) + ResponseEntity getECEnrollments( + @Parameter(description = "The fiscal code of the Organization.", required = true) + @NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode); +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/EnrollmentsController.java b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/EnrollmentsController.java new file mode 100644 index 0000000..d078b03 --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/EnrollmentsController.java @@ -0,0 +1,61 @@ +package it.gov.pagopa.spontaneouspayment.controller.impl; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; + +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; + +import it.gov.pagopa.spontaneouspayment.controller.IEnrollmentsController; +import it.gov.pagopa.spontaneouspayment.model.EnrollmentModel; +import it.gov.pagopa.spontaneouspayment.model.OrganizationEnrollmentModel; +import it.gov.pagopa.spontaneouspayment.model.OrganizationModel; +import it.gov.pagopa.spontaneouspayment.model.response.EnrollmentModelResponse; +import it.gov.pagopa.spontaneouspayment.model.response.OrganizationModelResponse; + +@Controller +public class EnrollmentsController implements IEnrollmentsController{ + + @Override + public ResponseEntity createECAndFirstServiceEnrollment( + @NotBlank String organizationFiscalCode, @NotBlank String serviceId, + @Valid OrganizationEnrollmentModel organizationEnrollmentModel) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResponseEntity updateECEnrollment(@NotBlank String organizationFiscalCode, + @NotBlank String serviceId, @Valid EnrollmentModel enrollmentModel) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResponseEntity updateEC(@NotBlank String organizationFiscalCode, + @Valid OrganizationModel organizationModel) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResponseEntity deleteECEnrollment(@NotBlank String organizationFiscalCode, + @NotBlank String serviceId) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResponseEntity getSingleEnrollment(@NotBlank String organizationFiscalCode, + @NotBlank String serviceId) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResponseEntity getECEnrollments(@NotBlank String organizationFiscalCode) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/EnrollmentModel.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/EnrollmentModel.java new file mode 100644 index 0000000..bcca0de --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/EnrollmentModel.java @@ -0,0 +1,20 @@ +package it.gov.pagopa.spontaneouspayment.model; + +import java.io.Serializable; + +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class EnrollmentModel implements Serializable{ + + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = 8505165905680276253L; + + private String iban; + private String officeName; + +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationEnrollmentModel.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationEnrollmentModel.java new file mode 100644 index 0000000..125c8c6 --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationEnrollmentModel.java @@ -0,0 +1,24 @@ +package it.gov.pagopa.spontaneouspayment.model; + +import java.io.Serializable; + +import javax.validation.constraints.NotBlank; + +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class OrganizationEnrollmentModel implements Serializable{ + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = 3009315407053476788L; + + @NotBlank(message = "company name is required") + private String companyName; + @NotBlank(message = "iban is required") + private String iban; + private String officeName; + +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationModel.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationModel.java new file mode 100644 index 0000000..f3b7db8 --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationModel.java @@ -0,0 +1,20 @@ +package it.gov.pagopa.spontaneouspayment.model; + +import java.io.Serializable; + +import it.gov.pagopa.spontaneouspayment.model.enumeration.Status; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class OrganizationModel implements Serializable{ + + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = -1181181033127626459L; + + private String companyName; + private Status status; +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/enumeration/Status.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/enumeration/Status.java new file mode 100644 index 0000000..ec3bf0b --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/enumeration/Status.java @@ -0,0 +1,5 @@ +package it.gov.pagopa.spontaneouspayment.model.enumeration; + +public enum Status { + ENABLED, DISABLED +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/EnrollmentModelResponse.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/EnrollmentModelResponse.java new file mode 100644 index 0000000..f58e48c --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/EnrollmentModelResponse.java @@ -0,0 +1,27 @@ +package it.gov.pagopa.spontaneouspayment.model.response; + +import java.io.Serializable; + +import javax.validation.constraints.NotBlank; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class EnrollmentModelResponse implements Serializable{ + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = -6830998393310794316L; + + @NotBlank(message = "service ID is required") + private String serviceId; + @NotBlank(message = "iban is required") + private String iban; + private String officeName; +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/OrganizationModelResponse.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/OrganizationModelResponse.java new file mode 100644 index 0000000..f019030 --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/OrganizationModelResponse.java @@ -0,0 +1,39 @@ +package it.gov.pagopa.spontaneouspayment.model.response; + +import java.io.Serializable; +import java.util.List; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +import it.gov.pagopa.spontaneouspayment.model.enumeration.Status; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class OrganizationModelResponse implements Serializable { + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = 6474656487948357626L; + + @NotBlank(message = "organization fiscal code is required") + private String organizationFiscalCode; + + @NotBlank(message = "company name is required") + private String companyName; + + @NotNull(message = "status is required") + private Status type; + + @Valid + private List enrollments; + + +} diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties new file mode 100644 index 0000000..c9057d2 --- /dev/null +++ b/src/main/resources/application-dev.properties @@ -0,0 +1,28 @@ +# info +properties.environment=dev + +# Cosmos account config +azure.cosmos.uri=https://pagopa-d-gps-cosmos-account.documents.azure.com:443/ +azure.cosmos.key=lGiI05RuRfjbT3UvHzFjuITKcSu6gK0f8lgHdKmipHgGiTIKVxceTdpJhVC67xmYm5uXihdsznnyyfOm2LsVoQ== +azure.cosmos.database=db +azure.cosmos.populate-query-metrics=false + +azure.cosmos.ec-container-name=creditor_institutions +azure.cosmos.service-container-name=services + +service.gpd.host=http://localhost:8085 + +# timeout +feign.client.config.default.connect-timeout=1000 +feign.client.config.default.read-timeout=1000 + +# retry configuration +retry.maxAttempts=1 +retry.maxDelay=200 + +# logging level settings +logging.level.root=INFO +logging.level.it.gov.pagopa.spontaneouspayment=INFO + + + diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index e38850a..7a2a04d 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -22,7 +22,4 @@ retry.maxDelay=200 # logging level settings logging.level.root=INFO -logging.level.it.gov.pagopa.spontaneouspayment=INFO - - - +logging.level.it.gov.pagopa.spontaneouspayment=INFO \ No newline at end of file From de8b9d62b39fdd14745d5bfbd76016b043be5b70 Mon Sep 17 00:00:00 2001 From: aacitelli Date: Mon, 20 Jun 2022 14:40:51 +0200 Subject: [PATCH 02/16] [PPD-206] crud gps: added services api (no business code) --- .../controller/IEnrollmentsController.java | 127 ++++++++++++++++++ .../controller/IServicesController.java | 51 +++++++ .../impl/EnrollmentsController.java | 61 +++++++++ .../controller/impl/ServicesController.java | 27 ++++ .../spontaneouspayment/entity/Service.java | 1 + .../model/EnrollmentModel.java | 20 +++ .../model/OrganizationEnrollmentModel.java | 24 ++++ .../model/OrganizationModel.java | 20 +++ .../model/enumeration/Status.java | 5 + .../response/EnrollmentModelResponse.java | 27 ++++ .../response/OrganizationModelResponse.java | 39 ++++++ .../response/ServiceDetailModelResponse.java | 41 ++++++ .../model/response/ServiceModelResponse.java | 25 ++++ .../ServicePropertyModelResponse.java | 30 +++++ .../model/response/SevicesModelResponse.java | 18 +++ src/main/resources/application-dev.properties | 28 ++++ .../resources/application-local.properties | 5 +- 17 files changed, 545 insertions(+), 4 deletions(-) create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/controller/IEnrollmentsController.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/controller/IServicesController.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/EnrollmentsController.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/ServicesController.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/model/EnrollmentModel.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationEnrollmentModel.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationModel.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/model/enumeration/Status.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/model/response/EnrollmentModelResponse.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/model/response/OrganizationModelResponse.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServiceDetailModelResponse.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServiceModelResponse.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServicePropertyModelResponse.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/model/response/SevicesModelResponse.java create mode 100644 src/main/resources/application-dev.properties diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IEnrollmentsController.java b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IEnrollmentsController.java new file mode 100644 index 0000000..04da662 --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IEnrollmentsController.java @@ -0,0 +1,127 @@ +package it.gov.pagopa.spontaneouspayment.controller; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; + +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.spontaneouspayment.model.EnrollmentModel; +import it.gov.pagopa.spontaneouspayment.model.OrganizationEnrollmentModel; +import it.gov.pagopa.spontaneouspayment.model.OrganizationModel; +import it.gov.pagopa.spontaneouspayment.model.ProblemJson; +import it.gov.pagopa.spontaneouspayment.model.response.EnrollmentModelResponse; +import it.gov.pagopa.spontaneouspayment.model.response.OrganizationModelResponse; + + +@Tag(name = "Enrollments API") +@RequestMapping +@Validated +public interface IEnrollmentsController { + + @Operation(summary = "The organization creates a creditor institution with its subscription to the 1st service.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "createECAndFirstServiceEnrollment") + @ApiResponses(value = { + @ApiResponse(responseCode = "201", description = "Request created.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "OrganizationModelResponse", implementation = OrganizationModelResponse.class))), + @ApiResponse(responseCode = "400", description = "Malformed request.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())), + @ApiResponse(responseCode = "404", description = "Not found the enroll service.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))}) + @PostMapping(value = "/organizations/{organizationFiscalCode}/services/{serviceId}", + produces = MediaType.APPLICATION_JSON_VALUE, + consumes = MediaType.APPLICATION_JSON_VALUE) + ResponseEntity createECAndFirstServiceEnrollment( + @Parameter(description = "The fiscal code of the Organization.", required = true) + @NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode, + @Parameter(description = "The service id to enroll.", required = true) + @NotBlank @PathVariable("serviceId") String serviceId, + @Valid @RequestBody OrganizationEnrollmentModel organizationEnrollmentModel); + + @Operation(summary = "The organization updates the enrollment to service for the creditor institution.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "updateECEnrollment") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Request updated.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "OrganizationModelResponse", implementation = OrganizationModelResponse.class))), + @ApiResponse(responseCode = "400", description = "Malformed request.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())), + @ApiResponse(responseCode = "404", description = "Not found the creditor institution or the enroll service.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))}) + @PutMapping(value = "/organizations/{organizationFiscalCode}/services/{serviceId}", + produces = MediaType.APPLICATION_JSON_VALUE, + consumes = MediaType.APPLICATION_JSON_VALUE) + ResponseEntity updateECEnrollment( + @Parameter(description = "The fiscal code of the Organization.", required = true) + @NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode, + @Parameter(description = "The service id to enroll.", required = true) + @NotBlank @PathVariable("serviceId") String serviceId, + @Valid @RequestBody EnrollmentModel enrollmentModel); + + @Operation(summary = "The organization updates the creditor institution.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "updateEC") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Request updated.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "OrganizationModelResponse", implementation = OrganizationModelResponse.class))), + @ApiResponse(responseCode = "400", description = "Malformed request.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())), + @ApiResponse(responseCode = "404", description = "Not found the creditor institution.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))}) + @PutMapping(value = "/organizations/{organizationFiscalCode}", + produces = MediaType.APPLICATION_JSON_VALUE, + consumes = MediaType.APPLICATION_JSON_VALUE) + ResponseEntity updateEC( + @Parameter(description = "The fiscal code of the Organization.", required = true) + @NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode, + @Valid @RequestBody OrganizationModel organizationModel); + + @Operation(summary = "The organization deletes the enrollment to service for the creditor institution.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "deleteECEnrollment") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Request deleted."), + @ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())), + @ApiResponse(responseCode = "404", description = "Not found the creditor institution or the enroll service.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))}) + @DeleteMapping(value = "/organizations/{organizationFiscalCode}/services/{serviceId}", + produces = MediaType.APPLICATION_JSON_VALUE, + consumes = MediaType.APPLICATION_JSON_VALUE) + ResponseEntity deleteECEnrollment( + @Parameter(description = "The fiscal code of the Organization.", required = true) + @NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode, + @Parameter(description = "The service id to enroll.", required = true) + @NotBlank @PathVariable("serviceId") String serviceId); + + @Operation(summary = "Return the single enrollment to a service.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "getSingleEnrollment") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Obtained single enrollment.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "EnrollmentModelResponse", implementation = EnrollmentModelResponse.class))), + @ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())), + @ApiResponse(responseCode = "404", description = "Not found the enroll service.", content = @Content(schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))}) + @GetMapping(value = "/organizations/{organizationFiscalCode}/services/{serviceId}", + produces = {"application/json"}) + ResponseEntity getSingleEnrollment( + @Parameter(description = "The fiscal code of the Organization.", required = true) + @NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode, + @Parameter(description = "The service id to enroll.", required = true) + @NotBlank @PathVariable("serviceId") String serviceId); + + @Operation(summary = "Return all enrollments for a creditor institution.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "getECEnrollments") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Obtained all enrollments for the creditor institution.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "OrganizationModelResponse", implementation = OrganizationModelResponse.class))), + @ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())), + @ApiResponse(responseCode = "404", description = "Not found the creditor institution.", content = @Content(schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))}) + @GetMapping(value = "/organizations/{organizationFiscalCode}", + produces = {"application/json"}) + ResponseEntity getECEnrollments( + @Parameter(description = "The fiscal code of the Organization.", required = true) + @NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode); +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IServicesController.java b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IServicesController.java new file mode 100644 index 0000000..60390d5 --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IServicesController.java @@ -0,0 +1,51 @@ +package it.gov.pagopa.spontaneouspayment.controller; + +import javax.validation.constraints.NotBlank; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; + +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.spontaneouspayment.model.ProblemJson; +import it.gov.pagopa.spontaneouspayment.model.response.OrganizationModelResponse; +import it.gov.pagopa.spontaneouspayment.model.response.ServiceDetailModelResponse; +import it.gov.pagopa.spontaneouspayment.model.response.SevicesModelResponse; + + +@Tag(name = "Services API") +@RequestMapping +@Validated +public interface IServicesController { + + @Operation(summary = "Return the single service details.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "getServiceDetails") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Obtained single service details.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "ServiceDetailModelResponse", implementation = ServiceDetailModelResponse.class))), + @ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())), + @ApiResponse(responseCode = "404", description = "No service found.", content = @Content(schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))}) + @GetMapping(value = "/services/{serviceId}", + produces = {"application/json"}) + ResponseEntity getServiceDetails( + @Parameter(description = "The service id for which to have the details.", required = true) + @NotBlank @PathVariable("serviceId") String serviceId); + + @Operation(summary = "Return all services.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "getServices") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Obtained all enrollments for the creditor institution.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "OrganizationModelResponse", implementation = OrganizationModelResponse.class))), + @ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())), + @ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))}) + @GetMapping(value = "/services", + produces = {"application/json"}) + ResponseEntity getServices(); +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/EnrollmentsController.java b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/EnrollmentsController.java new file mode 100644 index 0000000..d078b03 --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/EnrollmentsController.java @@ -0,0 +1,61 @@ +package it.gov.pagopa.spontaneouspayment.controller.impl; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; + +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; + +import it.gov.pagopa.spontaneouspayment.controller.IEnrollmentsController; +import it.gov.pagopa.spontaneouspayment.model.EnrollmentModel; +import it.gov.pagopa.spontaneouspayment.model.OrganizationEnrollmentModel; +import it.gov.pagopa.spontaneouspayment.model.OrganizationModel; +import it.gov.pagopa.spontaneouspayment.model.response.EnrollmentModelResponse; +import it.gov.pagopa.spontaneouspayment.model.response.OrganizationModelResponse; + +@Controller +public class EnrollmentsController implements IEnrollmentsController{ + + @Override + public ResponseEntity createECAndFirstServiceEnrollment( + @NotBlank String organizationFiscalCode, @NotBlank String serviceId, + @Valid OrganizationEnrollmentModel organizationEnrollmentModel) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResponseEntity updateECEnrollment(@NotBlank String organizationFiscalCode, + @NotBlank String serviceId, @Valid EnrollmentModel enrollmentModel) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResponseEntity updateEC(@NotBlank String organizationFiscalCode, + @Valid OrganizationModel organizationModel) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResponseEntity deleteECEnrollment(@NotBlank String organizationFiscalCode, + @NotBlank String serviceId) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResponseEntity getSingleEnrollment(@NotBlank String organizationFiscalCode, + @NotBlank String serviceId) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResponseEntity getECEnrollments(@NotBlank String organizationFiscalCode) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/ServicesController.java b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/ServicesController.java new file mode 100644 index 0000000..ada1b05 --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/ServicesController.java @@ -0,0 +1,27 @@ +package it.gov.pagopa.spontaneouspayment.controller.impl; + +import javax.validation.constraints.NotBlank; + +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; + +import it.gov.pagopa.spontaneouspayment.controller.IServicesController; +import it.gov.pagopa.spontaneouspayment.model.response.ServiceDetailModelResponse; +import it.gov.pagopa.spontaneouspayment.model.response.SevicesModelResponse; + +@Controller +public class ServicesController implements IServicesController{ + + @Override + public ResponseEntity getServiceDetails(@NotBlank String serviceId) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResponseEntity getServices() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/entity/Service.java b/src/main/java/it/gov/pagopa/spontaneouspayment/entity/Service.java index 1cf5160..d25f625 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/entity/Service.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/entity/Service.java @@ -25,6 +25,7 @@ public class Service { @Id private String id; + @NotBlank(message = "name is required") private String name; private String description; diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/EnrollmentModel.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/EnrollmentModel.java new file mode 100644 index 0000000..bcca0de --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/EnrollmentModel.java @@ -0,0 +1,20 @@ +package it.gov.pagopa.spontaneouspayment.model; + +import java.io.Serializable; + +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class EnrollmentModel implements Serializable{ + + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = 8505165905680276253L; + + private String iban; + private String officeName; + +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationEnrollmentModel.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationEnrollmentModel.java new file mode 100644 index 0000000..125c8c6 --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationEnrollmentModel.java @@ -0,0 +1,24 @@ +package it.gov.pagopa.spontaneouspayment.model; + +import java.io.Serializable; + +import javax.validation.constraints.NotBlank; + +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class OrganizationEnrollmentModel implements Serializable{ + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = 3009315407053476788L; + + @NotBlank(message = "company name is required") + private String companyName; + @NotBlank(message = "iban is required") + private String iban; + private String officeName; + +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationModel.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationModel.java new file mode 100644 index 0000000..f3b7db8 --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationModel.java @@ -0,0 +1,20 @@ +package it.gov.pagopa.spontaneouspayment.model; + +import java.io.Serializable; + +import it.gov.pagopa.spontaneouspayment.model.enumeration.Status; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class OrganizationModel implements Serializable{ + + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = -1181181033127626459L; + + private String companyName; + private Status status; +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/enumeration/Status.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/enumeration/Status.java new file mode 100644 index 0000000..ec3bf0b --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/enumeration/Status.java @@ -0,0 +1,5 @@ +package it.gov.pagopa.spontaneouspayment.model.enumeration; + +public enum Status { + ENABLED, DISABLED +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/EnrollmentModelResponse.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/EnrollmentModelResponse.java new file mode 100644 index 0000000..f58e48c --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/EnrollmentModelResponse.java @@ -0,0 +1,27 @@ +package it.gov.pagopa.spontaneouspayment.model.response; + +import java.io.Serializable; + +import javax.validation.constraints.NotBlank; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class EnrollmentModelResponse implements Serializable{ + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = -6830998393310794316L; + + @NotBlank(message = "service ID is required") + private String serviceId; + @NotBlank(message = "iban is required") + private String iban; + private String officeName; +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/OrganizationModelResponse.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/OrganizationModelResponse.java new file mode 100644 index 0000000..f019030 --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/OrganizationModelResponse.java @@ -0,0 +1,39 @@ +package it.gov.pagopa.spontaneouspayment.model.response; + +import java.io.Serializable; +import java.util.List; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +import it.gov.pagopa.spontaneouspayment.model.enumeration.Status; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class OrganizationModelResponse implements Serializable { + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = 6474656487948357626L; + + @NotBlank(message = "organization fiscal code is required") + private String organizationFiscalCode; + + @NotBlank(message = "company name is required") + private String companyName; + + @NotNull(message = "status is required") + private Status type; + + @Valid + private List enrollments; + + +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServiceDetailModelResponse.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServiceDetailModelResponse.java new file mode 100644 index 0000000..9cd3d77 --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServiceDetailModelResponse.java @@ -0,0 +1,41 @@ +package it.gov.pagopa.spontaneouspayment.model.response; + +import java.io.Serializable; +import java.util.List; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +import it.gov.pagopa.spontaneouspayment.model.enumeration.Status; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ServiceDetailModelResponse implements Serializable{ + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = -3792257418379600493L; + + @NotBlank(message = "id is required") + private String id; + private String name; + private String description; + + @NotBlank(message = "transfer category is required") + private String transferCategory; // tassonomia + + @NotBlank(message = "remittance information is required") + private String remittanceInformation; // causale + + @NotNull(message = "status is required") + private Status status; + + @Valid + private List properties; + +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServiceModelResponse.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServiceModelResponse.java new file mode 100644 index 0000000..809de39 --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServiceModelResponse.java @@ -0,0 +1,25 @@ +package it.gov.pagopa.spontaneouspayment.model.response; + +import java.io.Serializable; + +import javax.validation.constraints.NotBlank; + +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class ServiceModelResponse implements Serializable{ + + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = -6620381879835313811L; + + @NotBlank(message = "id is required") + private String id; + @NotBlank(message = "name is required") + private String name; + private String description; + +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServicePropertyModelResponse.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServicePropertyModelResponse.java new file mode 100644 index 0000000..26fc804 --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServicePropertyModelResponse.java @@ -0,0 +1,30 @@ +package it.gov.pagopa.spontaneouspayment.model.response; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.io.Serializable; + +import javax.validation.constraints.NotBlank; + + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class ServicePropertyModelResponse implements Serializable{ + + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = 7156317962327532355L; + + @NotBlank + private String name; + + private String type; + + private boolean isRequired; +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/SevicesModelResponse.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/SevicesModelResponse.java new file mode 100644 index 0000000..8d58bd8 --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/SevicesModelResponse.java @@ -0,0 +1,18 @@ +package it.gov.pagopa.spontaneouspayment.model.response; + +import java.io.Serializable; +import java.util.List; + +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class SevicesModelResponse implements Serializable{ + + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = -3078022971085103082L; + private List services; +} diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties new file mode 100644 index 0000000..c9057d2 --- /dev/null +++ b/src/main/resources/application-dev.properties @@ -0,0 +1,28 @@ +# info +properties.environment=dev + +# Cosmos account config +azure.cosmos.uri=https://pagopa-d-gps-cosmos-account.documents.azure.com:443/ +azure.cosmos.key=lGiI05RuRfjbT3UvHzFjuITKcSu6gK0f8lgHdKmipHgGiTIKVxceTdpJhVC67xmYm5uXihdsznnyyfOm2LsVoQ== +azure.cosmos.database=db +azure.cosmos.populate-query-metrics=false + +azure.cosmos.ec-container-name=creditor_institutions +azure.cosmos.service-container-name=services + +service.gpd.host=http://localhost:8085 + +# timeout +feign.client.config.default.connect-timeout=1000 +feign.client.config.default.read-timeout=1000 + +# retry configuration +retry.maxAttempts=1 +retry.maxDelay=200 + +# logging level settings +logging.level.root=INFO +logging.level.it.gov.pagopa.spontaneouspayment=INFO + + + diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index e38850a..7a2a04d 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -22,7 +22,4 @@ retry.maxDelay=200 # logging level settings logging.level.root=INFO -logging.level.it.gov.pagopa.spontaneouspayment=INFO - - - +logging.level.it.gov.pagopa.spontaneouspayment=INFO \ No newline at end of file From 6825864092a18a05dd69e5f035e6ec24abe469fc Mon Sep 17 00:00:00 2001 From: aacitelli Date: Fri, 24 Jun 2022 16:39:31 +0200 Subject: [PATCH 03/16] [PPD-206] crud gps: removed unnecessary test --- .../CosmosDBContainerTest.java | 76 ------------------- .../controller/EnrollmentsControllerTest.java | 3 +- 2 files changed, 1 insertion(+), 78 deletions(-) delete mode 100644 src/test/java/it/gov/pagopa/spontaneouspayment/CosmosDBContainerTest.java diff --git a/src/test/java/it/gov/pagopa/spontaneouspayment/CosmosDBContainerTest.java b/src/test/java/it/gov/pagopa/spontaneouspayment/CosmosDBContainerTest.java deleted file mode 100644 index 3de371d..0000000 --- a/src/test/java/it/gov/pagopa/spontaneouspayment/CosmosDBContainerTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package it.gov.pagopa.spontaneouspayment; - -import static org.junit.Assert.assertTrue; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.file.Path; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.CertificateException; - -import org.junit.jupiter.api.Assertions; -import org.junit.Rule; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.rules.TemporaryFolder; -import org.testcontainers.containers.CosmosDBEmulatorContainer; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; -import org.testcontainers.utility.DockerImageName; - -import com.azure.cosmos.CosmosAsyncClient; -import com.azure.cosmos.CosmosClientBuilder; -import com.azure.cosmos.models.CosmosContainerResponse; -import com.azure.cosmos.models.CosmosDatabaseResponse; - -@Testcontainers -class CosmosDBContainerTest { - - @Rule - public TemporaryFolder tempFolder= new TemporaryFolder(); - - - @Container - private static final CosmosDBEmulatorContainer emulator = new CosmosDBEmulatorContainer( - DockerImageName.parse("mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest")); - - - - @BeforeEach - public void setUp() throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException { - tempFolder.create(); - Path keyStoreFile = tempFolder.newFile("azure-cosmos-emulator.keystore").toPath(); - KeyStore keyStore = emulator.buildNewKeyStore(); - keyStore.store(new FileOutputStream(keyStoreFile.toFile()), emulator.getEmulatorKey().toCharArray()); - - System.setProperty("javax.net.ssl.trustStore", keyStoreFile.toString()); - System.setProperty("javax.net.ssl.trustStorePassword", emulator.getEmulatorKey()); - System.setProperty("javax.net.ssl.trustStoreType", "PKCS12"); - } - - @Test - void cosmosDBEmulatorCheck() { - - assertTrue(emulator.isRunning()); - - - - CosmosAsyncClient client = new CosmosClientBuilder() - .gatewayMode() - .endpointDiscoveryEnabled(false) - .endpoint(emulator.getEmulatorEndpoint()) - .key(emulator.getEmulatorKey()) - .buildAsyncClient(); - - CosmosDatabaseResponse databaseResponse = client.createDatabaseIfNotExists("Azure").block(); - - Assertions.assertEquals(201, databaseResponse.getStatusCode()); - CosmosContainerResponse containerResponse = client - .getDatabase("Azure") - .createContainerIfNotExists("ServiceContainer", "/name") - .block(); - Assertions.assertEquals(201, containerResponse.getStatusCode()); - } -} diff --git a/src/test/java/it/gov/pagopa/spontaneouspayment/controller/EnrollmentsControllerTest.java b/src/test/java/it/gov/pagopa/spontaneouspayment/controller/EnrollmentsControllerTest.java index 78b55b2..0e7d94c 100644 --- a/src/test/java/it/gov/pagopa/spontaneouspayment/controller/EnrollmentsControllerTest.java +++ b/src/test/java/it/gov/pagopa/spontaneouspayment/controller/EnrollmentsControllerTest.java @@ -23,14 +23,13 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; -import it.gov.pagopa.spontaneouspayment.SpontaneousPaymentApplication; import it.gov.pagopa.spontaneouspayment.config.TestUtil; import it.gov.pagopa.spontaneouspayment.entity.Organization; import it.gov.pagopa.spontaneouspayment.model.EnrollmentModel; import it.gov.pagopa.spontaneouspayment.model.OrganizationModel; import it.gov.pagopa.spontaneouspayment.service.EnrollmentsService; -@SpringBootTest(classes = SpontaneousPaymentApplication.class) +@SpringBootTest @AutoConfigureMockMvc class EnrollmentsControllerTest { From e05c2f96cb634c9657946d6d628294e97be52b95 Mon Sep 17 00:00:00 2001 From: aacitelli Date: Fri, 24 Jun 2022 16:39:31 +0200 Subject: [PATCH 04/16] [PPD-206] crud gps: corrected error "unable to find valid certification path" during JUNIT test execution --- .../CosmosDBContainerTest.java | 76 ------------------- ...=> SpontaneousPaymentApplicationTest.java} | 6 +- .../controller/EnrollmentsControllerTest.java | 3 +- .../service/EnrollmentsServiceTest.java | 5 ++ 4 files changed, 9 insertions(+), 81 deletions(-) delete mode 100644 src/test/java/it/gov/pagopa/spontaneouspayment/CosmosDBContainerTest.java rename src/test/java/it/gov/pagopa/spontaneouspayment/{SpontaneousPaymentApplicationTests.java => SpontaneousPaymentApplicationTest.java} (88%) diff --git a/src/test/java/it/gov/pagopa/spontaneouspayment/CosmosDBContainerTest.java b/src/test/java/it/gov/pagopa/spontaneouspayment/CosmosDBContainerTest.java deleted file mode 100644 index 3de371d..0000000 --- a/src/test/java/it/gov/pagopa/spontaneouspayment/CosmosDBContainerTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package it.gov.pagopa.spontaneouspayment; - -import static org.junit.Assert.assertTrue; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.file.Path; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.CertificateException; - -import org.junit.jupiter.api.Assertions; -import org.junit.Rule; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.rules.TemporaryFolder; -import org.testcontainers.containers.CosmosDBEmulatorContainer; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; -import org.testcontainers.utility.DockerImageName; - -import com.azure.cosmos.CosmosAsyncClient; -import com.azure.cosmos.CosmosClientBuilder; -import com.azure.cosmos.models.CosmosContainerResponse; -import com.azure.cosmos.models.CosmosDatabaseResponse; - -@Testcontainers -class CosmosDBContainerTest { - - @Rule - public TemporaryFolder tempFolder= new TemporaryFolder(); - - - @Container - private static final CosmosDBEmulatorContainer emulator = new CosmosDBEmulatorContainer( - DockerImageName.parse("mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest")); - - - - @BeforeEach - public void setUp() throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException { - tempFolder.create(); - Path keyStoreFile = tempFolder.newFile("azure-cosmos-emulator.keystore").toPath(); - KeyStore keyStore = emulator.buildNewKeyStore(); - keyStore.store(new FileOutputStream(keyStoreFile.toFile()), emulator.getEmulatorKey().toCharArray()); - - System.setProperty("javax.net.ssl.trustStore", keyStoreFile.toString()); - System.setProperty("javax.net.ssl.trustStorePassword", emulator.getEmulatorKey()); - System.setProperty("javax.net.ssl.trustStoreType", "PKCS12"); - } - - @Test - void cosmosDBEmulatorCheck() { - - assertTrue(emulator.isRunning()); - - - - CosmosAsyncClient client = new CosmosClientBuilder() - .gatewayMode() - .endpointDiscoveryEnabled(false) - .endpoint(emulator.getEmulatorEndpoint()) - .key(emulator.getEmulatorKey()) - .buildAsyncClient(); - - CosmosDatabaseResponse databaseResponse = client.createDatabaseIfNotExists("Azure").block(); - - Assertions.assertEquals(201, databaseResponse.getStatusCode()); - CosmosContainerResponse containerResponse = client - .getDatabase("Azure") - .createContainerIfNotExists("ServiceContainer", "/name") - .block(); - Assertions.assertEquals(201, containerResponse.getStatusCode()); - } -} diff --git a/src/test/java/it/gov/pagopa/spontaneouspayment/SpontaneousPaymentApplicationTests.java b/src/test/java/it/gov/pagopa/spontaneouspayment/SpontaneousPaymentApplicationTest.java similarity index 88% rename from src/test/java/it/gov/pagopa/spontaneouspayment/SpontaneousPaymentApplicationTests.java rename to src/test/java/it/gov/pagopa/spontaneouspayment/SpontaneousPaymentApplicationTest.java index 27ec48a..37d4bc4 100644 --- a/src/test/java/it/gov/pagopa/spontaneouspayment/SpontaneousPaymentApplicationTests.java +++ b/src/test/java/it/gov/pagopa/spontaneouspayment/SpontaneousPaymentApplicationTest.java @@ -1,12 +1,12 @@ package it.gov.pagopa.spontaneouspayment; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import static org.junit.jupiter.api.Assertions.assertTrue; - @SpringBootTest -class SpontaneousPaymentApplicationTests { +class SpontaneousPaymentApplicationTest { @Test void contextLoads() { diff --git a/src/test/java/it/gov/pagopa/spontaneouspayment/controller/EnrollmentsControllerTest.java b/src/test/java/it/gov/pagopa/spontaneouspayment/controller/EnrollmentsControllerTest.java index 78b55b2..0e7d94c 100644 --- a/src/test/java/it/gov/pagopa/spontaneouspayment/controller/EnrollmentsControllerTest.java +++ b/src/test/java/it/gov/pagopa/spontaneouspayment/controller/EnrollmentsControllerTest.java @@ -23,14 +23,13 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; -import it.gov.pagopa.spontaneouspayment.SpontaneousPaymentApplication; import it.gov.pagopa.spontaneouspayment.config.TestUtil; import it.gov.pagopa.spontaneouspayment.entity.Organization; import it.gov.pagopa.spontaneouspayment.model.EnrollmentModel; import it.gov.pagopa.spontaneouspayment.model.OrganizationModel; import it.gov.pagopa.spontaneouspayment.service.EnrollmentsService; -@SpringBootTest(classes = SpontaneousPaymentApplication.class) +@SpringBootTest @AutoConfigureMockMvc class EnrollmentsControllerTest { diff --git a/src/test/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsServiceTest.java b/src/test/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsServiceTest.java index e2d95ac..a2a7c5e 100644 --- a/src/test/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsServiceTest.java +++ b/src/test/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsServiceTest.java @@ -173,7 +173,12 @@ void teardown() { CosmosAsyncClient client = new CosmosClientBuilder().gatewayMode().endpointDiscoveryEnabled(false) .endpoint(emulator.getEmulatorEndpoint()).key(emulator.getEmulatorKey()).buildAsyncClient(); client.getDatabase("db").delete(); + client.close(); emulator.stop(); + emulator.close(); + System.clearProperty("javax.net.ssl.trustStore"); + System.clearProperty("javax.net.ssl.trustStorePassword"); + System.clearProperty("javax.net.ssl.trustStoreType"); } From 27d54fbc37a3340c9aa5fa7a112c84d89b39d7b7 Mon Sep 17 00:00:00 2001 From: pasqualespica <36746022+pasqualespica@users.noreply.github.com> Date: Fri, 24 Jun 2022 18:08:52 +0200 Subject: [PATCH 05/16] upd vmimage --- .devops/code-review-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devops/code-review-pipelines.yml b/.devops/code-review-pipelines.yml index dceef82..b6046c4 100644 --- a/.devops/code-review-pipelines.yml +++ b/.devops/code-review-pipelines.yml @@ -8,7 +8,7 @@ trigger: none pool: - vmImage: 'ubuntu-20.04' + vmImage: 'ubuntu-18.04' variables: MAVEN_CACHE_FOLDER: $(Pipeline.Workspace)/.m2/repository From 16f7879d02c5f7df0876c6bb78fd821aed4a605a Mon Sep 17 00:00:00 2001 From: pasqualespica <36746022+pasqualespica@users.noreply.github.com> Date: Fri, 24 Jun 2022 18:14:53 +0200 Subject: [PATCH 06/16] disable junit result --- .devops/code-review-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devops/code-review-pipelines.yml b/.devops/code-review-pipelines.yml index b6046c4..cd32683 100644 --- a/.devops/code-review-pipelines.yml +++ b/.devops/code-review-pipelines.yml @@ -41,7 +41,7 @@ steps: javaHomeOption: 'JDKVersion' jdkVersionOption: '1.11' jdkArchitectureOption: 'x64' - publishJUnitResults: true + publishJUnitResults: false testResultsFiles: '**/surefire-reports/TEST-*.xml' goals: 'package' sonarQubeRunAnalysis: true From 35741034c64dac6a266d89310e05db59ff043ee1 Mon Sep 17 00:00:00 2001 From: pasqualespica <36746022+pasqualespica@users.noreply.github.com> Date: Fri, 24 Jun 2022 18:30:48 +0200 Subject: [PATCH 07/16] jdk vers --- .devops/code-review-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devops/code-review-pipelines.yml b/.devops/code-review-pipelines.yml index cd32683..6b1d0bf 100644 --- a/.devops/code-review-pipelines.yml +++ b/.devops/code-review-pipelines.yml @@ -39,7 +39,7 @@ steps: mavenPomFile: 'pom.xml' mavenOptions: '-Xmx3072m $(MAVEN_OPTS)' javaHomeOption: 'JDKVersion' - jdkVersionOption: '1.11' + jdkVersionOption: '11' jdkArchitectureOption: 'x64' publishJUnitResults: false testResultsFiles: '**/surefire-reports/TEST-*.xml' From c94ef3e746076b1646b898c6e5f799d2ea3ada40 Mon Sep 17 00:00:00 2001 From: Pasquale Spica <36746022+pasqualespica@users.noreply.github.com> Date: Fri, 24 Jun 2022 18:39:19 +0200 Subject: [PATCH 08/16] Update code-review-pipelines.yml for Azure Pipelines --- .devops/code-review-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devops/code-review-pipelines.yml b/.devops/code-review-pipelines.yml index 6b1d0bf..d46b275 100644 --- a/.devops/code-review-pipelines.yml +++ b/.devops/code-review-pipelines.yml @@ -8,7 +8,7 @@ trigger: none pool: - vmImage: 'ubuntu-18.04' + vmImage: 'ubuntu-20.04' variables: MAVEN_CACHE_FOLDER: $(Pipeline.Workspace)/.m2/repository @@ -39,7 +39,7 @@ steps: mavenPomFile: 'pom.xml' mavenOptions: '-Xmx3072m $(MAVEN_OPTS)' javaHomeOption: 'JDKVersion' - jdkVersionOption: '11' + jdkVersionOption: '1.11' jdkArchitectureOption: 'x64' publishJUnitResults: false testResultsFiles: '**/surefire-reports/TEST-*.xml' From e6a698792a9dc5425abd9a58b2532fdb63d405c9 Mon Sep 17 00:00:00 2001 From: Pasquale Spica <36746022+pasqualespica@users.noreply.github.com> Date: Fri, 24 Jun 2022 18:46:38 +0200 Subject: [PATCH 09/16] Update code-review-pipelines.yml for Azure Pipelines --- .devops/code-review-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devops/code-review-pipelines.yml b/.devops/code-review-pipelines.yml index d46b275..8a0db0d 100644 --- a/.devops/code-review-pipelines.yml +++ b/.devops/code-review-pipelines.yml @@ -8,7 +8,7 @@ trigger: none pool: - vmImage: 'ubuntu-20.04' + vmImage: 'ubuntu-18.04' variables: MAVEN_CACHE_FOLDER: $(Pipeline.Workspace)/.m2/repository @@ -44,7 +44,7 @@ steps: publishJUnitResults: false testResultsFiles: '**/surefire-reports/TEST-*.xml' goals: 'package' - sonarQubeRunAnalysis: true + sonarQubeRunAnalysis: false - task: SonarCloudPublish@1 displayName: 'Publish SonarCloud results on build summary' From 109212136e193f589382819bdd98bc657a2562ac Mon Sep 17 00:00:00 2001 From: Pasquale Spica <36746022+pasqualespica@users.noreply.github.com> Date: Fri, 24 Jun 2022 18:53:26 +0200 Subject: [PATCH 10/16] Update code-review-pipelines.yml for Azure Pipelines --- .devops/code-review-pipelines.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devops/code-review-pipelines.yml b/.devops/code-review-pipelines.yml index 8a0db0d..82f75ce 100644 --- a/.devops/code-review-pipelines.yml +++ b/.devops/code-review-pipelines.yml @@ -44,7 +44,8 @@ steps: publishJUnitResults: false testResultsFiles: '**/surefire-reports/TEST-*.xml' goals: 'package' - sonarQubeRunAnalysis: false + sonarQubeRunAnalysis: true + sqMavenPluginVersionChoice: latest - task: SonarCloudPublish@1 displayName: 'Publish SonarCloud results on build summary' From c2fd00eb2317c921cd768781baf41a04e1697a53 Mon Sep 17 00:00:00 2001 From: Pasquale Spica <36746022+pasqualespica@users.noreply.github.com> Date: Mon, 27 Jun 2022 11:37:28 +0200 Subject: [PATCH 11/16] Update code-review-pipelines.yml for Azure Pipelines --- .devops/code-review-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devops/code-review-pipelines.yml b/.devops/code-review-pipelines.yml index 82f75ce..c6975b5 100644 --- a/.devops/code-review-pipelines.yml +++ b/.devops/code-review-pipelines.yml @@ -43,7 +43,7 @@ steps: jdkArchitectureOption: 'x64' publishJUnitResults: false testResultsFiles: '**/surefire-reports/TEST-*.xml' - goals: 'package' + goals: 'clean verify' sonarQubeRunAnalysis: true sqMavenPluginVersionChoice: latest From f9c68746e7520736a8f0b376b029d6921d36d29c Mon Sep 17 00:00:00 2001 From: Jacopo Carlini Date: Mon, 27 Jun 2022 12:14:01 +0200 Subject: [PATCH 12/16] Update code-review-pipelines.yml for Azure Pipelines --- .devops/code-review-pipelines.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.devops/code-review-pipelines.yml b/.devops/code-review-pipelines.yml index c6975b5..4570ff0 100644 --- a/.devops/code-review-pipelines.yml +++ b/.devops/code-review-pipelines.yml @@ -37,15 +37,19 @@ steps: - task: Maven@3 inputs: mavenPomFile: 'pom.xml' - mavenOptions: '-Xmx3072m $(MAVEN_OPTS)' + goals: 'clean verify' + publishJUnitResults: true + testResultsFiles: '**/surefire-reports/TEST-*.xml' + codeCoverageToolOption: 'JaCoCo' javaHomeOption: 'JDKVersion' jdkVersionOption: '1.11' - jdkArchitectureOption: 'x64' - publishJUnitResults: false - testResultsFiles: '**/surefire-reports/TEST-*.xml' - goals: 'clean verify' + mavenVersionOption: 'Default' + mavenOptions: '-Xmx3072m $(MAVEN_OPTS)' + mavenAuthenticateFeed: false + effectivePomSkip: false sonarQubeRunAnalysis: true - sqMavenPluginVersionChoice: latest + isJacocoCoverageReportXML: true + sqMavenPluginVersionChoice: 'latest' - task: SonarCloudPublish@1 displayName: 'Publish SonarCloud results on build summary' From 75422a92f494d47a9ef3f577a994c99eb32051dd Mon Sep 17 00:00:00 2001 From: Pasquale Spica <36746022+pasqualespica@users.noreply.github.com> Date: Mon, 27 Jun 2022 21:37:05 +0200 Subject: [PATCH 13/16] Update code-review-pipelines.yml for Azure Pipelines --- .devops/code-review-pipelines.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.devops/code-review-pipelines.yml b/.devops/code-review-pipelines.yml index 4570ff0..c3387ba 100644 --- a/.devops/code-review-pipelines.yml +++ b/.devops/code-review-pipelines.yml @@ -33,6 +33,9 @@ steps: extraProperties: | sonar.projectKey=$(SONARCLOUD_PROJECT_KEY) sonar.projectName=$(SONARCLOUD_PROJECT_NAME) + sonar.coverage.exclusions=**/config/*,**/*Mock*,**/model/**,**/entity/* + sonar.cpd.exclusions=**/model/**,**/entity/* + - task: Maven@3 inputs: From b7ece5a75b7e06d8cf13639a0feafffea31bdb06 Mon Sep 17 00:00:00 2001 From: aacitelli Date: Tue, 28 Jun 2022 11:02:03 +0200 Subject: [PATCH 14/16] [PPD-206] CRUD GPS: updated swagger definition --- openapi/openapi.json | 363 +++++++++++------- .../controller/IEnrollmentsController.java | 12 + .../controller/IServicesController.java | 6 +- .../impl/EnrollmentsController.java | 10 + .../controller/impl/ServicesController.java | 28 +- .../spontaneouspayment/entity/Service.java | 2 + .../model/response/SevicesModelResponse.java | 18 - .../service/EnrollmentsService.java | 7 + .../service/ServicesService.java | 36 ++ .../spontaneouspayment/config/TestUtil.java | 13 + .../controller/ServicesControllerTest.java | 62 +++ .../service/EnrollmentsServiceTest.java | 38 ++ .../service/ServicesServiceTest.java | 214 +++++++++++ 13 files changed, 648 insertions(+), 161 deletions(-) delete mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/model/response/SevicesModelResponse.java create mode 100644 src/main/java/it/gov/pagopa/spontaneouspayment/service/ServicesService.java create mode 100644 src/test/java/it/gov/pagopa/spontaneouspayment/controller/ServicesControllerTest.java create mode 100644 src/test/java/it/gov/pagopa/spontaneouspayment/service/ServicesServiceTest.java diff --git a/openapi/openapi.json b/openapi/openapi.json index eee2ec7..0e9a001 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -50,17 +50,6 @@ } } }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, "404": { "description": "Not found the creditor institution.", "headers": { @@ -96,6 +85,17 @@ } } } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } } }, "security": [ @@ -153,17 +153,6 @@ } } }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, "200": { "description": "Request updated.", "headers": { @@ -182,8 +171,8 @@ } } }, - "404": { - "description": "Not found the creditor institution.", + "500": { + "description": "Service unavailable.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -200,8 +189,19 @@ } } }, - "500": { - "description": "Service unavailable.", + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found the creditor institution.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -256,8 +256,8 @@ "required": true }, "responses": { - "409": { - "description": "The organization to create already exists.", + "400": { + "description": "Malformed request.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -274,8 +274,26 @@ } } }, - "400": { - "description": "Malformed request.", + "201": { + "description": "Request created.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationModelResponse" + } + } + } + }, + "500": { + "description": "Service unavailable.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -303,6 +321,70 @@ } } }, + "409": { + "description": "The organization to create already exists.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "delete": { + "tags": [ + "Enrollments API" + ], + "summary": "The organization deletes the creditor institution.", + "operationId": "deleteEC", + "parameters": [ + { + "name": "organizationFiscalCode", + "in": "path", + "description": "The fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Request deleted.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, "500": { "description": "Service unavailable.", "headers": { @@ -321,8 +403,19 @@ } } }, - "201": { - "description": "Request created.", + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found the creditor institution.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -334,7 +427,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OrganizationModelResponse" + "$ref": "#/components/schemas/ProblemJson" } } } @@ -388,8 +481,8 @@ } ], "responses": { - "200": { - "description": "Obtained single enrollment.", + "404": { + "description": "Not found the enroll service.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -401,13 +494,13 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/EnrollmentModelResponse" + "$ref": "#/components/schemas/ProblemJson" } } } }, - "401": { - "description": "Wrong or missing function key.", + "200": { + "description": "Obtained single enrollment.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -415,6 +508,13 @@ "type": "string" } } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EnrollmentModelResponse" + } + } } }, "500": { @@ -435,8 +535,8 @@ } } }, - "404": { - "description": "Not found the enroll service.", + "401": { + "description": "Wrong or missing function key.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -444,13 +544,6 @@ "type": "string" } } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } } } }, @@ -500,8 +593,8 @@ "required": true }, "responses": { - "404": { - "description": "Not found the creditor institution or the enroll service.", + "400": { + "description": "Malformed request.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -518,8 +611,8 @@ } } }, - "400": { - "description": "Malformed request.", + "404": { + "description": "Not found the creditor institution or the enroll service.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -536,17 +629,6 @@ } } }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, "200": { "description": "Request updated.", "headers": { @@ -582,6 +664,17 @@ } } } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } } }, "security": [ @@ -630,8 +723,8 @@ "required": true }, "responses": { - "404": { - "description": "Not found the creditor institution or the enroll service.", + "400": { + "description": "Malformed request.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -648,8 +741,8 @@ } } }, - "400": { - "description": "Malformed request.", + "404": { + "description": "Not found the creditor institution or the enroll service.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -666,8 +759,8 @@ } } }, - "401": { - "description": "Wrong or missing function key.", + "201": { + "description": "Request created.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -675,6 +768,13 @@ "type": "string" } } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationModelResponse" + } + } } }, "500": { @@ -695,8 +795,8 @@ } } }, - "409": { - "description": "The enrollment to the service already exists.", + "401": { + "description": "Wrong or missing function key.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -704,17 +804,10 @@ "type": "string" } } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } } }, - "201": { - "description": "Request created.", + "409": { + "description": "The enrollment to the service already exists.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -726,7 +819,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OrganizationModelResponse" + "$ref": "#/components/schemas/ProblemJson" } } } @@ -768,8 +861,8 @@ } ], "responses": { - "404": { - "description": "Not found the creditor institution or the enroll service.", + "200": { + "description": "Request deleted.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -780,25 +873,14 @@ }, "content": { "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", "schema": { "type": "string" } } } }, - "200": { - "description": "Request deleted.", + "404": { + "description": "Not found the creditor institution or the enroll service.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -810,7 +892,7 @@ "content": { "application/json": { "schema": { - "type": "string" + "$ref": "#/components/schemas/ProblemJson" } } } @@ -832,6 +914,17 @@ } } } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } } }, "security": [ @@ -883,8 +976,8 @@ "required": true }, "responses": { - "201": { - "description": "Request created.", + "400": { + "description": "Malformed request.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -896,13 +989,13 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PaymentPositionModel" + "$ref": "#/components/schemas/ProblemJson" } } } }, - "400": { - "description": "Malformed request.", + "201": { + "description": "Request created.", "headers": { "X-Request-Id": { "description": "This header identifies the call", @@ -914,18 +1007,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "$ref": "#/components/schemas/PaymentPositionModel" } } } @@ -965,6 +1047,17 @@ } } } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } } }, "security": [ @@ -1013,17 +1106,6 @@ } } }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, "500": { "description": "Service unavailable.", "headers": { @@ -1041,6 +1123,17 @@ } } } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } } }, "security": [ @@ -1118,17 +1211,6 @@ } } }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, "500": { "description": "Service unavailable.", "headers": { @@ -1146,6 +1228,17 @@ } } } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } } }, "security": [ diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IEnrollmentsController.java b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IEnrollmentsController.java index d50d7d9..a2bbae0 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IEnrollmentsController.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IEnrollmentsController.java @@ -114,6 +114,18 @@ ResponseEntity deleteECEnrollment( @Parameter(description = "The service id to enroll.", required = true) @NotBlank @PathVariable("serviceId") String serviceId); + @Operation(summary = "The organization deletes the creditor institution.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "deleteEC") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Request deleted.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "StringResponse", implementation = String.class))), + @ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())), + @ApiResponse(responseCode = "404", description = "Not found the creditor institution.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))}) + @DeleteMapping(value = "/organizations/{organizationFiscalCode}", + produces = MediaType.APPLICATION_JSON_VALUE) + ResponseEntity deleteEC( + @Parameter(description = "The fiscal code of the Organization.", required = true) + @NotBlank @PathVariable("organizationFiscalCode") String organizationFiscalCode); + @Operation(summary = "Return the single enrollment to a service.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "getSingleEnrollment") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Obtained single enrollment.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "EnrollmentModelResponse", implementation = EnrollmentModelResponse.class))), diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IServicesController.java b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IServicesController.java index 60390d5..0512237 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IServicesController.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IServicesController.java @@ -1,5 +1,7 @@ package it.gov.pagopa.spontaneouspayment.controller; +import java.util.List; + import javax.validation.constraints.NotBlank; import org.springframework.http.MediaType; @@ -20,7 +22,7 @@ import it.gov.pagopa.spontaneouspayment.model.ProblemJson; import it.gov.pagopa.spontaneouspayment.model.response.OrganizationModelResponse; import it.gov.pagopa.spontaneouspayment.model.response.ServiceDetailModelResponse; -import it.gov.pagopa.spontaneouspayment.model.response.SevicesModelResponse; +import it.gov.pagopa.spontaneouspayment.model.response.ServiceModelResponse; @Tag(name = "Services API") @@ -47,5 +49,5 @@ ResponseEntity getServiceDetails( @ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))}) @GetMapping(value = "/services", produces = {"application/json"}) - ResponseEntity getServices(); + ResponseEntity> getServices(); } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/EnrollmentsController.java b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/EnrollmentsController.java index f03e495..98668f9 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/EnrollmentsController.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/EnrollmentsController.java @@ -78,6 +78,14 @@ public ResponseEntity deleteECEnrollment(@NotBlank String organizationFi HttpStatus.OK); } + + @Override + public ResponseEntity deleteEC(@NotBlank String organizationFiscalCode) { + enrollmentsService.deleteEC(organizationFiscalCode); + return new ResponseEntity<>( + "\"The organization "+organizationFiscalCode+" was successfully removed\"", + HttpStatus.OK); + } @Override public ResponseEntity getSingleEnrollment(@NotBlank String organizationFiscalCode, @@ -94,4 +102,6 @@ public ResponseEntity getECEnrollments(@NotBlank Stri HttpStatus.OK); } + + } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/ServicesController.java b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/ServicesController.java index ada1b05..63c36a1 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/ServicesController.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/ServicesController.java @@ -1,27 +1,43 @@ package it.gov.pagopa.spontaneouspayment.controller.impl; +import java.util.List; +import java.util.stream.Collectors; + import javax.validation.constraints.NotBlank; +import org.modelmapper.ModelMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import it.gov.pagopa.spontaneouspayment.controller.IServicesController; import it.gov.pagopa.spontaneouspayment.model.response.ServiceDetailModelResponse; -import it.gov.pagopa.spontaneouspayment.model.response.SevicesModelResponse; +import it.gov.pagopa.spontaneouspayment.model.response.ServiceModelResponse; +import it.gov.pagopa.spontaneouspayment.service.ServicesService; @Controller public class ServicesController implements IServicesController{ + + @Autowired + private ServicesService servicesService; + + @Autowired + private ModelMapper modelMapper; @Override public ResponseEntity getServiceDetails(@NotBlank String serviceId) { - // TODO Auto-generated method stub - return null; + return new ResponseEntity<>( + modelMapper.map(servicesService.getServiceDetails(serviceId), ServiceDetailModelResponse.class), + HttpStatus.OK); } @Override - public ResponseEntity getServices() { - // TODO Auto-generated method stub - return null; + public ResponseEntity> getServices() { + + return new ResponseEntity<>(servicesService.getServices().stream() + .map(entity -> modelMapper.map(entity, ServiceModelResponse.class)) .collect(Collectors.toList()), + HttpStatus.OK); } } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/entity/Service.java b/src/main/java/it/gov/pagopa/spontaneouspayment/entity/Service.java index 0b56686..b9a52fe 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/entity/Service.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/entity/Service.java @@ -5,6 +5,7 @@ import it.gov.pagopa.spontaneouspayment.model.enumeration.Status; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -21,6 +22,7 @@ @Setter @NoArgsConstructor @AllArgsConstructor +@Builder public class Service { @Id diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/SevicesModelResponse.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/SevicesModelResponse.java deleted file mode 100644 index 8d58bd8..0000000 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/SevicesModelResponse.java +++ /dev/null @@ -1,18 +0,0 @@ -package it.gov.pagopa.spontaneouspayment.model.response; - -import java.io.Serializable; -import java.util.List; - -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class SevicesModelResponse implements Serializable{ - - /** - * generated serialVersionUID - */ - private static final long serialVersionUID = -3078022971085103082L; - private List services; -} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsService.java b/src/main/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsService.java index 03def1d..9bc7236 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsService.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsService.java @@ -138,6 +138,13 @@ public void deleteECEnrollment(String organizationFiscalCode, orgRepository.save(orgEntity); } + public void deleteEC(String organizationFiscalCode) { + // check if the organization fiscal code exists + Organization orgEntity = this.checkOrganizationFiscalCode (organizationFiscalCode); + + orgRepository.delete(orgEntity); + } + public ServiceRef getSingleEnrollment (String organizationFiscalCode, String serviceId) { diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/service/ServicesService.java b/src/main/java/it/gov/pagopa/spontaneouspayment/service/ServicesService.java new file mode 100644 index 0000000..8126bb0 --- /dev/null +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/service/ServicesService.java @@ -0,0 +1,36 @@ +package it.gov.pagopa.spontaneouspayment.service; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import it.gov.pagopa.spontaneouspayment.exception.AppError; +import it.gov.pagopa.spontaneouspayment.exception.AppException; +import it.gov.pagopa.spontaneouspayment.repository.ServiceRepository; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; + +@Service +@AllArgsConstructor +@NoArgsConstructor +public class ServicesService { + + @Autowired + private ServiceRepository serviceRepository; + + public List getServices () { + + Iterable allServices = serviceRepository.findAll(); + + return StreamSupport.stream(allServices.spliterator(), false) + .collect(Collectors.toList()); + } + + public it.gov.pagopa.spontaneouspayment.entity.Service getServiceDetails (String serviceId) { + return serviceRepository.findById(serviceId) + .orElseThrow(() -> new AppException(AppError.SERVICE_NOT_FOUND, serviceId)); + } +} diff --git a/src/test/java/it/gov/pagopa/spontaneouspayment/config/TestUtil.java b/src/test/java/it/gov/pagopa/spontaneouspayment/config/TestUtil.java index 96a426b..1d3d3e3 100644 --- a/src/test/java/it/gov/pagopa/spontaneouspayment/config/TestUtil.java +++ b/src/test/java/it/gov/pagopa/spontaneouspayment/config/TestUtil.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import it.gov.pagopa.spontaneouspayment.entity.Organization; +import it.gov.pagopa.spontaneouspayment.entity.Service; import it.gov.pagopa.spontaneouspayment.entity.ServiceRef; import it.gov.pagopa.spontaneouspayment.model.CreateEnrollmentModel; import it.gov.pagopa.spontaneouspayment.model.DebtorModel; @@ -193,4 +194,16 @@ public static SpontaneousPaymentModel getSpontaneousPaymentModel_BadProperty() { .build(); } + public static List getMockServices() { + List services = new ArrayList<>(); + services.add(Service.builder().id("mockId1").name("mockName1").transferCategory("mockTransferCategory1").remittanceInformation("mockRemittanceInformation1").build()); + services.add(Service.builder().id("mockId2").name("mockName2").transferCategory("mockTransferCategory2").remittanceInformation("mockRemittanceInformation2").build()); + + return services; + } + + public static Service getMockService() { + return Service.builder().id("mockId").name("mockName").transferCategory("mockTransferCategory").remittanceInformation("mockRemittanceInformation").build(); + } + } diff --git a/src/test/java/it/gov/pagopa/spontaneouspayment/controller/ServicesControllerTest.java b/src/test/java/it/gov/pagopa/spontaneouspayment/controller/ServicesControllerTest.java new file mode 100644 index 0000000..d1bef60 --- /dev/null +++ b/src/test/java/it/gov/pagopa/spontaneouspayment/controller/ServicesControllerTest.java @@ -0,0 +1,62 @@ +package it.gov.pagopa.spontaneouspayment.controller; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.when; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.MvcResult; + +import it.gov.pagopa.spontaneouspayment.config.TestUtil; +import it.gov.pagopa.spontaneouspayment.service.ServicesService; + +@SpringBootTest +@AutoConfigureMockMvc +class ServicesControllerTest { + + @Autowired + private MockMvc mvc; + + @MockBean + private ServicesService servicesService; + + @BeforeEach + void setUp() { + when(servicesService.getServices()).thenReturn(TestUtil.getMockServices()); + when(servicesService.getServiceDetails(anyString())).thenReturn(TestUtil.getMockService()); + } + + @Test + void getServices() throws Exception { + String url = "/services"; + MvcResult result = mvc.perform(get(url).contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andReturn(); + assertNotNull(result.getResponse().getContentAsString()); + assertTrue(result.getResponse().getContentAsString().contains("mockId1")); + assertTrue(result.getResponse().getContentAsString().contains("mockId2")); + } + + @Test + void getServiceDetails() throws Exception { + String url = "/services/mockService1"; + MvcResult result = mvc.perform(get(url).contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andReturn(); + assertNotNull(result.getResponse().getContentAsString()); + assertTrue(result.getResponse().getContentAsString().contains("mockId")); + } +} diff --git a/src/test/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsServiceTest.java b/src/test/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsServiceTest.java index a2a7c5e..85f7ceb 100644 --- a/src/test/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsServiceTest.java +++ b/src/test/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsServiceTest.java @@ -472,5 +472,43 @@ void deleteECEnrollment_404() { } } + + @Test + void deleteEC() { + assertTrue(emulator.isRunning()); + // Creates a dummy organization + Organization ci = new Organization(); + ci.setFiscalCode("organizationDummy"); + ci.setCompanyName("Comune di Napoli"); + ci.setStatus(Status.ENABLED); + ServiceRef ref1 = new ServiceRef(); + ref1.setServiceId("id-servizio-1"); + ref1.setIban("iban-1"); + List servicesRef = new ArrayList<>(); + servicesRef.add(ref1); + ci.setEnrollments(servicesRef); + Organization orgCreated = enrollmentsService.createEC(ci); + assertEquals("organizationDummy", orgCreated.getFiscalCode()); + assertEquals("Comune di Napoli", orgCreated.getCompanyName()); + assertEquals(1, orgCreated.getEnrollments().size()); + // Remove the dummy organization + enrollmentsService.deleteEC("organizationDummy"); + // This line means the call was successful + assertTrue(true); + } + + @Test + void deleteEC_404() { + assertTrue(emulator.isRunning()); + try { + // non-existent organization -> must raise a 404 exception + enrollmentsService.deleteEC("organizationFake"); + fail(); + } catch (AppException e) { + assertEquals(HttpStatus.NOT_FOUND, e.getHttpStatus()); + } catch (Exception e) { + fail(); + } + } } diff --git a/src/test/java/it/gov/pagopa/spontaneouspayment/service/ServicesServiceTest.java b/src/test/java/it/gov/pagopa/spontaneouspayment/service/ServicesServiceTest.java new file mode 100644 index 0000000..6956432 --- /dev/null +++ b/src/test/java/it/gov/pagopa/spontaneouspayment/service/ServicesServiceTest.java @@ -0,0 +1,214 @@ +package it.gov.pagopa.spontaneouspayment.service; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.spy; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.file.Path; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Rule; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.rules.TemporaryFolder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.HttpStatus; +import org.testcontainers.containers.CosmosDBEmulatorContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; +import org.testcontainers.utility.DockerImageName; + +import com.azure.cosmos.CosmosAsyncClient; +import com.azure.cosmos.CosmosClientBuilder; +import com.azure.cosmos.models.CosmosContainerResponse; +import com.azure.cosmos.models.CosmosDatabaseResponse; + +import it.gov.pagopa.spontaneouspayment.entity.Organization; +import it.gov.pagopa.spontaneouspayment.entity.Service; +import it.gov.pagopa.spontaneouspayment.entity.ServiceProperty; +import it.gov.pagopa.spontaneouspayment.entity.ServiceRef; +import it.gov.pagopa.spontaneouspayment.exception.AppException; +import it.gov.pagopa.spontaneouspayment.model.enumeration.Status; +import it.gov.pagopa.spontaneouspayment.repository.OrganizationRepository; +import it.gov.pagopa.spontaneouspayment.repository.ServiceRepository; + +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +@SpringBootTest +@Testcontainers +class ServicesServiceTest { + + @Rule + public TemporaryFolder tempFolder = new TemporaryFolder(); + + @Autowired + private OrganizationRepository ciRepository; + + @Autowired + private ServiceRepository serviceRepository; + + @Container + private static final CosmosDBEmulatorContainer emulator = new CosmosDBEmulatorContainer( + DockerImageName.parse("mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest")); + + private static ServicesService servicesService; + + @BeforeAll + public void setUp() throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException { + + servicesService = spy(new ServicesService(serviceRepository)); + + tempFolder.create(); + Path keyStoreFile = tempFolder.newFile("azure-cosmos-emulator.keystore").toPath(); + KeyStore keyStore = emulator.buildNewKeyStore(); + keyStore.store(new FileOutputStream(keyStoreFile.toFile()), emulator.getEmulatorKey().toCharArray()); + + System.setProperty("javax.net.ssl.trustStore", keyStoreFile.toString()); + System.setProperty("javax.net.ssl.trustStorePassword", emulator.getEmulatorKey()); + System.setProperty("javax.net.ssl.trustStoreType", "PKCS12"); + + CosmosAsyncClient client = new CosmosClientBuilder().gatewayMode().endpointDiscoveryEnabled(false) + .endpoint(emulator.getEmulatorEndpoint()).key(emulator.getEmulatorKey()).buildAsyncClient(); + + // creation of the database and containers + CosmosDatabaseResponse databaseResponse = client.createDatabaseIfNotExists("db").block(); + + Assertions.assertEquals(201, databaseResponse.getStatusCode()); + CosmosContainerResponse containerResponse = client.getDatabase("db") + .createContainerIfNotExists("creditor_institutions", "/fiscalCode").block(); + Assertions.assertEquals(201, containerResponse.getStatusCode()); + containerResponse = client.getDatabase("db").createContainerIfNotExists("services", "/fiscalCode").block(); + Assertions.assertEquals(201, containerResponse.getStatusCode()); + + // loading the database with test data + Organization ci = new Organization(); + ci.setFiscalCode("organizationTest"); + ci.setCompanyName("Comune di Roma"); + ci.setStatus(Status.ENABLED); + + Service s1 = new Service(); + s1.setId("id-servizio-1"); + s1.setTransferCategory("tassonomia-1"); + s1.setRemittanceInformation("causale-1"); + s1.setBasePath("base-path-1"); + s1.setEndpoint("endpont-1"); + + ServiceProperty sp1 = new ServiceProperty("propName1", "number", true); + List properties1 = new ArrayList<>(); + properties1.add(sp1); + s1.setProperties(properties1); + + Service s2 = new Service(); + s2.setId("id-servizio-2"); + s2.setTransferCategory("tassonomia-2"); + s2.setRemittanceInformation("causale-2"); + s2.setBasePath("base-path-2"); + s2.setEndpoint("endpont-2"); + + ServiceProperty sp2 = new ServiceProperty("propName2", "string", true); + List properties2 = new ArrayList<>(); + properties2.add(sp2); + s2.setProperties(properties2); + + Service s3 = new Service(); + s3.setId("id-servizio-3"); + s3.setTransferCategory("tassonomia-3"); + s3.setRemittanceInformation("causale-3"); + s3.setBasePath("base-path-3"); + s3.setEndpoint("endpont-3"); + + ServiceProperty sp3 = new ServiceProperty("propName3", "url", true); + List properties3 = new ArrayList<>(); + properties3.add(sp3); + s3.setProperties(properties3); + + Service s4 = new Service(); + s4.setId("id-servizio-4"); + s4.setTransferCategory("tassonomia-4"); + s4.setRemittanceInformation("causale-4"); + s4.setBasePath("base-path-4"); + s4.setEndpoint("endpont-4"); + + ServiceProperty sp4 = new ServiceProperty("propName4", "rule", true); + List properties4 = new ArrayList<>(); + properties4.add(sp4); + s4.setProperties(properties4); + + ServiceRef ref1 = new ServiceRef(); + ref1.setServiceId("id-servizio-1"); + ref1.setIban("iban-1"); + ServiceRef ref2 = new ServiceRef(); + ref2.setServiceId("id-servizio-2"); + ref2.setIban("iban-2"); + List servicesRef = new ArrayList<>(); + servicesRef.add(ref1); + servicesRef.add(ref2); + + ci.setEnrollments(servicesRef); + + ciRepository.deleteAll(); + ciRepository.save(ci); + serviceRepository.deleteAll(); + serviceRepository.save(s1); + serviceRepository.save(s2); + serviceRepository.save(s3); + serviceRepository.save(s4); + } + + @AfterAll + void teardown() { + CosmosAsyncClient client = new CosmosClientBuilder().gatewayMode().endpointDiscoveryEnabled(false) + .endpoint(emulator.getEmulatorEndpoint()).key(emulator.getEmulatorKey()).buildAsyncClient(); + client.getDatabase("db").delete(); + client.close(); + emulator.stop(); + emulator.close(); + System.clearProperty("javax.net.ssl.trustStore"); + System.clearProperty("javax.net.ssl.trustStorePassword"); + System.clearProperty("javax.net.ssl.trustStoreType"); + } + + + @Test + void getServices() { + assertTrue(emulator.isRunning()); + List services = servicesService.getServices(); + assertEquals(4, services.size()); + } + + @Test + void getServiceDetails() { + assertTrue(emulator.isRunning()); + Service s = servicesService.getServiceDetails("id-servizio-1"); + assertEquals("id-servizio-1", s.getId()); + assertEquals("tassonomia-1", s.getTransferCategory()); + assertEquals("causale-1", s.getRemittanceInformation()); + assertEquals("base-path-1", s.getBasePath()); + assertEquals("endpont-1", s.getEndpoint()); + } + + @Test + void getServiceDetails_404() { + assertTrue(emulator.isRunning()); + try { + // non-existent service -> must raise a 404 exception + servicesService.getServiceDetails("id-servizio-fake"); + fail(); + } catch (AppException e) { + assertEquals(HttpStatus.NOT_FOUND, e.getHttpStatus()); + } catch (Exception e) { + fail(); + } + } +} From 60c312286962d8840621d46556b71a6d5dbf2c35 Mon Sep 17 00:00:00 2001 From: Jacopo Date: Thu, 30 Jun 2022 14:31:43 +0200 Subject: [PATCH 15/16] refactor --- openapi/generate_openapi.sh | 2 +- openapi/openapi.json | 3508 ++++++++--------- .../config/AppConfiguration.java | 10 +- .../config/EntityValidator.java | 2 +- .../config/MappingsConfiguration.java | 2 +- .../config/SwaggerConfig.java | 7 + .../controller/IServicesController.java | 22 +- .../impl/EnrollmentsController.java | 172 +- .../controller/impl/PaymentsController.java | 9 +- .../controller/impl/ServicesController.java | 56 +- .../entity/Organization.java | 43 +- .../spontaneouspayment/entity/Service.java | 37 +- .../entity/ServiceProperty.java | 8 +- .../spontaneouspayment/entity/ServiceRef.java | 10 +- .../exception/AppError.java | 14 +- .../model/CreateEnrollmentModel.java | 29 +- .../model/EnrollmentModel.java | 20 +- .../model/OrganizationEnrollmentModel.java | 33 +- .../model/OrganizationModel.java | 20 +- .../model/ServicePropertyModel.java | 14 +- .../model/SpontaneousPaymentModel.java | 20 +- .../response/EnrollmentModelResponse.java | 29 +- .../response/OrganizationModelResponse.java | 31 +- .../response/ServiceDetailModelResponse.java | 57 +- .../model/response/ServiceModelResponse.java | 29 +- .../ServicePropertyModelResponse.java | 23 +- .../repository/OrganizationRepository.java | 2 +- .../service/EnrollmentsService.java | 257 +- .../service/PaymentsService.java | 1 - .../service/ServicesService.java | 37 +- .../service/EnrollmentsServiceTest.java | 56 +- .../service/PaymentsServiceTest.java | 439 ++- 32 files changed, 2492 insertions(+), 2507 deletions(-) diff --git a/openapi/generate_openapi.sh b/openapi/generate_openapi.sh index 01ed71e..7d3f148 100644 --- a/openapi/generate_openapi.sh +++ b/openapi/generate_openapi.sh @@ -1,2 +1,2 @@ #!/bin/bash -curl http://localhost:8080/v3/api-docs | python3 -m json.tool > ./openapi.json +curl http://localhost:9090/v3/api-docs | python3 -m json.tool > ./openapi.json diff --git a/openapi/openapi.json b/openapi/openapi.json index fe5eeca..756c859 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -1,1755 +1,1755 @@ { - "openapi": "3.0.1", - "info": { - "title": "PagoPA API Spontaneous Payment", - "description": "Progetto Gestione Pagamenti Spontanei", - "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.1" - }, - "servers": [ - { - "url": "http://localhost:9090", - "description": "Generated server url" - } - ], - "paths": { - "/organizations/{organizationFiscalCode}": { - "get": { - "tags": [ - "Enrollments API" - ], - "summary": "Return all enrollments for a creditor institution.", - "operationId": "getECEnrollments", - "parameters": [ - { - "name": "organizationFiscalCode", - "in": "path", - "description": "The fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "Obtained all enrollments for the creditor institution.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OrganizationModelResponse" - } - } - } - }, - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "404": { - "description": "Not found the creditor institution.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "put": { - "tags": [ - "Enrollments API" - ], - "summary": "The organization updates the creditor institution.", - "operationId": "updateEC", - "parameters": [ - { - "name": "organizationFiscalCode", - "in": "path", - "description": "The fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OrganizationModel" - } - } - }, - "required": true - }, - "responses": { - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "200": { - "description": "Request updated.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OrganizationModelResponse" - } - } - } - }, - "404": { - "description": "Not found the creditor institution.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "400": { - "description": "Malformed request.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "post": { - "tags": [ - "Enrollments API" - ], - "summary": "The organization creates a creditor institution with possible enrollments to services.", - "operationId": "createEC", - "parameters": [ - { - "name": "organizationFiscalCode", - "in": "path", - "description": "The fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OrganizationEnrollmentModel" - } - } - }, - "required": true - }, - "responses": { - "409": { - "description": "The organization to create already exists.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "201": { - "description": "Request created.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OrganizationModelResponse" - } - } - } - }, - "400": { - "description": "Malformed request.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "delete": { - "tags": [ - "Enrollments API" - ], - "summary": "The organization deletes the creditor institution.", - "operationId": "deleteEC", - "parameters": [ - { - "name": "organizationFiscalCode", - "in": "path", - "description": "The fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "200": { - "description": "Request deleted.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "type": "string" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "404": { - "description": "Not found the creditor institution.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" - } - } - ] - }, - "/organizations/{organizationFiscalCode}/services/{serviceId}": { - "get": { - "tags": [ - "Enrollments API" - ], - "summary": "Return the single enrollment to a service.", - "operationId": "getSingleEnrollment", - "parameters": [ - { - "name": "organizationFiscalCode", - "in": "path", - "description": "The fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "serviceId", - "in": "path", - "description": "The service id to enroll.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "404": { - "description": "Not found the enroll service.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "200": { - "description": "Obtained single enrollment.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/EnrollmentModelResponse" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "put": { - "tags": [ - "Enrollments API" - ], - "summary": "The organization update an enrollment to a service for the creditor institution.", - "operationId": "updateECEnrollment", - "parameters": [ - { - "name": "organizationFiscalCode", - "in": "path", - "description": "The fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "serviceId", - "in": "path", - "description": "The service id to enroll.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/EnrollmentModel" - } - } - }, - "required": true - }, - "responses": { - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "404": { - "description": "Not found the creditor institution or the enroll service.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "200": { - "description": "Request updated.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OrganizationModelResponse" - } - } - } - }, - "400": { - "description": "Malformed request.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "post": { - "tags": [ - "Enrollments API" - ], - "summary": "The organization creates an enrollment to a service for the creditor institution.", - "operationId": "createECEnrollment", - "parameters": [ - { - "name": "organizationFiscalCode", - "in": "path", - "description": "The fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "serviceId", - "in": "path", - "description": "The service id to enroll.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/EnrollmentModel" - } - } - }, - "required": true - }, - "responses": { - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "404": { - "description": "Not found the creditor institution or the enroll service.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "409": { - "description": "The enrollment to the service already exists.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "201": { - "description": "Request created.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OrganizationModelResponse" - } - } - } - }, - "400": { - "description": "Malformed request.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "delete": { - "tags": [ - "Enrollments API" - ], - "summary": "The organization deletes the enrollment to service for the creditor institution.", - "operationId": "deleteECEnrollment", - "parameters": [ - { - "name": "organizationFiscalCode", - "in": "path", - "description": "The fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "serviceId", - "in": "path", - "description": "The service id to enroll.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "200": { - "description": "Request deleted.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "type": "string" - } - } - } - }, - "404": { - "description": "Not found the creditor institution or the enroll service.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" - } - } - ] - }, - "/organizations/{organizationfiscalcode}/spontaneouspayments": { - "post": { - "tags": [ - "Payments API" - ], - "summary": "The Organization creates a spontaneous payment.", - "operationId": "createSpontaneousPayment", - "parameters": [ - { - "name": "organizationfiscalcode", - "in": "path", - "description": "Organization fiscal code, the fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SpontaneousPaymentModel" - } - } - }, - "required": true - }, - "responses": { - "201": { - "description": "Request created.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PaymentPositionModel" - } - } - } - }, - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "400": { - "description": "Malformed request.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "409": { - "description": "Conflict: duplicate debt position found.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" - } - } - ] - }, - "/services": { - "get": { - "tags": [ - "Services API" - ], - "summary": "Return all services.", - "operationId": "getServices", - "responses": { - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "200": { - "description": "Obtained all services.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ServiceModelResponse" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" - } - } - ] - }, - "/services/{serviceId}": { - "get": { - "tags": [ - "Services API" - ], - "summary": "Return the single service details.", - "operationId": "getServiceDetails", - "parameters": [ - { - "name": "serviceId", - "in": "path", - "description": "The service id for which to have the details.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "200": { - "description": "Obtained single service details.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ServiceDetailModelResponse" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "404": { - "description": "No service found.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" - } - } - ] - } - }, - "components": { - "schemas": { - "OrganizationModel": { - "type": "object", - "properties": { - "companyName": { - "type": "string" - }, - "status": { - "type": "string", - "enum": [ - "ENABLED", - "DISABLED" - ] - } - } - }, - "ProblemJson": { - "type": "object", - "properties": { - "title": { - "type": "string", - "description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" - }, - "status": { - "maximum": 600, - "minimum": 100, - "type": "integer", - "description": "The HTTP status code generated by the origin server for this occurrence of the problem.", - "format": "int32", - "example": 200 - }, - "detail": { - "type": "string", - "description": "A human readable explanation specific to this occurrence of the problem.", - "example": "There was an error processing the request" - } - } - }, - "EnrollmentModelResponse": { - "required": [ - "iban", - "serviceId" - ], - "type": "object", - "properties": { - "serviceId": { - "type": "string" - }, - "iban": { - "type": "string" - }, - "officeName": { - "type": "string" - } - } - }, - "OrganizationModelResponse": { - "required": [ - "companyName", - "fiscalCode", - "status" - ], - "type": "object", - "properties": { - "fiscalCode": { - "type": "string" - }, - "companyName": { - "type": "string" - }, - "status": { - "type": "string", - "enum": [ - "ENABLED", - "DISABLED" - ] - }, - "enrollments": { - "type": "array", - "items": { - "$ref": "#/components/schemas/EnrollmentModelResponse" - } - } - } - }, - "EnrollmentModel": { - "type": "object", - "properties": { - "iban": { - "type": "string" - }, - "officeName": { - "type": "string" - } - } - }, - "DebtorModel": { - "required": [ - "fiscalCode", - "fullName", - "type" - ], - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": [ - "F", - "G" - ] - }, - "fiscalCode": { - "type": "string" - }, - "fullName": { - "type": "string" - }, - "streetName": { - "type": "string" - }, - "civicNumber": { - "type": "string" - }, - "postalCode": { - "type": "string" - }, - "city": { - "type": "string" - }, - "province": { - "type": "string" - }, - "region": { - "type": "string" - }, - "country": { - "type": "string" - }, - "email": { - "type": "string" - }, - "phone": { - "type": "string" - } - } - }, - "ServiceModel": { - "required": [ - "id", - "properties" - ], - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "properties": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ServicePropertyModel" - } - } - } - }, - "ServicePropertyModel": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "value": { - "type": "string" - } - } - }, - "SpontaneousPaymentModel": { - "required": [ - "debtor", - "service" - ], - "type": "object", - "properties": { - "debtor": { - "$ref": "#/components/schemas/DebtorModel" - }, - "service": { - "$ref": "#/components/schemas/ServiceModel" - } - } - }, - "PaymentOptionModel": { - "required": [ - "amount", - "dueDate", - "isPartialPayment", - "iuv" - ], - "type": "object", - "properties": { - "iuv": { - "type": "string" - }, - "amount": { - "type": "integer", - "format": "int64" - }, - "description": { - "type": "string" - }, - "isPartialPayment": { - "type": "boolean" - }, - "dueDate": { - "type": "string", - "format": "date-time" - }, - "retentionDate": { - "type": "string", - "format": "date-time" - }, - "fee": { - "type": "integer", - "format": "int64" - }, - "transfer": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TransferModel" - } - } - } - }, - "PaymentPositionModel": { - "required": [ - "companyName", - "fiscalCode", - "fullName", - "iupd", - "type" - ], - "type": "object", - "properties": { - "iupd": { - "type": "string" - }, - "type": { - "type": "string", - "enum": [ - "F", - "G" - ] - }, - "fiscalCode": { - "type": "string" - }, - "fullName": { - "type": "string" - }, - "streetName": { - "type": "string" - }, - "civicNumber": { - "type": "string" - }, - "postalCode": { - "type": "string" - }, - "city": { - "type": "string" - }, - "province": { - "type": "string" - }, - "region": { - "type": "string" - }, - "country": { - "type": "string" - }, - "email": { - "type": "string" - }, - "phone": { - "type": "string" - }, - "switchToExpired": { - "type": "boolean", - "description": "feature flag to enable the debt position to expire after the due date", - "example": false, - "default": false - }, - "companyName": { - "type": "string" - }, - "officeName": { - "type": "string" - }, - "validityDate": { - "type": "string", - "format": "date-time" - }, - "status": { - "type": "string", - "readOnly": true, - "enum": [ - "DRAFT", - "PUBLISHED", - "VALID", - "INVALID", - "EXPIRED", - "PARTIALLY_PAID", - "PAID", - "REPORTED" - ] - }, - "paymentOption": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PaymentOptionModel" - } - } - } - }, - "TransferModel": { - "required": [ - "amount", - "category", - "iban", - "idTransfer", - "remittanceInformation" - ], - "type": "object", - "properties": { - "idTransfer": { - "type": "string", - "enum": [ - "1", - "2", - "3", - "4", - "5" - ] - }, - "amount": { - "type": "integer", - "format": "int64" - }, - "remittanceInformation": { - "type": "string" - }, - "category": { - "type": "string" - }, - "iban": { - "type": "string" - }, - "postalIban": { - "type": "string" - } - } - }, - "CreateEnrollmentModel": { - "required": [ - "iban", - "serviceId" - ], - "type": "object", - "properties": { - "serviceId": { - "type": "string" - }, - "iban": { - "type": "string" - }, - "officeName": { - "type": "string" - } - } - }, - "OrganizationEnrollmentModel": { - "required": [ - "companyName" - ], - "type": "object", - "properties": { - "companyName": { - "type": "string" - }, - "enrollments": { - "type": "array", - "items": { - "$ref": "#/components/schemas/CreateEnrollmentModel" - } - } - } - }, - "ServiceModelResponse": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "description": { - "type": "string" - } - } - }, - "ServiceDetailModelResponse": { - "required": [ - "id", - "remittanceInformation", - "status", - "transferCategory" - ], - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "description": { - "type": "string" - }, - "transferCategory": { - "type": "string" - }, - "remittanceInformation": { - "type": "string" - }, - "status": { - "type": "string", - "enum": [ - "ENABLED", - "DISABLED" - ] - }, - "properties": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ServicePropertyModelResponse" - } - } - } - }, - "ServicePropertyModelResponse": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "type": { - "type": "string" - }, - "required": { - "type": "boolean" - } - } - } - }, - "securitySchemes": { - "ApiKey": { - "type": "apiKey", - "description": "The API key to access this function app.", - "name": "Ocp-Apim-Subscription-Key", - "in": "header" - }, - "Authorization": { - "type": "http", - "description": "JWT token get after Azure Login", - "scheme": "bearer", - "bearerFormat": "JWT" - } - } - } -} \ No newline at end of file + "openapi": "3.0.1", + "info": { + "title": "PagoPA API Spontaneous Payment", + "description": "Progetto Gestione Pagamenti Spontanei", + "termsOfService": "https://www.pagopa.gov.it/", + "version": "0.0.1" + }, + "servers": [ + { + "url": "http://localhost:9090", + "description": "Generated server url" + } + ], + "paths": { + "/organizations/{organizationFiscalCode}": { + "get": { + "tags": [ + "Enrollments API" + ], + "summary": "Return all enrollments for a creditor institution.", + "operationId": "getECEnrollments", + "parameters": [ + { + "name": "organizationFiscalCode", + "in": "path", + "description": "The fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Obtained all enrollments for the creditor institution.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationModelResponse" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found the creditor institution.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "put": { + "tags": [ + "Enrollments API" + ], + "summary": "The organization updates the creditor institution.", + "operationId": "updateEC", + "parameters": [ + { + "name": "organizationFiscalCode", + "in": "path", + "description": "The fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationModel" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Request updated.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationModelResponse" + } + } + } + }, + "400": { + "description": "Malformed request.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found the creditor institution.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "post": { + "tags": [ + "Enrollments API" + ], + "summary": "The organization creates a creditor institution with possible enrollments to services.", + "operationId": "createEC", + "parameters": [ + { + "name": "organizationFiscalCode", + "in": "path", + "description": "The fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationEnrollmentModel" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Request created.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationModelResponse" + } + } + } + }, + "400": { + "description": "Malformed request.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "409": { + "description": "The organization to create already exists.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "delete": { + "tags": [ + "Enrollments API" + ], + "summary": "The organization deletes the creditor institution.", + "operationId": "deleteEC", + "parameters": [ + { + "name": "organizationFiscalCode", + "in": "path", + "description": "The fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Request deleted.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found the creditor institution.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "parameters": [ + { + "name": "X-Request-Id", + "in": "header", + "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema": { + "type": "string" + } + } + ] + }, + "/organizations/{organizationFiscalCode}/services/{serviceId}": { + "get": { + "tags": [ + "Enrollments API" + ], + "summary": "Return the single enrollment to a service.", + "operationId": "getSingleEnrollment", + "parameters": [ + { + "name": "organizationFiscalCode", + "in": "path", + "description": "The fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "serviceId", + "in": "path", + "description": "The service id to enroll.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Obtained single enrollment.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EnrollmentModelResponse" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found the enroll service.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "put": { + "tags": [ + "Enrollments API" + ], + "summary": "The organization update an enrollment to a service for the creditor institution.", + "operationId": "updateECEnrollment", + "parameters": [ + { + "name": "organizationFiscalCode", + "in": "path", + "description": "The fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "serviceId", + "in": "path", + "description": "The service id to enroll.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EnrollmentModel" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Request updated.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationModelResponse" + } + } + } + }, + "400": { + "description": "Malformed request.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found the creditor institution or the enroll service.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "post": { + "tags": [ + "Enrollments API" + ], + "summary": "The organization creates an enrollment to a service for the creditor institution.", + "operationId": "createECEnrollment", + "parameters": [ + { + "name": "organizationFiscalCode", + "in": "path", + "description": "The fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "serviceId", + "in": "path", + "description": "The service id to enroll.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EnrollmentModel" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Request created.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationModelResponse" + } + } + } + }, + "400": { + "description": "Malformed request.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found the creditor institution or the enroll service.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "409": { + "description": "The enrollment to the service already exists.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "delete": { + "tags": [ + "Enrollments API" + ], + "summary": "The organization deletes the enrollment to service for the creditor institution.", + "operationId": "deleteECEnrollment", + "parameters": [ + { + "name": "organizationFiscalCode", + "in": "path", + "description": "The fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "serviceId", + "in": "path", + "description": "The service id to enroll.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Request deleted.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found the creditor institution or the enroll service.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "parameters": [ + { + "name": "X-Request-Id", + "in": "header", + "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema": { + "type": "string" + } + } + ] + }, + "/organizations/{organizationfiscalcode}/spontaneouspayments": { + "post": { + "tags": [ + "Payments API" + ], + "summary": "The Organization creates a spontaneous payment.", + "operationId": "createSpontaneousPayment", + "parameters": [ + { + "name": "organizationfiscalcode", + "in": "path", + "description": "Organization fiscal code, the fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SpontaneousPaymentModel" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Request created.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PaymentPositionModel" + } + } + } + }, + "400": { + "description": "Malformed request.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "409": { + "description": "Conflict: duplicate debt position found.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "parameters": [ + { + "name": "X-Request-Id", + "in": "header", + "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema": { + "type": "string" + } + } + ] + }, + "/services": { + "get": { + "tags": [ + "Services API" + ], + "summary": "Return all services.", + "operationId": "getServices", + "responses": { + "200": { + "description": "Obtained all services.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ServiceModelResponse" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "parameters": [ + { + "name": "X-Request-Id", + "in": "header", + "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema": { + "type": "string" + } + } + ] + }, + "/services/{serviceId}": { + "get": { + "tags": [ + "Services API" + ], + "summary": "Return the single service details.", + "operationId": "getServiceDetails", + "parameters": [ + { + "name": "serviceId", + "in": "path", + "description": "The service id for which to have the details.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Obtained single service details.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ServiceDetailModelResponse" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "No service found.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "parameters": [ + { + "name": "X-Request-Id", + "in": "header", + "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema": { + "type": "string" + } + } + ] + } + }, + "components": { + "schemas": { + "OrganizationModel": { + "type": "object", + "properties": { + "companyName": { + "type": "string" + }, + "status": { + "type": "string", + "enum": [ + "ENABLED", + "DISABLED" + ] + } + } + }, + "EnrollmentModelResponse": { + "required": [ + "iban", + "serviceId" + ], + "type": "object", + "properties": { + "serviceId": { + "type": "string" + }, + "iban": { + "type": "string" + }, + "officeName": { + "type": "string" + } + } + }, + "OrganizationModelResponse": { + "required": [ + "companyName", + "fiscalCode", + "status" + ], + "type": "object", + "properties": { + "fiscalCode": { + "type": "string" + }, + "companyName": { + "type": "string" + }, + "status": { + "type": "string", + "enum": [ + "ENABLED", + "DISABLED" + ] + }, + "enrollments": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EnrollmentModelResponse" + } + } + } + }, + "ProblemJson": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" + }, + "status": { + "maximum": 600, + "minimum": 100, + "type": "integer", + "description": "The HTTP status code generated by the origin server for this occurrence of the problem.", + "format": "int32", + "example": 200 + }, + "detail": { + "type": "string", + "description": "A human readable explanation specific to this occurrence of the problem.", + "example": "There was an error processing the request" + } + } + }, + "EnrollmentModel": { + "type": "object", + "properties": { + "iban": { + "type": "string" + }, + "officeName": { + "type": "string" + } + } + }, + "DebtorModel": { + "required": [ + "fiscalCode", + "fullName", + "type" + ], + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "F", + "G" + ] + }, + "fiscalCode": { + "type": "string" + }, + "fullName": { + "type": "string" + }, + "streetName": { + "type": "string" + }, + "civicNumber": { + "type": "string" + }, + "postalCode": { + "type": "string" + }, + "city": { + "type": "string" + }, + "province": { + "type": "string" + }, + "region": { + "type": "string" + }, + "country": { + "type": "string" + }, + "email": { + "type": "string" + }, + "phone": { + "type": "string" + } + } + }, + "ServiceModel": { + "required": [ + "id", + "properties" + ], + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "properties": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ServicePropertyModel" + } + } + } + }, + "ServicePropertyModel": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "SpontaneousPaymentModel": { + "required": [ + "debtor", + "service" + ], + "type": "object", + "properties": { + "debtor": { + "$ref": "#/components/schemas/DebtorModel" + }, + "service": { + "$ref": "#/components/schemas/ServiceModel" + } + } + }, + "PaymentOptionModel": { + "required": [ + "amount", + "dueDate", + "isPartialPayment", + "iuv" + ], + "type": "object", + "properties": { + "iuv": { + "type": "string" + }, + "amount": { + "type": "integer", + "format": "int64" + }, + "description": { + "type": "string" + }, + "isPartialPayment": { + "type": "boolean" + }, + "dueDate": { + "type": "string", + "format": "date-time" + }, + "retentionDate": { + "type": "string", + "format": "date-time" + }, + "fee": { + "type": "integer", + "format": "int64" + }, + "transfer": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TransferModel" + } + } + } + }, + "PaymentPositionModel": { + "required": [ + "companyName", + "fiscalCode", + "fullName", + "iupd", + "type" + ], + "type": "object", + "properties": { + "iupd": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "F", + "G" + ] + }, + "fiscalCode": { + "type": "string" + }, + "fullName": { + "type": "string" + }, + "streetName": { + "type": "string" + }, + "civicNumber": { + "type": "string" + }, + "postalCode": { + "type": "string" + }, + "city": { + "type": "string" + }, + "province": { + "type": "string" + }, + "region": { + "type": "string" + }, + "country": { + "type": "string" + }, + "email": { + "type": "string" + }, + "phone": { + "type": "string" + }, + "switchToExpired": { + "type": "boolean", + "description": "feature flag to enable the debt position to expire after the due date", + "example": false, + "default": false + }, + "companyName": { + "type": "string" + }, + "officeName": { + "type": "string" + }, + "validityDate": { + "type": "string", + "format": "date-time" + }, + "status": { + "type": "string", + "readOnly": true, + "enum": [ + "DRAFT", + "PUBLISHED", + "VALID", + "INVALID", + "EXPIRED", + "PARTIALLY_PAID", + "PAID", + "REPORTED" + ] + }, + "paymentOption": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PaymentOptionModel" + } + } + } + }, + "TransferModel": { + "required": [ + "amount", + "category", + "iban", + "idTransfer", + "remittanceInformation" + ], + "type": "object", + "properties": { + "idTransfer": { + "type": "string", + "enum": [ + "1", + "2", + "3", + "4", + "5" + ] + }, + "amount": { + "type": "integer", + "format": "int64" + }, + "remittanceInformation": { + "type": "string" + }, + "category": { + "type": "string" + }, + "iban": { + "type": "string" + }, + "postalIban": { + "type": "string" + } + } + }, + "CreateEnrollmentModel": { + "required": [ + "iban", + "serviceId" + ], + "type": "object", + "properties": { + "serviceId": { + "type": "string" + }, + "iban": { + "type": "string" + }, + "officeName": { + "type": "string" + } + } + }, + "OrganizationEnrollmentModel": { + "required": [ + "companyName" + ], + "type": "object", + "properties": { + "companyName": { + "type": "string" + }, + "enrollments": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CreateEnrollmentModel" + } + } + } + }, + "ServiceModelResponse": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + } + } + }, + "ServiceDetailModelResponse": { + "required": [ + "id", + "remittanceInformation", + "status", + "transferCategory" + ], + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "transferCategory": { + "type": "string" + }, + "remittanceInformation": { + "type": "string" + }, + "status": { + "type": "string", + "enum": [ + "ENABLED", + "DISABLED" + ] + }, + "properties": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ServicePropertyModelResponse" + } + } + } + }, + "ServicePropertyModelResponse": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "required": { + "type": "boolean" + } + } + } + }, + "securitySchemes": { + "ApiKey": { + "type": "apiKey", + "description": "The API key to access this function app.", + "name": "Ocp-Apim-Subscription-Key", + "in": "header" + }, + "Authorization": { + "type": "http", + "description": "JWT token get after Azure Login", + "scheme": "bearer", + "bearerFormat": "JWT" + } + } + } +} diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/config/AppConfiguration.java b/src/main/java/it/gov/pagopa/spontaneouspayment/config/AppConfiguration.java index d1dcac5..9358929 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/config/AppConfiguration.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/config/AppConfiguration.java @@ -1,10 +1,6 @@ package it.gov.pagopa.spontaneouspayment.config; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.lang.Nullable; import com.azure.core.credential.AzureKeyCredential; import com.azure.cosmos.CosmosClientBuilder; import com.azure.cosmos.DirectConnectionConfig; @@ -15,6 +11,10 @@ import com.azure.spring.data.cosmos.core.ResponseDiagnosticsProcessor; import com.azure.spring.data.cosmos.repository.config.EnableCosmosRepositories; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.lang.Nullable; @Configuration @EnableCosmosRepositories @@ -36,7 +36,7 @@ public class AppConfiguration extends AbstractCosmosConfiguration { @Bean public CosmosClientBuilder getCosmosClientBuilder() { - AzureKeyCredential azureKeyCredential = new AzureKeyCredential(key); + AzureKeyCredential azureKeyCredential = new AzureKeyCredential(key); DirectConnectionConfig directConnectionConfig = new DirectConnectionConfig(); GatewayConnectionConfig gatewayConnectionConfig = new GatewayConnectionConfig(); return new CosmosClientBuilder() diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/config/EntityValidator.java b/src/main/java/it/gov/pagopa/spontaneouspayment/config/EntityValidator.java index ce8c618..f6f7065 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/config/EntityValidator.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/config/EntityValidator.java @@ -28,7 +28,7 @@ public class EntityValidator { * @param joinPoint not used * @param result the response to validate */ - @AfterReturning(pointcut = "execution(* it.gov.pagopa.spontaneouspayment.repository.impl.*.*(..))", returning = "result") + @AfterReturning(pointcut = "execution(* it.gov.pagopa.spontaneouspayment.repository.*.*(..))", returning = "result") public void validateResponse(JoinPoint joinPoint, Object result) { if (result instanceof ResponseEntity) { validateResponse((ResponseEntity) result); diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/config/MappingsConfiguration.java b/src/main/java/it/gov/pagopa/spontaneouspayment/config/MappingsConfiguration.java index 9ee828a..6270a50 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/config/MappingsConfiguration.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/config/MappingsConfiguration.java @@ -12,7 +12,7 @@ public class MappingsConfiguration { @Bean public ModelMapper modelMapper() { ModelMapper mapper = new ModelMapper(); - mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); return mapper; } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/config/SwaggerConfig.java b/src/main/java/it/gov/pagopa/spontaneouspayment/config/SwaggerConfig.java index 14c58f1..796c64c 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/config/SwaggerConfig.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/config/SwaggerConfig.java @@ -7,6 +7,7 @@ import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.media.StringSchema; import io.swagger.v3.oas.models.parameters.Parameter; +import io.swagger.v3.oas.models.responses.ApiResponses; import io.swagger.v3.oas.models.security.SecurityScheme; import org.springdoc.core.customizers.OpenApiCustomiser; import org.springframework.beans.factory.annotation.Value; @@ -54,6 +55,12 @@ public OpenApiCustomiser sortOperationsAlphabetically() { .sorted(Map.Entry.comparingByKey()) .collect(Paths::new, (map, item) -> map.addPathItem(item.getKey(), item.getValue()), Paths::putAll); + paths.forEach((key, value) -> value.readOperations().forEach(operation -> { + var responses = operation.getResponses().entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(ApiResponses::new, (map, item) -> map.addApiResponse(item.getKey(), item.getValue()), ApiResponses::putAll); + operation.setResponses(responses); + })); openApi.setPaths(paths); }; } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IServicesController.java b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IServicesController.java index 8d837fe..5168277 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IServicesController.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/IServicesController.java @@ -1,16 +1,5 @@ package it.gov.pagopa.spontaneouspayment.controller; -import java.util.List; - -import javax.validation.constraints.NotBlank; - -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; - import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; @@ -22,6 +11,15 @@ import it.gov.pagopa.spontaneouspayment.model.ProblemJson; import it.gov.pagopa.spontaneouspayment.model.response.ServiceDetailModelResponse; import it.gov.pagopa.spontaneouspayment.model.response.ServiceModelResponse; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; + +import javax.validation.constraints.NotBlank; +import java.util.List; @Tag(name = "Services API") @@ -40,7 +38,7 @@ public interface IServicesController { ResponseEntity getServiceDetails( @Parameter(description = "The service id for which to have the details.", required = true) @NotBlank @PathVariable("serviceId") String serviceId); - + @Operation(summary = "Return all services.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "getServices") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Obtained all services.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "ServiceModelResponse", implementation = ServiceModelResponse.class))), diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/EnrollmentsController.java b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/EnrollmentsController.java index 98668f9..9674464 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/EnrollmentsController.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/EnrollmentsController.java @@ -1,14 +1,5 @@ package it.gov.pagopa.spontaneouspayment.controller.impl; -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; - -import org.modelmapper.ModelMapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; - import it.gov.pagopa.spontaneouspayment.controller.IEnrollmentsController; import it.gov.pagopa.spontaneouspayment.entity.Organization; import it.gov.pagopa.spontaneouspayment.model.EnrollmentModel; @@ -18,90 +9,97 @@ import it.gov.pagopa.spontaneouspayment.model.response.EnrollmentModelResponse; import it.gov.pagopa.spontaneouspayment.model.response.OrganizationModelResponse; import it.gov.pagopa.spontaneouspayment.service.EnrollmentsService; +import org.modelmapper.ModelMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; @Controller -public class EnrollmentsController implements IEnrollmentsController{ - +public class EnrollmentsController implements IEnrollmentsController { + @Autowired private EnrollmentsService enrollmentsService; - + @Autowired private ModelMapper modelMapper; - @Override - public ResponseEntity createEC(@NotBlank String organizationFiscalCode, - @Valid OrganizationEnrollmentModel organizationEnrollmentModel) { - - // flip model to entity - Organization orgEntity = modelMapper.map(organizationEnrollmentModel, Organization.class); - orgEntity.setFiscalCode(organizationFiscalCode); - orgEntity.setStatus(Status.ENABLED); - - return new ResponseEntity<>( - modelMapper.map(enrollmentsService.createEC(orgEntity), OrganizationModelResponse.class), - HttpStatus.CREATED); - } - - @Override - public ResponseEntity createECEnrollment(@NotBlank String organizationFiscalCode, - @NotBlank String serviceId, @Valid EnrollmentModel enrollmentModel) { - return new ResponseEntity<>( - modelMapper.map(enrollmentsService.createECEnrollment(organizationFiscalCode, serviceId, enrollmentModel), - OrganizationModelResponse.class), - HttpStatus.CREATED); - } - - @Override - public ResponseEntity updateECEnrollment(@NotBlank String organizationFiscalCode, - @NotBlank String serviceId, @Valid EnrollmentModel enrollmentModel) { - return new ResponseEntity<>( - modelMapper.map(enrollmentsService.updateECEnrollment(organizationFiscalCode, serviceId, enrollmentModel), - OrganizationModelResponse.class), - HttpStatus.OK); - } - - @Override - public ResponseEntity updateEC(@NotBlank String organizationFiscalCode, - @Valid OrganizationModel organizationModel) { - return new ResponseEntity<>( - modelMapper.map(enrollmentsService.updateEC(organizationFiscalCode, organizationModel), - OrganizationModelResponse.class), - HttpStatus.OK); - } - - @Override - public ResponseEntity deleteECEnrollment(@NotBlank String organizationFiscalCode, - @NotBlank String serviceId) { - enrollmentsService.deleteECEnrollment(organizationFiscalCode, serviceId); - return new ResponseEntity<>( - "\"The enrollment to service "+serviceId+" for "+organizationFiscalCode+" was successfully removed\"", - HttpStatus.OK); - - } - - @Override - public ResponseEntity deleteEC(@NotBlank String organizationFiscalCode) { - enrollmentsService.deleteEC(organizationFiscalCode); - return new ResponseEntity<>( - "\"The organization "+organizationFiscalCode+" was successfully removed\"", - HttpStatus.OK); - } - - @Override - public ResponseEntity getSingleEnrollment(@NotBlank String organizationFiscalCode, - @NotBlank String serviceId) { - return new ResponseEntity<>( - modelMapper.map(enrollmentsService.getSingleEnrollment(organizationFiscalCode, serviceId), EnrollmentModelResponse.class), - HttpStatus.OK); - } - - @Override - public ResponseEntity getECEnrollments(@NotBlank String organizationFiscalCode) { - return new ResponseEntity<>( - modelMapper.map(enrollmentsService.getECEnrollments(organizationFiscalCode), OrganizationModelResponse.class), - HttpStatus.OK); - } - - + @Override + public ResponseEntity createEC(@NotBlank String organizationFiscalCode, + @Valid OrganizationEnrollmentModel organizationEnrollmentModel) { + + // flip model to entity + Organization orgEntity = modelMapper.map(organizationEnrollmentModel, Organization.class); + orgEntity.setFiscalCode(organizationFiscalCode); + orgEntity.setStatus(Status.ENABLED); + + return new ResponseEntity<>( + modelMapper.map(enrollmentsService.createEC(orgEntity), OrganizationModelResponse.class), + HttpStatus.CREATED); + } + + @Override + public ResponseEntity createECEnrollment(@NotBlank String organizationFiscalCode, + @NotBlank String serviceId, @Valid EnrollmentModel enrollmentModel) { + return new ResponseEntity<>( + modelMapper.map(enrollmentsService.createECEnrollment(organizationFiscalCode, serviceId, enrollmentModel), + OrganizationModelResponse.class), + HttpStatus.CREATED); + } + + @Override + public ResponseEntity updateECEnrollment(@NotBlank String organizationFiscalCode, + @NotBlank String serviceId, @Valid EnrollmentModel enrollmentModel) { + return new ResponseEntity<>( + modelMapper.map(enrollmentsService.updateECEnrollment(organizationFiscalCode, serviceId, enrollmentModel), + OrganizationModelResponse.class), + HttpStatus.OK); + } + + @Override + public ResponseEntity updateEC(@NotBlank String organizationFiscalCode, + @Valid OrganizationModel organizationModel) { + return new ResponseEntity<>( + modelMapper.map(enrollmentsService.updateEC(organizationFiscalCode, organizationModel), + OrganizationModelResponse.class), + HttpStatus.OK); + } + + @Override + public ResponseEntity deleteECEnrollment(@NotBlank String organizationFiscalCode, + @NotBlank String serviceId) { + enrollmentsService.deleteECEnrollment(organizationFiscalCode, serviceId); + return new ResponseEntity<>( + "\"The enrollment to service " + serviceId + " for " + organizationFiscalCode + " was successfully removed\"", + HttpStatus.OK); + + } + + @Override + public ResponseEntity deleteEC(@NotBlank String organizationFiscalCode) { + enrollmentsService.deleteEC(organizationFiscalCode); + return new ResponseEntity<>( + "\"The organization " + organizationFiscalCode + " was successfully removed\"", + HttpStatus.OK); + } + + @Override + public ResponseEntity getSingleEnrollment(@NotBlank String organizationFiscalCode, + @NotBlank String serviceId) { + return new ResponseEntity<>( + modelMapper.map(enrollmentsService.getSingleEnrollment(organizationFiscalCode, serviceId), EnrollmentModelResponse.class), + HttpStatus.OK); + } + + @Override + public ResponseEntity getECEnrollments(@NotBlank String organizationFiscalCode) { + return new ResponseEntity<>( + modelMapper.map(enrollmentsService.getECEnrollments(organizationFiscalCode), OrganizationModelResponse.class), + HttpStatus.OK); + } + } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/PaymentsController.java b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/PaymentsController.java index d5924ee..4ca9547 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/PaymentsController.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/PaymentsController.java @@ -1,14 +1,13 @@ package it.gov.pagopa.spontaneouspayment.controller.impl; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; - import it.gov.pagopa.spontaneouspayment.controller.IPaymentsController; import it.gov.pagopa.spontaneouspayment.model.SpontaneousPaymentModel; import it.gov.pagopa.spontaneouspayment.model.response.PaymentPositionModel; import it.gov.pagopa.spontaneouspayment.service.PaymentsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; @Controller public class PaymentsController implements IPaymentsController { diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/ServicesController.java b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/ServicesController.java index 63c36a1..67d7328 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/ServicesController.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/controller/impl/ServicesController.java @@ -1,43 +1,41 @@ package it.gov.pagopa.spontaneouspayment.controller.impl; -import java.util.List; -import java.util.stream.Collectors; - -import javax.validation.constraints.NotBlank; - +import it.gov.pagopa.spontaneouspayment.controller.IServicesController; +import it.gov.pagopa.spontaneouspayment.model.response.ServiceDetailModelResponse; +import it.gov.pagopa.spontaneouspayment.model.response.ServiceModelResponse; +import it.gov.pagopa.spontaneouspayment.service.ServicesService; import org.modelmapper.ModelMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -import it.gov.pagopa.spontaneouspayment.controller.IServicesController; -import it.gov.pagopa.spontaneouspayment.model.response.ServiceDetailModelResponse; -import it.gov.pagopa.spontaneouspayment.model.response.ServiceModelResponse; -import it.gov.pagopa.spontaneouspayment.service.ServicesService; +import javax.validation.constraints.NotBlank; +import java.util.List; +import java.util.stream.Collectors; @Controller -public class ServicesController implements IServicesController{ - - @Autowired +public class ServicesController implements IServicesController { + + @Autowired private ServicesService servicesService; - - @Autowired - private ModelMapper modelMapper; - - @Override - public ResponseEntity getServiceDetails(@NotBlank String serviceId) { - return new ResponseEntity<>( - modelMapper.map(servicesService.getServiceDetails(serviceId), ServiceDetailModelResponse.class), - HttpStatus.OK); - } - - @Override - public ResponseEntity> getServices() { - - return new ResponseEntity<>(servicesService.getServices().stream() - .map(entity -> modelMapper.map(entity, ServiceModelResponse.class)) .collect(Collectors.toList()), + + @Autowired + private ModelMapper modelMapper; + + @Override + public ResponseEntity getServiceDetails(@NotBlank String serviceId) { + return new ResponseEntity<>( + modelMapper.map(servicesService.getServiceDetails(serviceId), ServiceDetailModelResponse.class), + HttpStatus.OK); + } + + @Override + public ResponseEntity> getServices() { + + return new ResponseEntity<>(servicesService.getServices().stream() + .map(entity -> modelMapper.map(entity, ServiceModelResponse.class)).collect(Collectors.toList()), HttpStatus.OK); - } + } } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/entity/Organization.java b/src/main/java/it/gov/pagopa/spontaneouspayment/entity/Organization.java index fb42678..a9ea356 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/entity/Organization.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/entity/Organization.java @@ -1,24 +1,21 @@ package it.gov.pagopa.spontaneouspayment.entity; -import java.time.LocalDateTime; -import java.util.List; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; - -import org.springframework.data.annotation.CreatedDate; -import org.springframework.data.annotation.Id; -import org.springframework.data.annotation.LastModifiedDate; - import com.azure.spring.data.cosmos.core.mapping.Container; import com.azure.spring.data.cosmos.core.mapping.PartitionKey; - import it.gov.pagopa.spontaneouspayment.model.enumeration.Status; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.Id; +import org.springframework.data.annotation.LastModifiedDate; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import java.time.LocalDateTime; +import java.util.List; @Container(containerName = "${azure.cosmos.ec-container-name}", autoCreateContainer = false) @Getter @@ -29,22 +26,22 @@ public class Organization { - @Id - @PartitionKey - private String fiscalCode; + @Id + @PartitionKey + private String fiscalCode; - @NotBlank(message = "company name is required") - private String companyName; + @NotBlank(message = "company name is required") + private String companyName; - @CreatedDate - private LocalDateTime insertedDate; + @CreatedDate + private LocalDateTime insertedDate; - @LastModifiedDate - private LocalDateTime lastUpdatedDate; + @LastModifiedDate + private LocalDateTime lastUpdatedDate; - private Status status; + private Status status; - @Valid - private List enrollments; + @Valid + private List enrollments; } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/entity/Service.java b/src/main/java/it/gov/pagopa/spontaneouspayment/entity/Service.java index b9a52fe..2c65aa4 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/entity/Service.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/entity/Service.java @@ -2,7 +2,6 @@ import com.azure.spring.data.cosmos.core.mapping.Container; import com.azure.spring.data.cosmos.core.mapping.PartitionKey; - import it.gov.pagopa.spontaneouspayment.model.enumeration.Status; import lombok.AllArgsConstructor; import lombok.Builder; @@ -25,34 +24,34 @@ @Builder public class Service { - @Id - private String id; + @Id + private String id; - @NotBlank(message = "name is required") - private String name; + @NotBlank(message = "name is required") + private String name; - private String description; + private String description; - @NotBlank(message = "transfer category is required") - @PartitionKey - private String transferCategory; // tassonomia + @NotBlank(message = "transfer category is required") + @PartitionKey + private String transferCategory; // tassonomia - @NotBlank(message = "remittance information is required") - private String remittanceInformation; // causale + @NotBlank(message = "remittance information is required") + private String remittanceInformation; // causale - @CreatedDate - private LocalDateTime insertedDate; + @CreatedDate + private LocalDateTime insertedDate; - @LastModifiedDate - private LocalDateTime lastUpdatedDate; + @LastModifiedDate + private LocalDateTime lastUpdatedDate; - private Status status; + private Status status; - private String endpoint; + private String endpoint; - private String basePath; + private String basePath; - private List properties; + private List properties; } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/entity/ServiceProperty.java b/src/main/java/it/gov/pagopa/spontaneouspayment/entity/ServiceProperty.java index f6cf39b..df7f369 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/entity/ServiceProperty.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/entity/ServiceProperty.java @@ -14,10 +14,10 @@ @AllArgsConstructor public class ServiceProperty { - @NotBlank - private String name; + @NotBlank + private String name; - private String type; + private String type; - private boolean isRequired; + private boolean isRequired; } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/entity/ServiceRef.java b/src/main/java/it/gov/pagopa/spontaneouspayment/entity/ServiceRef.java index 39d41d9..8e3e115 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/entity/ServiceRef.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/entity/ServiceRef.java @@ -15,13 +15,13 @@ @Builder public class ServiceRef { - private String serviceId; + private String serviceId; - private String officeName; // es. Ufficio Tributi + private String officeName; // es. Ufficio Tributi - @NotBlank(message = "iban is required") - private String iban; + @NotBlank(message = "iban is required") + private String iban; - private String postalIban; + private String postalIban; } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/exception/AppError.java b/src/main/java/it/gov/pagopa/spontaneouspayment/exception/AppError.java index 87cb23c..1cd753d 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/exception/AppError.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/exception/AppError.java @@ -7,13 +7,13 @@ @Getter public enum AppError { - ORGANIZATION_NOT_FOUND (HttpStatus.NOT_FOUND, "Organization not found", "Not found the Organization Fiscal Code %s"), - ORGANIZATION_SERVICE_NOT_FOUND (HttpStatus.NOT_FOUND, "Not found a relation between organization and service", "Not found a relation between Organization Fiscal Code %s and Service Id %s"), - SERVICE_NOT_FOUND (HttpStatus.NOT_FOUND, "The service configuration was not found", "Not found a service configuration for Service Id %s"), - ENROLLMENT_TO_SERVICE_NOT_FOUND (HttpStatus.NOT_FOUND, "Not found the enrollment for the specified id", "Not found an enrollment to the Service Id %s for the Organization Fiscal Code %s"), - PROPERTY_MISSING (HttpStatus.BAD_REQUEST, "A property configured for the service is not present in the request", "Not found in the request the configured property %s"), - ENTITY_DUPLICATED (HttpStatus.CONFLICT, "Entity with the specified id already exists in the system", "%s"), - ENROLLMENT_TO_SERVICE_DUPLICATED (HttpStatus.CONFLICT, "An enrollment for the specified id already exists", "Already exists an enrollment between Organization Fiscal Code %s and Service Id %s"), + ORGANIZATION_NOT_FOUND(HttpStatus.NOT_FOUND, "Organization not found", "Not found the Organization Fiscal Code %s"), + ORGANIZATION_SERVICE_NOT_FOUND(HttpStatus.NOT_FOUND, "Not found a relation between organization and service", "Not found a relation between Organization Fiscal Code %s and Service Id %s"), + SERVICE_NOT_FOUND(HttpStatus.NOT_FOUND, "The service configuration was not found", "Not found a service configuration for Service Id %s"), + ENROLLMENT_TO_SERVICE_NOT_FOUND(HttpStatus.NOT_FOUND, "Not found the enrollment for the specified id", "Not found an enrollment to the Service Id %s for the Organization Fiscal Code %s"), + PROPERTY_MISSING(HttpStatus.BAD_REQUEST, "A property configured for the service is not present in the request", "Not found in the request the configured property %s"), + ENTITY_DUPLICATED(HttpStatus.CONFLICT, "Entity with the specified id already exists in the system", "%s"), + ENROLLMENT_TO_SERVICE_DUPLICATED(HttpStatus.CONFLICT, "An enrollment for the specified id already exists", "Already exists an enrollment between Organization Fiscal Code %s and Service Id %s"), ENTITY_VALIDATION_FAIL(HttpStatus.INTERNAL_SERVER_ERROR, "Error during entity validation", "%s"), UNKNOWN(null, null, null); diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/CreateEnrollmentModel.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/CreateEnrollmentModel.java index 905c5d5..5a5e2ca 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/model/CreateEnrollmentModel.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/CreateEnrollmentModel.java @@ -1,29 +1,28 @@ package it.gov.pagopa.spontaneouspayment.model; -import java.io.Serializable; - -import javax.validation.constraints.NotBlank; - import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + @Data @NoArgsConstructor @AllArgsConstructor @Builder -public class CreateEnrollmentModel implements Serializable{ +public class CreateEnrollmentModel implements Serializable { + + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = -3542093274149923876L; - /** - * generated serialVersionUID - */ - private static final long serialVersionUID = -3542093274149923876L; - - @NotBlank(message = "service id is required") - private String serviceId; - @NotBlank(message = "iban is required") - private String iban; - private String officeName; + @NotBlank(message = "service id is required") + private String serviceId; + @NotBlank(message = "iban is required") + private String iban; + private String officeName; } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/EnrollmentModel.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/EnrollmentModel.java index 707500c..35bae3d 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/model/EnrollmentModel.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/EnrollmentModel.java @@ -1,24 +1,24 @@ package it.gov.pagopa.spontaneouspayment.model; -import java.io.Serializable; - import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @NoArgsConstructor @AllArgsConstructor @Builder -public class EnrollmentModel implements Serializable{ +public class EnrollmentModel implements Serializable { + + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = 8505165905680276253L; - /** - * generated serialVersionUID - */ - private static final long serialVersionUID = 8505165905680276253L; - - private String iban; - private String officeName; + private String iban; + private String officeName; } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationEnrollmentModel.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationEnrollmentModel.java index 2c19878..c3a552d 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationEnrollmentModel.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationEnrollmentModel.java @@ -1,30 +1,29 @@ package it.gov.pagopa.spontaneouspayment.model; -import java.io.Serializable; -import java.util.List; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; - import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + @Data @NoArgsConstructor @AllArgsConstructor @Builder -public class OrganizationEnrollmentModel implements Serializable{ - /** - * generated serialVersionUID - */ - private static final long serialVersionUID = 3009315407053476788L; - - @NotBlank(message = "company name is required") - private String companyName; - - @Valid - private List enrollments; +public class OrganizationEnrollmentModel implements Serializable { + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = 3009315407053476788L; + + @NotBlank(message = "company name is required") + private String companyName; + + @Valid + private List enrollments; } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationModel.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationModel.java index 39effa0..cea7004 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationModel.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/OrganizationModel.java @@ -1,24 +1,24 @@ package it.gov.pagopa.spontaneouspayment.model; -import java.io.Serializable; - import it.gov.pagopa.spontaneouspayment.model.enumeration.Status; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @NoArgsConstructor @AllArgsConstructor @Builder -public class OrganizationModel implements Serializable{ +public class OrganizationModel implements Serializable { + + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = -1181181033127626459L; - /** - * generated serialVersionUID - */ - private static final long serialVersionUID = -1181181033127626459L; - - private String companyName; - private Status status; + private String companyName; + private Status status; } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/ServicePropertyModel.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/ServicePropertyModel.java index a374752..8e877f1 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/model/ServicePropertyModel.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/ServicePropertyModel.java @@ -14,13 +14,13 @@ @Builder public class ServicePropertyModel implements Serializable { - /** - * generated serialVersionUID - */ - private static final long serialVersionUID = -4881284106551118200L; + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = -4881284106551118200L; - @NotBlank - private String name; + @NotBlank + private String name; - private String value; + private String value; } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/SpontaneousPaymentModel.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/SpontaneousPaymentModel.java index ecb0ef4..c1c6609 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/model/SpontaneousPaymentModel.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/SpontaneousPaymentModel.java @@ -14,18 +14,18 @@ @AllArgsConstructor @Builder public class SpontaneousPaymentModel implements Serializable { - /** - * generated serialVersionUID - */ - private static final long serialVersionUID = 8257339606190246109L; + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = 8257339606190246109L; - @Valid - @NotNull - private DebtorModel debtor; + @Valid + @NotNull + private DebtorModel debtor; - @Valid - @NotNull - private ServiceModel service; + @Valid + @NotNull + private ServiceModel service; } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/EnrollmentModelResponse.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/EnrollmentModelResponse.java index f58e48c..ac7d66a 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/EnrollmentModelResponse.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/EnrollmentModelResponse.java @@ -1,27 +1,26 @@ package it.gov.pagopa.spontaneouspayment.model.response; -import java.io.Serializable; - -import javax.validation.constraints.NotBlank; - import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + @Builder @Data @NoArgsConstructor @AllArgsConstructor -public class EnrollmentModelResponse implements Serializable{ - /** - * generated serialVersionUID - */ - private static final long serialVersionUID = -6830998393310794316L; - - @NotBlank(message = "service ID is required") - private String serviceId; - @NotBlank(message = "iban is required") - private String iban; - private String officeName; +public class EnrollmentModelResponse implements Serializable { + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = -6830998393310794316L; + + @NotBlank(message = "service ID is required") + private String serviceId; + @NotBlank(message = "iban is required") + private String iban; + private String officeName; } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/OrganizationModelResponse.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/OrganizationModelResponse.java index 2a97426..a48dd5a 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/OrganizationModelResponse.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/OrganizationModelResponse.java @@ -1,39 +1,38 @@ package it.gov.pagopa.spontaneouspayment.model.response; -import java.io.Serializable; -import java.util.List; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - import it.gov.pagopa.spontaneouspayment.model.enumeration.Status; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + @Builder @Data @NoArgsConstructor @AllArgsConstructor public class OrganizationModelResponse implements Serializable { - /** - * generated serialVersionUID - */ - private static final long serialVersionUID = 6474656487948357626L; - - @NotBlank(message = "organization fiscal code is required") + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = 6474656487948357626L; + + @NotBlank(message = "organization fiscal code is required") private String fiscalCode; @NotBlank(message = "company name is required") private String companyName; - + @NotNull(message = "status is required") private Status status; @Valid - private List enrollments; - + private List enrollments; + } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServiceDetailModelResponse.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServiceDetailModelResponse.java index 9cd3d77..5bfcaf0 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServiceDetailModelResponse.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServiceDetailModelResponse.java @@ -1,41 +1,40 @@ package it.gov.pagopa.spontaneouspayment.model.response; -import java.io.Serializable; -import java.util.List; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - import it.gov.pagopa.spontaneouspayment.model.enumeration.Status; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + @Data @NoArgsConstructor @AllArgsConstructor -public class ServiceDetailModelResponse implements Serializable{ - /** - * generated serialVersionUID - */ - private static final long serialVersionUID = -3792257418379600493L; - - @NotBlank(message = "id is required") - private String id; - private String name; - private String description; - - @NotBlank(message = "transfer category is required") - private String transferCategory; // tassonomia - - @NotBlank(message = "remittance information is required") - private String remittanceInformation; // causale - - @NotNull(message = "status is required") - private Status status; - - @Valid - private List properties; +public class ServiceDetailModelResponse implements Serializable { + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = -3792257418379600493L; + + @NotBlank(message = "id is required") + private String id; + private String name; + private String description; + + @NotBlank(message = "transfer category is required") + private String transferCategory; // tassonomia + + @NotBlank(message = "remittance information is required") + private String remittanceInformation; // causale + + @NotNull(message = "status is required") + private Status status; + + @Valid + private List properties; } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServiceModelResponse.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServiceModelResponse.java index 809de39..10ca2fa 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServiceModelResponse.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServiceModelResponse.java @@ -1,25 +1,24 @@ package it.gov.pagopa.spontaneouspayment.model.response; -import java.io.Serializable; - -import javax.validation.constraints.NotBlank; - import lombok.Data; import lombok.NoArgsConstructor; +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + @Data @NoArgsConstructor -public class ServiceModelResponse implements Serializable{ +public class ServiceModelResponse implements Serializable { + + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = -6620381879835313811L; - /** - * generated serialVersionUID - */ - private static final long serialVersionUID = -6620381879835313811L; - - @NotBlank(message = "id is required") - private String id; - @NotBlank(message = "name is required") - private String name; - private String description; + @NotBlank(message = "id is required") + private String id; + @NotBlank(message = "name is required") + private String name; + private String description; } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServicePropertyModelResponse.java b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServicePropertyModelResponse.java index 26fc804..072292f 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServicePropertyModelResponse.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/model/response/ServicePropertyModelResponse.java @@ -5,26 +5,25 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import java.io.Serializable; - import javax.validation.constraints.NotBlank; +import java.io.Serializable; @Getter @Setter @NoArgsConstructor @AllArgsConstructor -public class ServicePropertyModelResponse implements Serializable{ - - /** - * generated serialVersionUID - */ - private static final long serialVersionUID = 7156317962327532355L; +public class ServicePropertyModelResponse implements Serializable { + + /** + * generated serialVersionUID + */ + private static final long serialVersionUID = 7156317962327532355L; - @NotBlank - private String name; + @NotBlank + private String name; - private String type; + private String type; - private boolean isRequired; + private boolean isRequired; } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/repository/OrganizationRepository.java b/src/main/java/it/gov/pagopa/spontaneouspayment/repository/OrganizationRepository.java index 9661ad2..ad4b150 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/repository/OrganizationRepository.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/repository/OrganizationRepository.java @@ -14,6 +14,6 @@ public interface OrganizationRepository extends CosmosRepository getCreditInstitutionByOrgFiscCodeAndServiceId(@Param("organizationFiscalCode") String organizationFiscalCode, @Param("serviceId") String serviceId); - + Optional findByFiscalCode(String organizationFiscalCode); } diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsService.java b/src/main/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsService.java index 36bc49c..931e3a4 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsService.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsService.java @@ -1,14 +1,6 @@ package it.gov.pagopa.spontaneouspayment.service; -import java.util.stream.StreamSupport; - -import javax.validation.constraints.NotBlank; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - import com.azure.cosmos.models.PartitionKey; - import it.gov.pagopa.spontaneouspayment.entity.Organization; import it.gov.pagopa.spontaneouspayment.entity.ServiceRef; import it.gov.pagopa.spontaneouspayment.exception.AppError; @@ -19,6 +11,11 @@ import it.gov.pagopa.spontaneouspayment.repository.ServiceRepository; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.validation.constraints.NotBlank; +import java.util.stream.StreamSupport; @Service @AllArgsConstructor @@ -27,145 +24,145 @@ public class EnrollmentsService { @Autowired private OrganizationRepository orgRepository; - + @Autowired private ServiceRepository serviceRepository; - + public Organization createEC(Organization orgEntity) { - Iterable allServices = serviceRepository.findAll(); - - // check if all services the EC wants to enroll are configured in the database - for (ServiceRef servRef : orgEntity.getEnrollments()) { - boolean exist = StreamSupport.stream(allServices.spliterator(), true).anyMatch(s -> s.getId().equals(servRef.getServiceId())); - if (!exist) { + Iterable allServices = serviceRepository.findAll(); + + // check if all services the EC wants to enroll are configured in the database + for (ServiceRef servRef : orgEntity.getEnrollments()) { + boolean exist = StreamSupport.stream(allServices.spliterator(), true).anyMatch(s -> s.getId().equals(servRef.getServiceId())); + if (!exist) { throw new AppException(AppError.SERVICE_NOT_FOUND, servRef.getServiceId()); } - } - - // check if organization fiscal code already exists - if (orgRepository.existsById(orgEntity.getFiscalCode())) { - throw new AppException(AppError.ENTITY_DUPLICATED, "Already exists an entity with id " + orgEntity.getFiscalCode()); - } - - return orgRepository.save(orgEntity); - } - + } + + // check if organization fiscal code already exists + if (orgRepository.existsById(orgEntity.getFiscalCode())) { + throw new AppException(AppError.ENTITY_DUPLICATED, "Already exists an entity with id " + orgEntity.getFiscalCode()); + } + + return orgRepository.save(orgEntity); + } + public Organization createECEnrollment(String organizationFiscalCode, - @NotBlank String serviceId, EnrollmentModel enrollmentModel) { - Iterable allServices = serviceRepository.findAll(); - - // check if the service the EC wants to enroll is configured in the database - boolean exists = StreamSupport.stream(allServices.spliterator(), true).anyMatch(s -> s.getId().equals(serviceId)); - if (!exists) { - throw new AppException(AppError.SERVICE_NOT_FOUND, serviceId); + @NotBlank String serviceId, EnrollmentModel enrollmentModel) { + Iterable allServices = serviceRepository.findAll(); + + // check if the service the EC wants to enroll is configured in the database + boolean exists = StreamSupport.stream(allServices.spliterator(), true).anyMatch(s -> s.getId().equals(serviceId)); + if (!exists) { + throw new AppException(AppError.SERVICE_NOT_FOUND, serviceId); } - - // check if the organization fiscal code exists - Organization orgEntity = this.checkOrganizationFiscalCode (organizationFiscalCode); - - // check if the enroll to service already exist for the organization fiscal code - exists = orgEntity.getEnrollments() + + // check if the organization fiscal code exists + Organization orgEntity = this.checkOrganizationFiscalCode(organizationFiscalCode); + + // check if the enroll to service already exist for the organization fiscal code + exists = orgEntity.getEnrollments() .parallelStream() .anyMatch(s -> s.getServiceId().equals(serviceId)); - if (exists) { - throw new AppException(AppError.ENROLLMENT_TO_SERVICE_DUPLICATED, organizationFiscalCode, serviceId); - } - - // creates the new enrollment and adds it to the organization - orgEntity.getEnrollments().add( - ServiceRef.builder() - .serviceId(serviceId) - .officeName(enrollmentModel.getOfficeName()) - .iban(enrollmentModel.getIban()).build() - ); - - return orgRepository.save(orgEntity); - } - - + if (exists) { + throw new AppException(AppError.ENROLLMENT_TO_SERVICE_DUPLICATED, organizationFiscalCode, serviceId); + } + + // creates the new enrollment and adds it to the organization + orgEntity.getEnrollments().add( + ServiceRef.builder() + .serviceId(serviceId) + .officeName(enrollmentModel.getOfficeName()) + .iban(enrollmentModel.getIban()).build() + ); + + return orgRepository.save(orgEntity); + } + + public Organization updateECEnrollment(String organizationFiscalCode, - String serviceId, EnrollmentModel enrollmentModel) { - - // check if the organization fiscal code exists - Organization orgEntity = this.checkOrganizationFiscalCode (organizationFiscalCode); - - // check if the enroll to service exist for the organization fiscal code - ServiceRef enrollToUpdate = orgEntity.getEnrollments().stream().filter(s -> s.getServiceId().equals(serviceId)).findFirst() - .orElseThrow(() -> new AppException(AppError.ENROLLMENT_TO_SERVICE_NOT_FOUND, serviceId, organizationFiscalCode)); - - // removes old enrollment - orgEntity.getEnrollments().remove(enrollToUpdate); - - // adds updated enrollment - orgEntity.getEnrollments().add( - ServiceRef.builder() - .serviceId(serviceId) - .officeName(enrollmentModel.getOfficeName()) - .iban(enrollmentModel.getIban()).build() - ); - - return orgRepository.save(orgEntity); - } - + String serviceId, EnrollmentModel enrollmentModel) { + + // check if the organization fiscal code exists + Organization orgEntity = this.checkOrganizationFiscalCode(organizationFiscalCode); + + // check if the enroll to service exist for the organization fiscal code + ServiceRef enrollToUpdate = orgEntity.getEnrollments().stream().filter(s -> s.getServiceId().equals(serviceId)).findFirst() + .orElseThrow(() -> new AppException(AppError.ENROLLMENT_TO_SERVICE_NOT_FOUND, serviceId, organizationFiscalCode)); + + // removes old enrollment + orgEntity.getEnrollments().remove(enrollToUpdate); + + // adds updated enrollment + orgEntity.getEnrollments().add( + ServiceRef.builder() + .serviceId(serviceId) + .officeName(enrollmentModel.getOfficeName()) + .iban(enrollmentModel.getIban()).build() + ); + + return orgRepository.save(orgEntity); + } + public Organization updateEC(String organizationFiscalCode, - OrganizationModel organizationModel) { - - // check if the organization fiscal code exists - Organization orgEntity = this.checkOrganizationFiscalCode (organizationFiscalCode); - - // update EC info - orgEntity.setCompanyName(organizationModel.getCompanyName()); - orgEntity.setStatus(organizationModel.getStatus()); - - - return orgRepository.save(orgEntity); - } - - + OrganizationModel organizationModel) { + + // check if the organization fiscal code exists + Organization orgEntity = this.checkOrganizationFiscalCode(organizationFiscalCode); + + // update EC info + orgEntity.setCompanyName(organizationModel.getCompanyName()); + orgEntity.setStatus(organizationModel.getStatus()); + + + return orgRepository.save(orgEntity); + } + + public void deleteECEnrollment(String organizationFiscalCode, - String serviceId) { - // check if the organization fiscal code exists - Organization orgEntity = this.checkOrganizationFiscalCode (organizationFiscalCode); - - // check if the enroll to service exist for the organization fiscal code - ServiceRef enrollToRemove = orgEntity.getEnrollments().stream().filter(s -> s.getServiceId().equals(serviceId)).findFirst() - .orElseThrow(() -> new AppException(AppError.ENROLLMENT_TO_SERVICE_NOT_FOUND, serviceId, organizationFiscalCode)); - - // removes the enrollment - orgEntity.getEnrollments().remove(enrollToRemove); - - orgRepository.save(orgEntity); + String serviceId) { + // check if the organization fiscal code exists + Organization orgEntity = this.checkOrganizationFiscalCode(organizationFiscalCode); + + // check if the enroll to service exist for the organization fiscal code + ServiceRef enrollToRemove = orgEntity.getEnrollments().stream().filter(s -> s.getServiceId().equals(serviceId)).findFirst() + .orElseThrow(() -> new AppException(AppError.ENROLLMENT_TO_SERVICE_NOT_FOUND, serviceId, organizationFiscalCode)); + + // removes the enrollment + orgEntity.getEnrollments().remove(enrollToRemove); + + orgRepository.save(orgEntity); } - + public void deleteEC(String organizationFiscalCode) { - // check if the organization fiscal code exists - Organization orgEntity = this.checkOrganizationFiscalCode (organizationFiscalCode); - - orgRepository.delete(orgEntity); - } - - - public ServiceRef getSingleEnrollment (String organizationFiscalCode, - String serviceId) { - // check if the organization fiscal code exists - Organization orgEntity = this.checkOrganizationFiscalCode (organizationFiscalCode); - - // if the enroll to service exists is returned - return orgEntity.getEnrollments().stream().filter(s -> s.getServiceId().equals(serviceId)).findFirst() - .orElseThrow(() -> new AppException(AppError.ENROLLMENT_TO_SERVICE_NOT_FOUND, serviceId, organizationFiscalCode)); - + // check if the organization fiscal code exists + Organization orgEntity = this.checkOrganizationFiscalCode(organizationFiscalCode); + + orgRepository.delete(orgEntity); + } + + + public ServiceRef getSingleEnrollment(String organizationFiscalCode, + String serviceId) { + // check if the organization fiscal code exists + Organization orgEntity = this.checkOrganizationFiscalCode(organizationFiscalCode); + + // if the enroll to service exists is returned + return orgEntity.getEnrollments().stream().filter(s -> s.getServiceId().equals(serviceId)).findFirst() + .orElseThrow(() -> new AppException(AppError.ENROLLMENT_TO_SERVICE_NOT_FOUND, serviceId, organizationFiscalCode)); + } - - public Organization getECEnrollments (String organizationFiscalCode) { - return orgRepository.findByFiscalCode(organizationFiscalCode) - .orElseThrow(() -> new AppException(AppError.ORGANIZATION_NOT_FOUND, organizationFiscalCode)); + + public Organization getECEnrollments(String organizationFiscalCode) { + return orgRepository.findByFiscalCode(organizationFiscalCode) + .orElseThrow(() -> new AppException(AppError.ORGANIZATION_NOT_FOUND, organizationFiscalCode)); } - - + + private Organization checkOrganizationFiscalCode(String organizationFiscalCode) { - return orgRepository.findById(organizationFiscalCode, new PartitionKey(organizationFiscalCode)) - .orElseThrow(() -> new AppException(AppError.ORGANIZATION_NOT_FOUND, organizationFiscalCode)); - } + return orgRepository.findById(organizationFiscalCode, new PartitionKey(organizationFiscalCode)) + .orElseThrow(() -> new AppException(AppError.ORGANIZATION_NOT_FOUND, organizationFiscalCode)); + } } 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 32adfbd..5d0b17f 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/service/PaymentsService.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/service/PaymentsService.java @@ -11,7 +11,6 @@ import it.gov.pagopa.spontaneouspayment.repository.ServiceRepository; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/src/main/java/it/gov/pagopa/spontaneouspayment/service/ServicesService.java b/src/main/java/it/gov/pagopa/spontaneouspayment/service/ServicesService.java index 8126bb0..8309325 100644 --- a/src/main/java/it/gov/pagopa/spontaneouspayment/service/ServicesService.java +++ b/src/main/java/it/gov/pagopa/spontaneouspayment/service/ServicesService.java @@ -1,36 +1,35 @@ package it.gov.pagopa.spontaneouspayment.service; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.StreamSupport; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - import it.gov.pagopa.spontaneouspayment.exception.AppError; import it.gov.pagopa.spontaneouspayment.exception.AppException; import it.gov.pagopa.spontaneouspayment.repository.ServiceRepository; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; @Service @AllArgsConstructor @NoArgsConstructor public class ServicesService { - + @Autowired private ServiceRepository serviceRepository; - - public List getServices () { - - Iterable allServices = serviceRepository.findAll(); - - return StreamSupport.stream(allServices.spliterator(), false) - .collect(Collectors.toList()); + + public List getServices() { + + Iterable allServices = serviceRepository.findAll(); + + return StreamSupport.stream(allServices.spliterator(), false) + .collect(Collectors.toList()); } - - public it.gov.pagopa.spontaneouspayment.entity.Service getServiceDetails (String serviceId) { - return serviceRepository.findById(serviceId) - .orElseThrow(() -> new AppException(AppError.SERVICE_NOT_FOUND, serviceId)); + + public it.gov.pagopa.spontaneouspayment.entity.Service getServiceDetails(String serviceId) { + return serviceRepository.findById(serviceId) + .orElseThrow(() -> new AppException(AppError.SERVICE_NOT_FOUND, serviceId)); } } diff --git a/src/test/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsServiceTest.java b/src/test/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsServiceTest.java index 85f7ceb..08c12ef 100644 --- a/src/test/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsServiceTest.java +++ b/src/test/java/it/gov/pagopa/spontaneouspayment/service/EnrollmentsServiceTest.java @@ -1,20 +1,19 @@ package it.gov.pagopa.spontaneouspayment.service; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.spy; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.file.Path; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.CertificateException; -import java.util.ArrayList; -import java.util.List; - +import com.azure.cosmos.CosmosAsyncClient; +import com.azure.cosmos.CosmosClientBuilder; +import com.azure.cosmos.models.CosmosContainerResponse; +import com.azure.cosmos.models.CosmosDatabaseResponse; +import it.gov.pagopa.spontaneouspayment.entity.Organization; +import it.gov.pagopa.spontaneouspayment.entity.Service; +import it.gov.pagopa.spontaneouspayment.entity.ServiceProperty; +import it.gov.pagopa.spontaneouspayment.entity.ServiceRef; +import it.gov.pagopa.spontaneouspayment.exception.AppException; +import it.gov.pagopa.spontaneouspayment.model.EnrollmentModel; +import it.gov.pagopa.spontaneouspayment.model.OrganizationModel; +import it.gov.pagopa.spontaneouspayment.model.enumeration.Status; +import it.gov.pagopa.spontaneouspayment.repository.OrganizationRepository; +import it.gov.pagopa.spontaneouspayment.repository.ServiceRepository; import org.junit.Rule; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; @@ -30,21 +29,20 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; -import com.azure.cosmos.CosmosAsyncClient; -import com.azure.cosmos.CosmosClientBuilder; -import com.azure.cosmos.models.CosmosContainerResponse; -import com.azure.cosmos.models.CosmosDatabaseResponse; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.file.Path; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.util.ArrayList; +import java.util.List; -import it.gov.pagopa.spontaneouspayment.entity.Organization; -import it.gov.pagopa.spontaneouspayment.entity.Service; -import it.gov.pagopa.spontaneouspayment.entity.ServiceProperty; -import it.gov.pagopa.spontaneouspayment.entity.ServiceRef; -import it.gov.pagopa.spontaneouspayment.exception.AppException; -import it.gov.pagopa.spontaneouspayment.model.EnrollmentModel; -import it.gov.pagopa.spontaneouspayment.model.OrganizationModel; -import it.gov.pagopa.spontaneouspayment.model.enumeration.Status; -import it.gov.pagopa.spontaneouspayment.repository.OrganizationRepository; -import it.gov.pagopa.spontaneouspayment.repository.ServiceRepository; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.spy; @TestInstance(TestInstance.Lifecycle.PER_CLASS) @SpringBootTest 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 a75e520..d539801 100644 --- a/src/test/java/it/gov/pagopa/spontaneouspayment/service/PaymentsServiceTest.java +++ b/src/test/java/it/gov/pagopa/spontaneouspayment/service/PaymentsServiceTest.java @@ -1,23 +1,22 @@ package it.gov.pagopa.spontaneouspayment.service; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.spy; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.file.Path; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.CertificateException; -import java.util.ArrayList; -import java.util.List; - +import com.azure.cosmos.CosmosAsyncClient; +import com.azure.cosmos.CosmosClientBuilder; +import com.azure.cosmos.models.CosmosContainerResponse; +import com.azure.cosmos.models.CosmosDatabaseResponse; +import it.gov.pagopa.spontaneouspayment.config.TestUtil; +import it.gov.pagopa.spontaneouspayment.entity.Organization; +import it.gov.pagopa.spontaneouspayment.entity.Service; +import it.gov.pagopa.spontaneouspayment.entity.ServiceProperty; +import it.gov.pagopa.spontaneouspayment.entity.ServiceRef; +import it.gov.pagopa.spontaneouspayment.exception.AppException; +import it.gov.pagopa.spontaneouspayment.model.SpontaneousPaymentModel; +import it.gov.pagopa.spontaneouspayment.model.enumeration.Status; +import it.gov.pagopa.spontaneouspayment.model.response.PaymentPositionModel; +import it.gov.pagopa.spontaneouspayment.repository.OrganizationRepository; +import it.gov.pagopa.spontaneouspayment.repository.ServiceRepository; import org.junit.Rule; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; @@ -30,213 +29,217 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; -import com.azure.cosmos.CosmosAsyncClient; -import com.azure.cosmos.CosmosClientBuilder; -import com.azure.cosmos.models.CosmosContainerResponse; -import com.azure.cosmos.models.CosmosDatabaseResponse; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.file.Path; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.util.ArrayList; +import java.util.List; -import it.gov.pagopa.spontaneouspayment.config.TestUtil; -import it.gov.pagopa.spontaneouspayment.entity.Organization; -import it.gov.pagopa.spontaneouspayment.entity.Service; -import it.gov.pagopa.spontaneouspayment.entity.ServiceProperty; -import it.gov.pagopa.spontaneouspayment.entity.ServiceRef; -import it.gov.pagopa.spontaneouspayment.exception.AppException; -import it.gov.pagopa.spontaneouspayment.model.enumeration.Status; -import it.gov.pagopa.spontaneouspayment.model.response.PaymentPositionModel; -import it.gov.pagopa.spontaneouspayment.repository.OrganizationRepository; -import it.gov.pagopa.spontaneouspayment.repository.ServiceRepository; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import static org.mockito.Mockito.spy; @TestInstance(TestInstance.Lifecycle.PER_CLASS) @SpringBootTest @Testcontainers class PaymentsServiceTest { - @Rule - public TemporaryFolder tempFolder = new TemporaryFolder(); - - @Autowired - private OrganizationRepository ciRepository; - - @Autowired - private ServiceRepository serviceRepository; - - @Container - private static final CosmosDBEmulatorContainer emulator = new CosmosDBEmulatorContainer( - DockerImageName.parse("mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest")); - - private static PaymentsService paymentsService; - - @BeforeAll - public void setUp() throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException { - - paymentsService = spy(new PaymentsService(ciRepository, serviceRepository)); - - tempFolder.create(); - Path keyStoreFile = tempFolder.newFile("azure-cosmos-emulator.keystore").toPath(); - KeyStore keyStore = emulator.buildNewKeyStore(); - keyStore.store(new FileOutputStream(keyStoreFile.toFile()), emulator.getEmulatorKey().toCharArray()); - - System.setProperty("javax.net.ssl.trustStore", keyStoreFile.toString()); - System.setProperty("javax.net.ssl.trustStorePassword", emulator.getEmulatorKey()); - System.setProperty("javax.net.ssl.trustStoreType", "PKCS12"); - - CosmosAsyncClient client = new CosmosClientBuilder().gatewayMode().endpointDiscoveryEnabled(false) - .endpoint(emulator.getEmulatorEndpoint()).key(emulator.getEmulatorKey()).buildAsyncClient(); - - // creation of the database and containers - CosmosDatabaseResponse databaseResponse = client.createDatabaseIfNotExists("db").block(); - - Assertions.assertEquals(201, databaseResponse.getStatusCode()); - CosmosContainerResponse containerResponse = client.getDatabase("db") - .createContainerIfNotExists("creditor_institutions", "/fiscalCode").block(); - Assertions.assertEquals(201, containerResponse.getStatusCode()); - containerResponse = client.getDatabase("db").createContainerIfNotExists("services", "/transferCategory").block(); - Assertions.assertEquals(201, containerResponse.getStatusCode()); - - // loading the database with test data - Organization ci = new Organization(); - ci.setFiscalCode("organizationTest"); - ci.setCompanyName("Comune di Roma"); - ci.setStatus(Status.ENABLED); - - Service s1 = new Service(); - s1.setId("id-servizio-1"); - s1.setTransferCategory("tassonomia-1"); - s1.setRemittanceInformation("causale-1"); - s1.setBasePath("base-path-1"); - s1.setEndpoint("endpont-1"); - - ServiceProperty sp1 = new ServiceProperty("propName1", "number", true); - List properties1 = new ArrayList<>(); - properties1.add(sp1); - s1.setProperties(properties1); - - Service s2 = new Service(); - s2.setId("id-servizio-2"); - s2.setTransferCategory("tassonomia-2"); - s2.setRemittanceInformation("causale-2"); - s2.setBasePath("base-path-2"); - s2.setEndpoint("endpont-2"); - - ServiceProperty sp2 = new ServiceProperty("propName2", "string", true); - List properties2 = new ArrayList<>(); - properties2.add(sp2); - s2.setProperties(properties2); - - Service s3 = new Service(); - s3.setId("id-servizio-3"); - s3.setTransferCategory("tassonomia-3"); - s3.setRemittanceInformation("causale-3"); - s3.setBasePath("base-path-3"); - s3.setEndpoint("endpont-3"); - - ServiceProperty sp3 = new ServiceProperty("propName3", "url", true); - List properties3 = new ArrayList<>(); - properties3.add(sp3); - s3.setProperties(properties3); - - Service s4 = new Service(); - s4.setId("id-servizio-4"); - s4.setTransferCategory("tassonomia-4"); - s4.setRemittanceInformation("causale-4"); - s4.setBasePath("base-path-4"); - s4.setEndpoint("endpont-4"); - - ServiceProperty sp4 = new ServiceProperty("propName4", "rule", true); - List properties4 = new ArrayList<>(); - properties4.add(sp4); - s4.setProperties(properties4); - - ServiceRef ref1 = new ServiceRef(); - ref1.setServiceId("id-servizio-1"); - ref1.setIban("iban-1"); - ServiceRef ref2 = new ServiceRef(); - ref2.setServiceId("id-servizio-2"); - ref2.setIban("iban-2"); - List servicesRef = new ArrayList<>(); - servicesRef.add(ref1); - servicesRef.add(ref2); - - ci.setEnrollments(servicesRef); - - ciRepository.deleteAll(); - ciRepository.save(ci); - serviceRepository.deleteAll(); - serviceRepository.save(s1); - serviceRepository.save(s2); - serviceRepository.save(s3); - serviceRepository.save(s4); - } - - @AfterAll - void teardown() { - CosmosAsyncClient client = new CosmosClientBuilder().gatewayMode().endpointDiscoveryEnabled(false) - .endpoint(emulator.getEmulatorEndpoint()).key(emulator.getEmulatorKey()).buildAsyncClient(); - client.getDatabase("db").delete(); - client.close(); - emulator.stop(); - emulator.close(); - System.clearProperty("javax.net.ssl.trustStore"); - System.clearProperty("javax.net.ssl.trustStorePassword"); - System.clearProperty("javax.net.ssl.trustStoreType"); - } - - - @Test - void createSpontaneousPayment() { - assertTrue(emulator.isRunning()); - PaymentPositionModel ppm = paymentsService.createSpontaneousPayment("organizationTest", TestUtil.getSpontaneousPaymentModel()); - assertEquals(null , ppm.getFiscalCode()); - assertEquals(null , ppm.getFullName()); - } - - @Test - void createSpontaneousPayment_404() { - assertTrue(emulator.isRunning()); - try { - // non-existent organization -> must raise a 404 exception - paymentsService.createSpontaneousPayment("organizationFake", TestUtil.getSpontaneousPaymentModel()); - fail(); - } catch (AppException e) { - assertEquals(HttpStatus.NOT_FOUND, e.getHttpStatus()); - } catch (Exception e) { - fail(); - } - - try { - // non-existent service -> must raise a 404 exception - paymentsService.createSpontaneousPayment("organizationTest", TestUtil.getSpontaneousPaymentModel_FakeServiceId()); - fail(); - } catch (AppException e) { - assertEquals(HttpStatus.NOT_FOUND, e.getHttpStatus()); - } catch (Exception e) { - fail(); - } - - try { - // non-existent enrollment between organization ad service -> must raise a 404 exception - paymentsService.createSpontaneousPayment("organizationTest", TestUtil.getSpontaneousPaymentModel_NotEnrolledService()); - fail(); - } catch (AppException e) { - assertEquals(HttpStatus.NOT_FOUND, e.getHttpStatus()); - } catch (Exception e) { - fail(); - } - } - - @Test - void createSpontaneousPayment_400() { - assertTrue(emulator.isRunning()); - try { - // non-existent in request a configured property in service -> must raise a 400 exception - paymentsService.createSpontaneousPayment("organizationTest", TestUtil.getSpontaneousPaymentModel_BadProperty()); - fail(); - } catch (AppException e) { - assertEquals(HttpStatus.BAD_REQUEST, e.getHttpStatus()); - } catch (Exception e) { - fail(); - } - } - - + @Rule + public TemporaryFolder tempFolder = new TemporaryFolder(); + + @Autowired + private OrganizationRepository ciRepository; + + @Autowired + private ServiceRepository serviceRepository; + + @Container + private static final CosmosDBEmulatorContainer emulator = new CosmosDBEmulatorContainer( + DockerImageName.parse("mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest")); + + private static PaymentsService paymentsService; + + @BeforeAll + public void setUp() throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException { + + paymentsService = spy(new PaymentsService(ciRepository, serviceRepository)); + + tempFolder.create(); + Path keyStoreFile = tempFolder.newFile("azure-cosmos-emulator.keystore").toPath(); + KeyStore keyStore = emulator.buildNewKeyStore(); + keyStore.store(new FileOutputStream(keyStoreFile.toFile()), emulator.getEmulatorKey().toCharArray()); + + System.setProperty("javax.net.ssl.trustStore", keyStoreFile.toString()); + System.setProperty("javax.net.ssl.trustStorePassword", emulator.getEmulatorKey()); + System.setProperty("javax.net.ssl.trustStoreType", "PKCS12"); + + CosmosAsyncClient client = new CosmosClientBuilder().gatewayMode().endpointDiscoveryEnabled(false) + .endpoint(emulator.getEmulatorEndpoint()).key(emulator.getEmulatorKey()).buildAsyncClient(); + + // creation of the database and containers + CosmosDatabaseResponse databaseResponse = client.createDatabaseIfNotExists("db").block(); + + assertEquals(201, databaseResponse.getStatusCode()); + CosmosContainerResponse containerResponse = client.getDatabase("db") + .createContainerIfNotExists("creditor_institutions", "/fiscalCode").block(); + assertEquals(201, containerResponse.getStatusCode()); + containerResponse = client.getDatabase("db").createContainerIfNotExists("services", "/transferCategory").block(); + assertEquals(201, containerResponse.getStatusCode()); + + // loading the database with test data + Organization ci = new Organization(); + ci.setFiscalCode("organizationTest"); + ci.setCompanyName("Comune di Roma"); + ci.setStatus(Status.ENABLED); + + Service s1 = new Service(); + s1.setId("id-servizio-1"); + s1.setTransferCategory("tassonomia-1"); + s1.setRemittanceInformation("causale-1"); + s1.setBasePath("base-path-1"); + s1.setEndpoint("endpont-1"); + + ServiceProperty sp1 = new ServiceProperty("propName1", "number", true); + List properties1 = new ArrayList<>(); + properties1.add(sp1); + s1.setProperties(properties1); + + Service s2 = new Service(); + s2.setId("id-servizio-2"); + s2.setTransferCategory("tassonomia-2"); + s2.setRemittanceInformation("causale-2"); + s2.setBasePath("base-path-2"); + s2.setEndpoint("endpont-2"); + + ServiceProperty sp2 = new ServiceProperty("propName2", "string", true); + List properties2 = new ArrayList<>(); + properties2.add(sp2); + s2.setProperties(properties2); + + Service s3 = new Service(); + s3.setId("id-servizio-3"); + s3.setTransferCategory("tassonomia-3"); + s3.setRemittanceInformation("causale-3"); + s3.setBasePath("base-path-3"); + s3.setEndpoint("endpont-3"); + + ServiceProperty sp3 = new ServiceProperty("propName3", "url", true); + List properties3 = new ArrayList<>(); + properties3.add(sp3); + s3.setProperties(properties3); + + Service s4 = new Service(); + s4.setId("id-servizio-4"); + s4.setTransferCategory("tassonomia-4"); + s4.setRemittanceInformation("causale-4"); + s4.setBasePath("base-path-4"); + s4.setEndpoint("endpont-4"); + + ServiceProperty sp4 = new ServiceProperty("propName4", "rule", true); + List properties4 = new ArrayList<>(); + properties4.add(sp4); + s4.setProperties(properties4); + + ServiceRef ref1 = new ServiceRef(); + ref1.setServiceId("id-servizio-1"); + ref1.setIban("iban-1"); + ServiceRef ref2 = new ServiceRef(); + ref2.setServiceId("id-servizio-2"); + ref2.setIban("iban-2"); + List servicesRef = new ArrayList<>(); + servicesRef.add(ref1); + servicesRef.add(ref2); + + ci.setEnrollments(servicesRef); + + ciRepository.deleteAll(); + ciRepository.save(ci); + serviceRepository.deleteAll(); + serviceRepository.save(s1); + serviceRepository.save(s2); + serviceRepository.save(s3); + serviceRepository.save(s4); + } + + @AfterAll + void teardown() { + CosmosAsyncClient client = new CosmosClientBuilder().gatewayMode().endpointDiscoveryEnabled(false) + .endpoint(emulator.getEmulatorEndpoint()).key(emulator.getEmulatorKey()).buildAsyncClient(); + client.getDatabase("db").delete(); + client.close(); + emulator.stop(); + emulator.close(); + System.clearProperty("javax.net.ssl.trustStore"); + System.clearProperty("javax.net.ssl.trustStorePassword"); + System.clearProperty("javax.net.ssl.trustStoreType"); + } + + + @Test + void createSpontaneousPayment() { + assertTrue(emulator.isRunning()); + PaymentPositionModel ppm = paymentsService.createSpontaneousPayment("organizationTest", TestUtil.getSpontaneousPaymentModel()); + assertNull(ppm.getFiscalCode()); + assertNull(ppm.getFullName()); + } + + @Test + void createSpontaneousPayment_404() { + assertTrue(emulator.isRunning()); + SpontaneousPaymentModel spontaneousPaymentModel = TestUtil.getSpontaneousPaymentModel(); + try { + // non-existent organization -> must raise a 404 exception + paymentsService.createSpontaneousPayment("organizationFake", spontaneousPaymentModel); + fail(); + } catch (AppException e) { + assertEquals(HttpStatus.NOT_FOUND, e.getHttpStatus()); + } catch (Exception e) { + fail(); + } + + SpontaneousPaymentModel spontaneousPaymentModel_fakeServiceId = TestUtil.getSpontaneousPaymentModel_FakeServiceId(); + try { + // non-existent service -> must raise a 404 exception + paymentsService.createSpontaneousPayment("organizationTest", spontaneousPaymentModel_fakeServiceId); + fail(); + } catch (AppException e) { + assertEquals(HttpStatus.NOT_FOUND, e.getHttpStatus()); + } catch (Exception e) { + fail(); + } + + SpontaneousPaymentModel spontaneousPaymentModel_notEnrolledService = TestUtil.getSpontaneousPaymentModel_NotEnrolledService(); + try { + // non-existent enrollment between organization ad service -> must raise a 404 exception + paymentsService.createSpontaneousPayment("organizationTest", spontaneousPaymentModel_notEnrolledService); + fail(); + } catch (AppException e) { + assertEquals(HttpStatus.NOT_FOUND, e.getHttpStatus()); + } catch (Exception e) { + fail(); + } + } + + @Test + void createSpontaneousPayment_400() { + assertTrue(emulator.isRunning()); + SpontaneousPaymentModel spontaneousPaymentModel_badProperty = TestUtil.getSpontaneousPaymentModel_BadProperty(); + try { + // non-existent in request a configured property in service -> must raise a 400 exception + paymentsService.createSpontaneousPayment("organizationTest", spontaneousPaymentModel_badProperty); + fail(); + } catch (AppException e) { + assertEquals(HttpStatus.BAD_REQUEST, e.getHttpStatus()); + } catch (Exception e) { + fail(); + } + } + + } From a3084a039a40d1d64192bee494fb540439f918ea Mon Sep 17 00:00:00 2001 From: Jacopo Date: Thu, 30 Jun 2022 14:42:51 +0200 Subject: [PATCH 16/16] fix --- openapi/openapi.json | 3514 +++++++++++++++++++++--------------------- 1 file changed, 1757 insertions(+), 1757 deletions(-) diff --git a/openapi/openapi.json b/openapi/openapi.json index f96e055..efa979f 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -1,1758 +1,1758 @@ { - "openapi": "3.0.1", - "info": { - "title": "PagoPA API Spontaneous Payment", - "description": "Progetto Gestione Pagamenti Spontanei", - "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.1" - }, - "servers": [ - { - "url": "http://localhost:9090", - "description": "Generated server url" - } - ], - "paths": { - "/organizations/{organizationFiscalCode}": { - "get": { - "tags": [ - "Enrollments API" - ], - "summary": "Return all enrollments for a creditor institution.", - "operationId": "getECEnrollments", - "parameters": [ - { - "name": "organizationFiscalCode", - "in": "path", - "description": "The fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "404": { - "description": "Not found the creditor institution.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "200": { - "description": "Obtained all enrollments for the creditor institution.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OrganizationModelResponse" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "put": { - "tags": [ - "Enrollments API" - ], - "summary": "The organization updates the creditor institution.", - "operationId": "updateEC", - "parameters": [ - { - "name": "organizationFiscalCode", - "in": "path", - "description": "The fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OrganizationModel" - } - } - }, - "required": true - }, - "responses": { - "404": { - "description": "Not found the creditor institution.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "200": { - "description": "Request updated.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OrganizationModelResponse" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "400": { - "description": "Malformed request.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "post": { - "tags": [ - "Enrollments API" - ], - "summary": "The organization creates a creditor institution with possible enrollments to services.", - "operationId": "createEC", - "parameters": [ - { - "name": "organizationFiscalCode", - "in": "path", - "description": "The fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OrganizationEnrollmentModel" - } - } - }, - "required": true - }, - "responses": { - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "400": { - "description": "Malformed request.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "409": { - "description": "The organization to create already exists.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "201": { - "description": "Request created.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OrganizationModelResponse" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "delete": { - "tags": [ - "Enrollments API" - ], - "summary": "The organization deletes the creditor institution.", - "operationId": "deleteEC", - "parameters": [ - { - "name": "organizationFiscalCode", - "in": "path", - "description": "The fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "404": { - "description": "Not found the creditor institution.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "200": { - "description": "Request deleted.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "type": "string" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" - } - } - ] - }, - "/organizations/{organizationFiscalCode}/services/{serviceId}": { - "get": { - "tags": [ - "Enrollments API" - ], - "summary": "Return the single enrollment to a service.", - "operationId": "getSingleEnrollment", - "parameters": [ - { - "name": "organizationFiscalCode", - "in": "path", - "description": "The fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "serviceId", - "in": "path", - "description": "The service id to enroll.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "404": { - "description": "Not found the enroll service.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "200": { - "description": "Obtained single enrollment.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/EnrollmentModelResponse" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "put": { - "tags": [ - "Enrollments API" - ], - "summary": "The organization update an enrollment to a service for the creditor institution.", - "operationId": "updateECEnrollment", - "parameters": [ - { - "name": "organizationFiscalCode", - "in": "path", - "description": "The fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "serviceId", - "in": "path", - "description": "The service id to enroll.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/EnrollmentModel" - } - } - }, - "required": true - }, - "responses": { - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "200": { - "description": "Request updated.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OrganizationModelResponse" - } - } - } - }, - "404": { - "description": "Not found the creditor institution or the enroll service.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "400": { - "description": "Malformed request.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "post": { - "tags": [ - "Enrollments API" - ], - "summary": "The organization creates an enrollment to a service for the creditor institution.", - "operationId": "createECEnrollment", - "parameters": [ - { - "name": "organizationFiscalCode", - "in": "path", - "description": "The fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "serviceId", - "in": "path", - "description": "The service id to enroll.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/EnrollmentModel" - } - } - }, - "required": true - }, - "responses": { - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "409": { - "description": "The enrollment to the service already exists.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "404": { - "description": "Not found the creditor institution or the enroll service.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "400": { - "description": "Malformed request.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "201": { - "description": "Request created.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OrganizationModelResponse" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "delete": { - "tags": [ - "Enrollments API" - ], - "summary": "The organization deletes the enrollment to service for the creditor institution.", - "operationId": "deleteECEnrollment", - "parameters": [ - { - "name": "organizationFiscalCode", - "in": "path", - "description": "The fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "serviceId", - "in": "path", - "description": "The service id to enroll.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "200": { - "description": "Request deleted.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "type": "string" - } - } - } - }, - "404": { - "description": "Not found the creditor institution or the enroll service.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" - } - } - ] - }, - "/organizations/{organizationfiscalcode}/spontaneouspayments": { - "post": { - "tags": [ - "Payments API" - ], - "summary": "The Organization creates a spontaneous payment.", - "operationId": "createSpontaneousPayment", - "parameters": [ - { - "name": "organizationfiscalcode", - "in": "path", - "description": "Organization fiscal code, the fiscal code of the Organization.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SpontaneousPaymentModel" - } - } - }, - "required": true - }, - "responses": { - "201": { - "description": "Request created.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PaymentPositionModel" - } - } - } - }, - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "400": { - "description": "Malformed request.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "409": { - "description": "Conflict: duplicate debt position found.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" - } - } - ] - }, - "/services": { - "get": { - "tags": [ - "Services API" - ], - "summary": "Return all services.", - "operationId": "getServices", - "responses": { - "200": { - "description": "Obtained all services.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ServiceModelResponse" - } - } - } - } - }, - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" - } - } - ] - }, - "/services/{serviceId}": { - "get": { - "tags": [ - "Services API" - ], - "summary": "Return the single service details.", - "operationId": "getServiceDetails", - "parameters": [ - { - "name": "serviceId", - "in": "path", - "description": "The service id for which to have the details.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "500": { - "description": "Service unavailable.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "200": { - "description": "Obtained single service details.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ServiceDetailModelResponse" - } - } - } - }, - "404": { - "description": "No service found.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" - } - } - } - }, - "401": { - "description": "Wrong or missing function key.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - } - }, - "security": [ - { - "ApiKey": [] - }, - { - "Authorization": [] - } - ] - }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" - } - } - ] - } - }, - "components": { - "schemas": { - "OrganizationModel": { - "type": "object", - "properties": { - "companyName": { - "type": "string" - }, - "status": { - "type": "string", - "enum": [ - "ENABLED", - "DISABLED" - ] - } - } - }, - "ProblemJson": { - "type": "object", - "properties": { - "title": { - "type": "string", - "description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" - }, - "status": { - "maximum": 600, - "minimum": 100, - "type": "integer", - "description": "The HTTP status code generated by the origin server for this occurrence of the problem.", - "format": "int32", - "example": 200 - }, - "detail": { - "type": "string", - "description": "A human readable explanation specific to this occurrence of the problem.", - "example": "There was an error processing the request" - } - } - }, - "EnrollmentModelResponse": { - "required": [ - "iban", - "serviceId" - ], - "type": "object", - "properties": { - "serviceId": { - "type": "string" - }, - "iban": { - "type": "string" - }, - "officeName": { - "type": "string" - } - } - }, - "OrganizationModelResponse": { - "required": [ - "companyName", - "fiscalCode", - "status" - ], - "type": "object", - "properties": { - "fiscalCode": { - "type": "string" - }, - "companyName": { - "type": "string" - }, - "status": { - "type": "string", - "enum": [ - "ENABLED", - "DISABLED" - ] - }, - "enrollments": { - "type": "array", - "items": { - "$ref": "#/components/schemas/EnrollmentModelResponse" - } - } - } - }, - "EnrollmentModel": { - "type": "object", - "properties": { - "iban": { - "type": "string" - }, - "officeName": { - "type": "string" - } - } - }, - "DebtorModel": { - "required": [ - "fiscalCode", - "fullName", - "type" - ], - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": [ - "F", - "G" - ] - }, - "fiscalCode": { - "type": "string" - }, - "fullName": { - "type": "string" - }, - "streetName": { - "type": "string" - }, - "civicNumber": { - "type": "string" - }, - "postalCode": { - "type": "string" - }, - "city": { - "type": "string" - }, - "province": { - "type": "string" - }, - "region": { - "type": "string" - }, - "country": { - "type": "string" - }, - "email": { - "type": "string" - }, - "phone": { - "type": "string" - } - } - }, - "ServiceModel": { - "required": [ - "id", - "properties" - ], - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "properties": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ServicePropertyModel" - } - } - } - }, - "ServicePropertyModel": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "value": { - "type": "string" - } - } - }, - "SpontaneousPaymentModel": { - "required": [ - "debtor", - "service" - ], - "type": "object", - "properties": { - "debtor": { - "$ref": "#/components/schemas/DebtorModel" - }, - "service": { - "$ref": "#/components/schemas/ServiceModel" - } - } - }, - "PaymentOptionModel": { - "required": [ - "amount", - "dueDate", - "isPartialPayment", - "iuv" - ], - "type": "object", - "properties": { - "iuv": { - "type": "string" - }, - "amount": { - "type": "integer", - "format": "int64" - }, - "description": { - "type": "string" - }, - "isPartialPayment": { - "type": "boolean" - }, - "dueDate": { - "type": "string", - "format": "date-time" - }, - "retentionDate": { - "type": "string", - "format": "date-time" - }, - "fee": { - "type": "integer", - "format": "int64" - }, - "transfer": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TransferModel" - } - } - } - }, - "PaymentPositionModel": { - "required": [ - "companyName", - "fiscalCode", - "fullName", - "iupd", - "type" - ], - "type": "object", - "properties": { - "iupd": { - "type": "string" - }, - "type": { - "type": "string", - "enum": [ - "F", - "G" - ] - }, - "fiscalCode": { - "type": "string" - }, - "fullName": { - "type": "string" - }, - "streetName": { - "type": "string" - }, - "civicNumber": { - "type": "string" - }, - "postalCode": { - "type": "string" - }, - "city": { - "type": "string" - }, - "province": { - "type": "string" - }, - "region": { - "type": "string" - }, - "country": { - "type": "string" - }, - "email": { - "type": "string" - }, - "phone": { - "type": "string" - }, - "switchToExpired": { - "type": "boolean", - "description": "feature flag to enable the debt position to expire after the due date", - "example": false, - "default": false - }, - "companyName": { - "type": "string" - }, - "officeName": { - "type": "string" - }, - "validityDate": { - "type": "string", - "format": "date-time" - }, - "status": { - "type": "string", - "readOnly": true, - "enum": [ - "DRAFT", - "PUBLISHED", - "VALID", - "INVALID", - "EXPIRED", - "PARTIALLY_PAID", - "PAID", - "REPORTED" - ] - }, - "paymentOption": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PaymentOptionModel" - } - } - } - }, - "TransferModel": { - "required": [ - "amount", - "category", - "iban", - "idTransfer", - "remittanceInformation" - ], - "type": "object", - "properties": { - "idTransfer": { - "type": "string", - "enum": [ - "1", - "2", - "3", - "4", - "5" - ] - }, - "amount": { - "type": "integer", - "format": "int64" - }, - "remittanceInformation": { - "type": "string" - }, - "category": { - "type": "string" - }, - "iban": { - "type": "string" - }, - "postalIban": { - "type": "string" - } - } - }, - "CreateEnrollmentModel": { - "required": [ - "iban", - "serviceId" - ], - "type": "object", - "properties": { - "serviceId": { - "type": "string" - }, - "iban": { - "type": "string" - }, - "officeName": { - "type": "string" - } - } - }, - "OrganizationEnrollmentModel": { - "required": [ - "companyName" - ], - "type": "object", - "properties": { - "companyName": { - "type": "string" - }, - "enrollments": { - "type": "array", - "items": { - "$ref": "#/components/schemas/CreateEnrollmentModel" - } - } - } - }, - "ServiceModelResponse": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "description": { - "type": "string" - } - } - }, - "ServiceDetailModelResponse": { - "required": [ - "id", - "remittanceInformation", - "status", - "transferCategory" - ], - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "description": { - "type": "string" - }, - "transferCategory": { - "type": "string" - }, - "remittanceInformation": { - "type": "string" - }, - "status": { - "type": "string", - "enum": [ - "ENABLED", - "DISABLED" - ] - }, - "properties": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ServicePropertyModelResponse" - } - } - } - }, - "ServicePropertyModelResponse": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "type": { - "type": "string" - }, - "required": { - "type": "boolean" - } - } - } - }, - "securitySchemes": { - "ApiKey": { - "type": "apiKey", - "description": "The API key to access this function app.", - "name": "Ocp-Apim-Subscription-Key", - "in": "header" - }, - "Authorization": { - "type": "http", - "description": "JWT token get after Azure Login", - "scheme": "bearer", - "bearerFormat": "JWT" - } - } - } -} \ No newline at end of file + "openapi": "3.0.1", + "info": { + "title": "PagoPA API Spontaneous Payment", + "description": "Progetto Gestione Pagamenti Spontanei", + "termsOfService": "https://www.pagopa.gov.it/", + "version": "0.0.1" + }, + "servers": [ + { + "url": "http://localhost:9090", + "description": "Generated server url" + } + ], + "paths": { + "/organizations/{organizationFiscalCode}": { + "get": { + "tags": [ + "Enrollments API" + ], + "summary": "Return all enrollments for a creditor institution.", + "operationId": "getECEnrollments", + "parameters": [ + { + "name": "organizationFiscalCode", + "in": "path", + "description": "The fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Obtained all enrollments for the creditor institution.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationModelResponse" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found the creditor institution.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "put": { + "tags": [ + "Enrollments API" + ], + "summary": "The organization updates the creditor institution.", + "operationId": "updateEC", + "parameters": [ + { + "name": "organizationFiscalCode", + "in": "path", + "description": "The fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationModel" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Request updated.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationModelResponse" + } + } + } + }, + "400": { + "description": "Malformed request.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found the creditor institution.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "post": { + "tags": [ + "Enrollments API" + ], + "summary": "The organization creates a creditor institution with possible enrollments to services.", + "operationId": "createEC", + "parameters": [ + { + "name": "organizationFiscalCode", + "in": "path", + "description": "The fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationEnrollmentModel" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Request created.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationModelResponse" + } + } + } + }, + "400": { + "description": "Malformed request.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "409": { + "description": "The organization to create already exists.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "delete": { + "tags": [ + "Enrollments API" + ], + "summary": "The organization deletes the creditor institution.", + "operationId": "deleteEC", + "parameters": [ + { + "name": "organizationFiscalCode", + "in": "path", + "description": "The fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Request deleted.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found the creditor institution.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "parameters": [ + { + "name": "X-Request-Id", + "in": "header", + "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema": { + "type": "string" + } + } + ] + }, + "/organizations/{organizationFiscalCode}/services/{serviceId}": { + "get": { + "tags": [ + "Enrollments API" + ], + "summary": "Return the single enrollment to a service.", + "operationId": "getSingleEnrollment", + "parameters": [ + { + "name": "organizationFiscalCode", + "in": "path", + "description": "The fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "serviceId", + "in": "path", + "description": "The service id to enroll.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Obtained single enrollment.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EnrollmentModelResponse" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found the enroll service.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "put": { + "tags": [ + "Enrollments API" + ], + "summary": "The organization update an enrollment to a service for the creditor institution.", + "operationId": "updateECEnrollment", + "parameters": [ + { + "name": "organizationFiscalCode", + "in": "path", + "description": "The fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "serviceId", + "in": "path", + "description": "The service id to enroll.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EnrollmentModel" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Request updated.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationModelResponse" + } + } + } + }, + "400": { + "description": "Malformed request.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found the creditor institution or the enroll service.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "post": { + "tags": [ + "Enrollments API" + ], + "summary": "The organization creates an enrollment to a service for the creditor institution.", + "operationId": "createECEnrollment", + "parameters": [ + { + "name": "organizationFiscalCode", + "in": "path", + "description": "The fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "serviceId", + "in": "path", + "description": "The service id to enroll.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EnrollmentModel" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Request created.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationModelResponse" + } + } + } + }, + "400": { + "description": "Malformed request.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found the creditor institution or the enroll service.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "409": { + "description": "The enrollment to the service already exists.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "delete": { + "tags": [ + "Enrollments API" + ], + "summary": "The organization deletes the enrollment to service for the creditor institution.", + "operationId": "deleteECEnrollment", + "parameters": [ + { + "name": "organizationFiscalCode", + "in": "path", + "description": "The fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "serviceId", + "in": "path", + "description": "The service id to enroll.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Request deleted.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found the creditor institution or the enroll service.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "parameters": [ + { + "name": "X-Request-Id", + "in": "header", + "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema": { + "type": "string" + } + } + ] + }, + "/organizations/{organizationfiscalcode}/spontaneouspayments": { + "post": { + "tags": [ + "Payments API" + ], + "summary": "The Organization creates a spontaneous payment.", + "operationId": "createSpontaneousPayment", + "parameters": [ + { + "name": "organizationfiscalcode", + "in": "path", + "description": "Organization fiscal code, the fiscal code of the Organization.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SpontaneousPaymentModel" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Request created.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PaymentPositionModel" + } + } + } + }, + "400": { + "description": "Malformed request.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "409": { + "description": "Conflict: duplicate debt position found.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "parameters": [ + { + "name": "X-Request-Id", + "in": "header", + "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema": { + "type": "string" + } + } + ] + }, + "/services": { + "get": { + "tags": [ + "Services API" + ], + "summary": "Return all services.", + "operationId": "getServices", + "responses": { + "200": { + "description": "Obtained all services.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ServiceModelResponse" + } + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "parameters": [ + { + "name": "X-Request-Id", + "in": "header", + "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema": { + "type": "string" + } + } + ] + }, + "/services/{serviceId}": { + "get": { + "tags": [ + "Services API" + ], + "summary": "Return the single service details.", + "operationId": "getServiceDetails", + "parameters": [ + { + "name": "serviceId", + "in": "path", + "description": "The service id for which to have the details.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Obtained single service details.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ServiceDetailModelResponse" + } + } + } + }, + "401": { + "description": "Wrong or missing function key.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "No service found.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + }, + "500": { + "description": "Service unavailable.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Authorization": [] + } + ] + }, + "parameters": [ + { + "name": "X-Request-Id", + "in": "header", + "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema": { + "type": "string" + } + } + ] + } + }, + "components": { + "schemas": { + "OrganizationModel": { + "type": "object", + "properties": { + "companyName": { + "type": "string" + }, + "status": { + "type": "string", + "enum": [ + "ENABLED", + "DISABLED" + ] + } + } + }, + "ProblemJson": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" + }, + "status": { + "maximum": 600, + "minimum": 100, + "type": "integer", + "description": "The HTTP status code generated by the origin server for this occurrence of the problem.", + "format": "int32", + "example": 200 + }, + "detail": { + "type": "string", + "description": "A human readable explanation specific to this occurrence of the problem.", + "example": "There was an error processing the request" + } + } + }, + "EnrollmentModelResponse": { + "required": [ + "iban", + "serviceId" + ], + "type": "object", + "properties": { + "serviceId": { + "type": "string" + }, + "iban": { + "type": "string" + }, + "officeName": { + "type": "string" + } + } + }, + "OrganizationModelResponse": { + "required": [ + "companyName", + "fiscalCode", + "status" + ], + "type": "object", + "properties": { + "fiscalCode": { + "type": "string" + }, + "companyName": { + "type": "string" + }, + "status": { + "type": "string", + "enum": [ + "ENABLED", + "DISABLED" + ] + }, + "enrollments": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EnrollmentModelResponse" + } + } + } + }, + "EnrollmentModel": { + "type": "object", + "properties": { + "iban": { + "type": "string" + }, + "officeName": { + "type": "string" + } + } + }, + "DebtorModel": { + "required": [ + "fiscalCode", + "fullName", + "type" + ], + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "F", + "G" + ] + }, + "fiscalCode": { + "type": "string" + }, + "fullName": { + "type": "string" + }, + "streetName": { + "type": "string" + }, + "civicNumber": { + "type": "string" + }, + "postalCode": { + "type": "string" + }, + "city": { + "type": "string" + }, + "province": { + "type": "string" + }, + "region": { + "type": "string" + }, + "country": { + "type": "string" + }, + "email": { + "type": "string" + }, + "phone": { + "type": "string" + } + } + }, + "ServiceModel": { + "required": [ + "id", + "properties" + ], + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "properties": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ServicePropertyModel" + } + } + } + }, + "ServicePropertyModel": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "SpontaneousPaymentModel": { + "required": [ + "debtor", + "service" + ], + "type": "object", + "properties": { + "debtor": { + "$ref": "#/components/schemas/DebtorModel" + }, + "service": { + "$ref": "#/components/schemas/ServiceModel" + } + } + }, + "PaymentOptionModel": { + "required": [ + "amount", + "dueDate", + "isPartialPayment", + "iuv" + ], + "type": "object", + "properties": { + "iuv": { + "type": "string" + }, + "amount": { + "type": "integer", + "format": "int64" + }, + "description": { + "type": "string" + }, + "isPartialPayment": { + "type": "boolean" + }, + "dueDate": { + "type": "string", + "format": "date-time" + }, + "retentionDate": { + "type": "string", + "format": "date-time" + }, + "fee": { + "type": "integer", + "format": "int64" + }, + "transfer": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TransferModel" + } + } + } + }, + "PaymentPositionModel": { + "required": [ + "companyName", + "fiscalCode", + "fullName", + "iupd", + "type" + ], + "type": "object", + "properties": { + "iupd": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "F", + "G" + ] + }, + "fiscalCode": { + "type": "string" + }, + "fullName": { + "type": "string" + }, + "streetName": { + "type": "string" + }, + "civicNumber": { + "type": "string" + }, + "postalCode": { + "type": "string" + }, + "city": { + "type": "string" + }, + "province": { + "type": "string" + }, + "region": { + "type": "string" + }, + "country": { + "type": "string" + }, + "email": { + "type": "string" + }, + "phone": { + "type": "string" + }, + "switchToExpired": { + "type": "boolean", + "description": "feature flag to enable the debt position to expire after the due date", + "example": false, + "default": false + }, + "companyName": { + "type": "string" + }, + "officeName": { + "type": "string" + }, + "validityDate": { + "type": "string", + "format": "date-time" + }, + "status": { + "type": "string", + "readOnly": true, + "enum": [ + "DRAFT", + "PUBLISHED", + "VALID", + "INVALID", + "EXPIRED", + "PARTIALLY_PAID", + "PAID", + "REPORTED" + ] + }, + "paymentOption": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PaymentOptionModel" + } + } + } + }, + "TransferModel": { + "required": [ + "amount", + "category", + "iban", + "idTransfer", + "remittanceInformation" + ], + "type": "object", + "properties": { + "idTransfer": { + "type": "string", + "enum": [ + "1", + "2", + "3", + "4", + "5" + ] + }, + "amount": { + "type": "integer", + "format": "int64" + }, + "remittanceInformation": { + "type": "string" + }, + "category": { + "type": "string" + }, + "iban": { + "type": "string" + }, + "postalIban": { + "type": "string" + } + } + }, + "CreateEnrollmentModel": { + "required": [ + "iban", + "serviceId" + ], + "type": "object", + "properties": { + "serviceId": { + "type": "string" + }, + "iban": { + "type": "string" + }, + "officeName": { + "type": "string" + } + } + }, + "OrganizationEnrollmentModel": { + "required": [ + "companyName" + ], + "type": "object", + "properties": { + "companyName": { + "type": "string" + }, + "enrollments": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CreateEnrollmentModel" + } + } + } + }, + "ServiceModelResponse": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + } + } + }, + "ServiceDetailModelResponse": { + "required": [ + "id", + "remittanceInformation", + "status", + "transferCategory" + ], + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "transferCategory": { + "type": "string" + }, + "remittanceInformation": { + "type": "string" + }, + "status": { + "type": "string", + "enum": [ + "ENABLED", + "DISABLED" + ] + }, + "properties": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ServicePropertyModelResponse" + } + } + } + }, + "ServicePropertyModelResponse": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "required": { + "type": "boolean" + } + } + } + }, + "securitySchemes": { + "ApiKey": { + "type": "apiKey", + "description": "The API key to access this function app.", + "name": "Ocp-Apim-Subscription-Key", + "in": "header" + }, + "Authorization": { + "type": "http", + "description": "JWT token get after Azure Login", + "scheme": "bearer", + "bearerFormat": "JWT" + } + } + } +}