Skip to content

Commit

Permalink
Merge pull request #30 from pagopa/PAGOPA-1404-sviluppo-modifiche-get…
Browse files Browse the repository at this point in the history
…-organization-receipt

PAGOPA-1404 adding new biz api fiscalCode-iur
  • Loading branch information
FedericoRuzzier authored Jan 11, 2024
2 parents 2b88b82 + fdfae39 commit b2eaa64
Show file tree
Hide file tree
Showing 15 changed files with 279 additions and 58 deletions.
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: pagopa-biz-events-service
description: Microservice for exposing REST APIs about payment receipts.
type: application
version: 0.20.0
appVersion: 0.1.1
version: 0.22.0
appVersion: 0.1.1-2-PAGOPA-1404-sviluppo-modifiche-get-organization-receipt
dependencies:
- name: microservice-chart
version: 2.4.0
Expand Down
2 changes: 1 addition & 1 deletion helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-biz-events-service
tag: "0.1.1"
tag: "0.1.1-2-PAGOPA-1404-sviluppo-modifiche-get-organization-receipt"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-biz-events-service
tag: "0.1.1"
tag: "0.1.1-2-PAGOPA-1404-sviluppo-modifiche-get-organization-receipt"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-biz-events-service
tag: "0.1.1"
tag: "0.1.1-2-PAGOPA-1404-sviluppo-modifiche-get-organization-receipt"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
184 changes: 153 additions & 31 deletions openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "Biz-Events Service",
"description": "Microservice for exposing REST APIs about payment receipts.",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "0.1.1"
"version": "0.1.1-2-PAGOPA-1404-sviluppo-modifiche-get-organization-receipt"
},
"servers": [
{
Expand Down Expand Up @@ -622,13 +622,153 @@
}
]
},
"/organizations/{organizationfiscalcode}/receipts/{iur}": {
"get": {
"tags": [
"Payment Receipts REST APIs"
],
"summary": "The organization get the receipt for the creditor institution using IUR.",
"operationId": "getOrganizationReceiptIur",
"parameters": [
{
"name": "organizationfiscalcode",
"in": "path",
"description": "The fiscal code of the Organization.",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "iur",
"in": "path",
"description": "The unique reference of the operation assigned to the payment (Payment Token).",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Obtained receipt.",
"headers": {
"X-Request-Id": {
"description": "This header identifies the call",
"schema": {
"type": "string"
}
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CtReceiptModelResponse"
}
}
}
},
"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 receipt.",
"headers": {
"X-Request-Id": {
"description": "This header identifies the call",
"schema": {
"type": "string"
}
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemJson"
}
}
}
},
"422": {
"description": "Unable to process the request.",
"headers": {
"X-Request-Id": {
"description": "This header identifies the call",
"schema": {
"type": "string"
}
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemJson"
}
}
}
},
"429": {
"description": "Too many requests.",
"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": []
}
]
},
"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}/receipts/{iur}/paymentoptions/{iuv}": {
"get": {
"tags": [
"Payment Receipts REST APIs"
],
"summary": "The organization get the receipt for the creditor institution.",
"operationId": "getOrganizationReceipt",
"summary": "The organization get the receipt for the creditor institution using IUV and IUR.",
"operationId": "getOrganizationReceiptIuvIur",
"parameters": [
{
"name": "organizationfiscalcode",
Expand Down Expand Up @@ -908,24 +1048,15 @@
}
},
"Debtor": {
"required": [
"entityUniqueIdentifierType",
"entityUniqueIdentifierValue",
"fullName"
],
"type": "object",
"properties": {
"entityUniqueIdentifierType": {
"type": "string",
"enum": [
"F",
"G"
]
"fullName": {
"type": "string"
},
"entityUniqueIdentifierValue": {
"entityUniqueIdentifierType": {
"type": "string"
},
"fullName": {
"entityUniqueIdentifierValue": {
"type": "string"
},
"streetName": {
Expand All @@ -946,7 +1077,7 @@
"country": {
"type": "string"
},
"email": {
"eMail": {
"type": "string"
}
}
Expand All @@ -963,24 +1094,15 @@
}
},
"Payer": {
"required": [
"entityUniqueIdentifierType",
"entityUniqueIdentifierValue",
"fullName"
],
"type": "object",
"properties": {
"entityUniqueIdentifierType": {
"type": "string",
"enum": [
"F",
"G"
]
"fullName": {
"type": "string"
},
"entityUniqueIdentifierValue": {
"entityUniqueIdentifierType": {
"type": "string"
},
"fullName": {
"entityUniqueIdentifierValue": {
"type": "string"
},
"streetName": {
Expand All @@ -1001,7 +1123,7 @@
"country": {
"type": "string"
},
"email": {
"eMail": {
"type": "string"
}
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>it.gov.pagopa</groupId>
<artifactId>bizeventsservice</artifactId>
<version>0.1.1</version>
<version>0.1.1-2-PAGOPA-1404-sviluppo-modifiche-get-organization-receipt</version>
<name>Biz-Events Service</name>
<description>Microservice for exposing REST APIs about payment receipts.</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@
@RequestMapping
@Validated
public interface IPaymentsController {

@Operation(summary = "The organization get the receipt for the creditor institution.", security = {@SecurityRequirement(name = "ApiKey")}, operationId = "getOrganizationReceipt")

// TODO: this API is included in the one using the path /organizations/{organizationfiscalcode}/receipts/{iur}, will be removed
@Deprecated
/**
* @deprecated (API to be removed after the next SANP release)
*/
@Operation(summary = "The organization get the receipt for the creditor institution using IUV and IUR.", security = {@SecurityRequirement(name = "ApiKey")}, operationId = "getOrganizationReceiptIuvIur")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Obtained receipt.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "CtReceipt", implementation = CtReceiptModelResponse.class))),
@ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())),
Expand All @@ -43,4 +48,20 @@ ResponseEntity<CtReceiptModelResponse> getOrganizationReceipt(
@NotBlank @PathVariable("iur") String iur,
@Parameter(description = "The unique payment identification. Alphanumeric code that uniquely associates and identifies three key elements of a payment: reason, payer, amount", required = true)
@NotBlank @PathVariable("iuv") String iuv);

@Operation(summary = "The organization get the receipt for the creditor institution using IUR.", security = {@SecurityRequirement(name = "ApiKey")}, operationId = "getOrganizationReceiptIur")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Obtained receipt.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "CtReceipt", implementation = CtReceiptModelResponse.class))),
@ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())),
@ApiResponse(responseCode = "404", description = "Not found the receipt.", content = @Content(schema = @Schema(implementation = ProblemJson.class))),
@ApiResponse(responseCode = "422", description = "Unable to process the request.", content = @Content(schema = @Schema(implementation = ProblemJson.class))),
@ApiResponse(responseCode = "429", description = "Too many requests.", content = @Content(schema = @Schema())),
@ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))})
@GetMapping(value = "/organizations/{organizationfiscalcode}/receipts/{iur}",
produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<CtReceiptModelResponse> getOrganizationReceipt(
@Parameter(description = "The fiscal code of the Organization.", required = true)
@NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode,
@Parameter(description = "The unique reference of the operation assigned to the payment (Payment Token).", required = true)
@NotBlank @PathVariable("iur") String iur);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,12 @@ public ResponseEntity<CtReceiptModelResponse> getOrganizationReceipt(@NotBlank S
HttpStatus.OK);
}

@Override
public ResponseEntity<CtReceiptModelResponse> getOrganizationReceipt(@NotBlank String organizationFiscalCode,
@NotBlank String iur) {
return new ResponseEntity<>(
bizEventsService.getOrganizationReceipt(organizationFiscalCode, iur),
HttpStatus.OK);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
import lombok.Getter;
import org.springframework.http.HttpStatus;

import static it.gov.pagopa.bizeventsservice.util.Constants.BIZ_NOT_FOUND_HEADER;
import static it.gov.pagopa.bizeventsservice.util.Constants.BIZ_NOT_UNIQUE_HEADER;


@Getter
public enum AppError {
BIZ_EVENT_NOT_FOUND(HttpStatus.NOT_FOUND, "Biz Event not found", "Not found a biz event for the Organization Fiscal Code %s and IUR %s and IUV %s"),
BIZ_EVENT_NOT_FOUND_WITH_ID(HttpStatus.NOT_FOUND, "Biz Event not found", "Not found a biz event with id %s"),
BIZ_EVENT_NOT_FOUND_WITH_ORG_CF_AND_IUV(HttpStatus.NOT_FOUND, "Biz Event not found", "Not found a biz event for the Organization Fiscal Code %s and IUV %s"),
BIZ_EVENT_NOT_UNIQUE(HttpStatus.UNPROCESSABLE_ENTITY, "Biz Event is not unique", "More than one biz event was found for the Organization Fiscal Code %s and IUR %s and IUV %s"),
BIZ_EVENT_NOT_UNIQUE_WITH_ORG_CF_AND_IUV(HttpStatus.UNPROCESSABLE_ENTITY, "Biz Event is not unique", "More than one biz event was found for the Organization Fiscal Code %s and IUV %s"),
BIZ_EVENT_NOT_FOUND_IUV_IUR(HttpStatus.NOT_FOUND, BIZ_NOT_FOUND_HEADER, "Not found a biz event for the Organization Fiscal Code %s and IUR %s and IUV %s"),
BIZ_EVENT_NOT_FOUND_IUR(HttpStatus.NOT_FOUND, BIZ_NOT_FOUND_HEADER, "Not found a biz event for the Organization Fiscal Code %s and IUR %s"),
BIZ_EVENT_NOT_FOUND_WITH_ID(HttpStatus.NOT_FOUND, BIZ_NOT_FOUND_HEADER, "Not found a biz event with id %s"),
BIZ_EVENT_NOT_FOUND_WITH_ORG_CF_AND_IUV(HttpStatus.NOT_FOUND, BIZ_NOT_FOUND_HEADER, "Not found a biz event for the Organization Fiscal Code %s and IUV %s"),
BIZ_EVENT_NOT_UNIQUE_IUV_IUR(HttpStatus.UNPROCESSABLE_ENTITY, BIZ_NOT_UNIQUE_HEADER, "More than one biz event was found for the Organization Fiscal Code %s and IUR %s and IUV %s"),
BIZ_EVENT_NOT_UNIQUE_IUR(HttpStatus.UNPROCESSABLE_ENTITY, BIZ_NOT_UNIQUE_HEADER, "More than one biz event was found for the Organization Fiscal Code %s and IUR %s"),
BIZ_EVENT_NOT_UNIQUE_WITH_ORG_CF_AND_IUV(HttpStatus.UNPROCESSABLE_ENTITY, BIZ_NOT_UNIQUE_HEADER, "More than one biz event was found for the Organization Fiscal Code %s and IUV %s"),
INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "Internal Server Error", "Something was wrong");

public final HttpStatus httpStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ public interface BizEventsRepository extends CosmosRepository<BizEvent, String>

// TODO when available replace idPa with the paFiscalCode field
@Query("select * from c where c.creditor.idPA = @organizationFiscalCode and c.paymentInfo.paymentToken = @iur and c.debtorPosition.iuv = @iuv and StringToNumber(c.debtorPosition.modelType) > 1")
List<BizEvent> getBizEventByOrgFiscCodeAndIur(@Param("organizationFiscalCode") String organizationFiscalCode,
@Param("iur") String iur, @Param("iuv") String iuv);
List<BizEvent> getBizEventByOrgFiscCodeIuvAndIur(@Param("organizationFiscalCode") String organizationFiscalCode,
@Param("iur") String iur, @Param("iuv") String iuv);

@Query("select * from c where c.creditor.idPA = @organizationFiscalCode and c.debtorPosition.iuv = @iuv")
List<BizEvent> getBizEventByOrgFiscalCodeAndIuv(@Param("organizationFiscalCode") String organizationFiscalCode,
@Param("iuv") String iuv);

@Query("select distinct value c from c JOIN t IN c.transferList where t.fiscalCodePA = @organizationFiscalCode and c.paymentInfo.paymentToken = @iur and StringToNumber(c.debtorPosition.modelType) > 1")
List<BizEvent> getBizEventByOrgFiscCodeAndIur(@Param("organizationFiscalCode") String organizationFiscalCode,
@Param("iur") String iur);

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ CtReceiptModelResponse getOrganizationReceipt(String organizationFiscalCode,

BizEvent getBizEventByOrgFiscalCodeAndIuv(String organizationFiscalCode,
String iuv);
CtReceiptModelResponse getOrganizationReceipt(String organizationFiscalCode,
String iur);

}
Loading

0 comments on commit b2eaa64

Please sign in to comment.