diff --git a/openapi/generated.openapi.json b/openapi/generated.openapi.json index 4f299247..adb6bd63 100644 --- a/openapi/generated.openapi.json +++ b/openapi/generated.openapi.json @@ -4067,6 +4067,67 @@ "BearerAuth" : [ ] } ] } + }, + "/debt-positions/{debtPositionId}" : { + "get" : { + "tags" : [ "debt-position" ], + "operationId" : "getDebtPosition", + "parameters" : [ { + "name" : "debtPositionId", + "in" : "path", + "description" : "The ID of the debt position", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + } ], + "responses" : { + "200" : { + "description" : "Ok", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/DebtPositionDTO" + } + } + } + }, + "400" : { + "description" : "Invalid request", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/DebtPositionErrorDTO" + } + } + } + }, + "404" : { + "description" : "Not found", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/DebtPositionErrorDTO" + } + } + } + }, + "500" : { + "description" : "Server Error", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/DebtPositionErrorDTO" + } + } + } + } + }, + "security" : [ { + "BearerAuth" : [ ] + } ] + } } }, "components" : { @@ -4145,7 +4206,7 @@ } } }, - "DebtPosition" : { + "PaymentOption" : { "type" : "object", "properties" : { "creationDate" : { @@ -4159,50 +4220,42 @@ "updateOperatorExternalId" : { "type" : "string" }, - "debtPositionId" : { + "paymentOptionId" : { "type" : "integer", "format" : "int64" }, - "iupdOrg" : { - "type" : "string" - }, - "description" : { - "type" : "string" - }, - "status" : { - "type" : "string", - "enum" : [ "TO_SYNC", "REPORTED", "PAID", "PARTIALLY_PAID", "CANCELLED", "EXPIRED", "UNPAID", "DRAFT" ] - }, - "debtPositionOrigin" : { - "type" : "string", - "enum" : [ "ORDINARY", "ORDINARY_SIL", "SPONTANEOUS", "SECONDARY_ORG", "RECEIPT_FILE", "RECEIPT_PAGOPA", "REPORTING_PAGOPA" ] - }, - "organizationId" : { + "debtPositionId" : { "type" : "integer", "format" : "int64" }, - "debtPositionTypeOrgId" : { + "totalAmountCents" : { "type" : "integer", "format" : "int64" }, - "validityDate" : { + "status" : { + "type" : "string", + "enum" : [ "TO_SYNC", "REPORTED", "PAID", "PARTIALLY_PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] + }, + "dueDate" : { "type" : "string", "format" : "date-time" }, - "flagIuvVolatile" : { - "type" : "boolean" + "description" : { + "type" : "string" }, - "multiDebtor" : { - "type" : "boolean" + "paymentOptionType" : { + "type" : "string", + "enum" : [ "SINGLE_INSTALLMENT", "INSTALLMENTS", "DOWN_PAYMENT" ] }, - "flagPagoPaPayment" : { - "type" : "boolean" + "paymentOptionIndex" : { + "type" : "integer", + "format" : "int32" }, "_links" : { "$ref" : "#/components/schemas/Links" } }, - "required" : [ "debtPositionOrigin", "debtPositionTypeOrgId", "iupdOrg", "organizationId", "status" ] + "required" : [ "debtPositionId", "description", "paymentOptionIndex", "paymentOptionType", "status", "totalAmountCents" ] }, "InstallmentSyncStatus" : { "type" : "object", @@ -4218,6 +4271,20 @@ }, "required" : [ "syncStatusFrom", "syncStatusTo" ] }, + "Stamp" : { + "type" : "object", + "properties" : { + "stampType" : { + "type" : "string" + }, + "stampHashDocument" : { + "type" : "string" + }, + "stampProvincialResidence" : { + "type" : "string" + } + } + }, "PageMetadata" : { "type" : "object", "properties" : { @@ -4239,16 +4306,16 @@ } } }, - "PagedModelDebtPosition" : { + "PagedModelPaymentOption" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositions" : { + "paymentOptions" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPosition" + "$ref" : "#/components/schemas/PaymentOption" } } } @@ -4261,30 +4328,16 @@ } } }, - "Stamp" : { - "type" : "object", - "properties" : { - "stampType" : { - "type" : "string" - }, - "stampHashDocument" : { - "type" : "string" - }, - "stampProvincialResidence" : { - "type" : "string" - } - } - }, - "CollectionModelObject" : { + "CollectionModelInstallmentNoPII" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "objects" : { + "installmentNoPIIs" : { "type" : "array", "items" : { - "type" : "object" + "$ref" : "#/components/schemas/InstallmentNoPIIResponse" } } } @@ -4294,16 +4347,16 @@ } } }, - "CollectionModelPaymentOption" : { + "CollectionModelObject" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "paymentOptions" : { + "objects" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/PaymentOptionResponse" + "type" : "object" } } } @@ -4313,7 +4366,7 @@ } } }, - "DebtPositionTypeOrgOperators" : { + "InstallmentNoPII" : { "type" : "object", "properties" : { "creationDate" : { @@ -4327,106 +4380,103 @@ "updateOperatorExternalId" : { "type" : "string" }, - "debtPositionTypeOrgOperatorId" : { + "installmentId" : { "type" : "integer", "format" : "int64" }, - "debtPositionTypeOrgId" : { + "paymentOptionId" : { "type" : "integer", "format" : "int64" }, - "operatorExternalUserId" : { + "status" : { + "type" : "string", + "enum" : [ "TO_SYNC", "REPORTED", "PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] + }, + "iupdPagopa" : { "type" : "string" }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - }, - "required" : [ "debtPositionTypeOrgId", "operatorExternalUserId" ] - }, - "PagedModelDebtPositionTypeOrgOperators" : { - "type" : "object", - "properties" : { - "_embedded" : { - "type" : "object", - "properties" : { - "debtPositionTypeOrgOperatorses" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/DebtPositionTypeOrgOperators" - } - } - } + "iud" : { + "type" : "string" }, - "_links" : { - "$ref" : "#/components/schemas/Links" + "iuv" : { + "type" : "string" }, - "page" : { - "$ref" : "#/components/schemas/PageMetadata" - } - } - }, - "PaymentOption" : { - "type" : "object", - "properties" : { - "creationDate" : { - "type" : "string", - "format" : "date-time" + "iur" : { + "type" : "string" }, - "updateDate" : { + "iuf" : { + "type" : "string" + }, + "nav" : { + "type" : "string" + }, + "dueDate" : { "type" : "string", "format" : "date-time" }, - "updateOperatorExternalId" : { + "paymentTypeCode" : { "type" : "string" }, - "paymentOptionId" : { + "amountCents" : { "type" : "integer", "format" : "int64" }, - "debtPositionId" : { - "type" : "integer", - "format" : "int64" + "remittanceInformation" : { + "type" : "string" }, - "totalAmountCents" : { + "balance" : { + "type" : "string" + }, + "legacyPaymentMetadata" : { + "type" : "string" + }, + "personalDataId" : { "type" : "integer", "format" : "int64" }, - "status" : { + "debtorEntityType" : { "type" : "string", - "enum" : [ "TO_SYNC", "REPORTED", "PAID", "PARTIALLY_PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] + "enum" : [ "F", "G" ] }, - "dueDate" : { + "debtorFiscalCodeHash" : { "type" : "string", - "format" : "date-time" + "format" : "byte" }, - "description" : { - "type" : "string" + "syncStatus" : { + "$ref" : "#/components/schemas/InstallmentSyncStatus" }, - "paymentOptionType" : { + "notificationDate" : { "type" : "string", - "enum" : [ "SINGLE_INSTALLMENT", "INSTALLMENTS", "DOWN_PAYMENT" ] + "format" : "date-time" }, - "paymentOptionIndex" : { + "ingestionFlowFileId" : { "type" : "integer", - "format" : "int32" + "format" : "int64" + }, + "ingestionFlowFileLineNumber" : { + "type" : "integer", + "format" : "int64" + }, + "receiptId" : { + "type" : "integer", + "format" : "int64" }, "_links" : { "$ref" : "#/components/schemas/Links" } }, - "required" : [ "debtPositionId", "description", "paymentOptionIndex", "paymentOptionType", "status", "totalAmountCents" ] + "required" : [ "amountCents", "debtorEntityType", "debtorFiscalCodeHash", "iud", "paymentOptionId", "paymentTypeCode", "personalDataId", "remittanceInformation", "status" ] }, - "PagedModelPaymentOption" : { + "PagedModelInstallmentNoPII" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "paymentOptions" : { + "installmentNoPIIs" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/PaymentOption" + "$ref" : "#/components/schemas/InstallmentNoPII" } } } @@ -4439,16 +4489,16 @@ } } }, - "CollectionModelInstallmentNoPII" : { + "CollectionModelTransfer" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "installmentNoPIIs" : { + "transfers" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/InstallmentNoPIIResponse" + "$ref" : "#/components/schemas/TransferResponse" } } } @@ -4458,23 +4508,30 @@ } } }, - "DebtPositionView" : { + "DebtPosition" : { "type" : "object", "properties" : { + "creationDate" : { + "type" : "string", + "format" : "date-time" + }, + "updateDate" : { + "type" : "string", + "format" : "date-time" + }, + "updateOperatorExternalId" : { + "type" : "string" + }, "debtPositionId" : { "type" : "integer", "format" : "int64" }, - "description" : { + "iupdOrg" : { "type" : "string" }, - "debtPositionTypeOrgDescription" : { + "description" : { "type" : "string" }, - "creationDate" : { - "type" : "string", - "format" : "date-time" - }, "status" : { "type" : "string", "enum" : [ "TO_SYNC", "REPORTED", "PAID", "PARTIALLY_PAID", "CANCELLED", "EXPIRED", "UNPAID", "DRAFT" ] @@ -4483,30 +4540,43 @@ "type" : "string", "enum" : [ "ORDINARY", "ORDINARY_SIL", "SPONTANEOUS", "SECONDARY_ORG", "RECEIPT_FILE", "RECEIPT_PAGOPA", "REPORTING_PAGOPA" ] }, - "debtPositionTypeOrgId" : { + "organizationId" : { "type" : "integer", "format" : "int64" }, - "organizationId" : { + "debtPositionTypeOrgId" : { "type" : "integer", "format" : "int64" }, + "validityDate" : { + "type" : "string", + "format" : "date-time" + }, + "flagIuvVolatile" : { + "type" : "boolean" + }, + "multiDebtor" : { + "type" : "boolean" + }, + "flagPagoPaPayment" : { + "type" : "boolean" + }, "_links" : { "$ref" : "#/components/schemas/Links" } }, - "required" : [ "debtPositionOrigin", "debtPositionTypeOrgId", "organizationId", "status" ] + "required" : [ "debtPositionOrigin", "debtPositionTypeOrgId", "iupdOrg", "organizationId", "status" ] }, - "PagedModelDebtPositionView" : { + "PagedModelDebtPosition" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositionViews" : { + "debtPositions" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPositionView" + "$ref" : "#/components/schemas/DebtPosition" } } } @@ -4519,33 +4589,59 @@ } } }, - "ReceiptView" : { + "CollectionModelPaymentOption" : { "type" : "object", "properties" : { - "receiptId" : { + "_embedded" : { + "type" : "object", + "properties" : { + "paymentOptions" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/PaymentOptionResponse" + } + } + } + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "InstallmentView" : { + "type" : "object", + "properties" : { + "installmentId" : { "type" : "integer", "format" : "int64" }, - "paymentAmountCents" : { + "paymentOptionId" : { "type" : "integer", "format" : "int64" }, - "paymentDateTime" : { + "iuv" : { + "type" : "string" + }, + "status" : { + "type" : "string", + "enum" : [ "TO_SYNC", "REPORTED", "PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] + }, + "dueDate" : { "type" : "string", "format" : "date-time" }, - "installmentId" : { + "amountCents" : { "type" : "integer", "format" : "int64" }, - "receiptOrigin" : { - "type" : "string", - "enum" : [ "RECEIPT_PAGOPA", "RECEIPT_FILE" ] - }, - "iuv" : { + "remittanceInformation" : { "type" : "string" }, - "description" : { + "debtorFiscalCodeHash" : { + "type" : "string", + "format" : "byte" + }, + "debtPositionTypeOrgDescription" : { "type" : "string" }, "_links" : { @@ -4553,16 +4649,16 @@ } } }, - "PagedModelReceiptView" : { + "PagedModelInstallmentView" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "receiptViews" : { + "installmentViews" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/ReceiptView" + "$ref" : "#/components/schemas/InstallmentView" } } } @@ -4575,7 +4671,7 @@ } } }, - "Transfer" : { + "DebtPositionType" : { "type" : "object", "properties" : { "creationDate" : { @@ -4589,59 +4685,63 @@ "updateOperatorExternalId" : { "type" : "string" }, - "transferId" : { + "debtPositionTypeId" : { "type" : "integer", "format" : "int64" }, - "installmentId" : { + "brokerId" : { "type" : "integer", "format" : "int64" }, - "orgFiscalCode" : { + "code" : { "type" : "string" }, - "orgName" : { + "description" : { "type" : "string" }, - "amountCents" : { - "type" : "integer", - "format" : "int64" - }, - "remittanceInformation" : { + "orgType" : { "type" : "string" }, - "stamp" : { - "$ref" : "#/components/schemas/Stamp" + "macroArea" : { + "type" : "string" }, - "iban" : { + "serviceType" : { "type" : "string" }, - "postalIban" : { + "collectingReason" : { "type" : "string" }, - "category" : { + "taxonomyCode" : { "type" : "string" }, - "transferIndex" : { - "type" : "integer", - "format" : "int32" + "flagAnonymousFiscalCode" : { + "type" : "boolean" + }, + "flagMandatoryDueDate" : { + "type" : "boolean" + }, + "flagNotifyIo" : { + "type" : "boolean" + }, + "ioTemplateMessage" : { + "type" : "string" }, "_links" : { "$ref" : "#/components/schemas/Links" } }, - "required" : [ "amountCents", "category", "installmentId", "orgFiscalCode", "remittanceInformation", "transferIndex" ] + "required" : [ "brokerId", "code", "collectingReason", "description", "macroArea", "orgType", "serviceType", "taxonomyCode" ] }, - "PagedModelTransfer" : { + "PagedModelDebtPositionType" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "transfers" : { + "debtPositionTypes" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/Transfer" + "$ref" : "#/components/schemas/DebtPositionType" } } } @@ -4654,57 +4754,46 @@ } } }, - "InstallmentView" : { + "DebtPositionTypeWithCount" : { "type" : "object", "properties" : { - "installmentId" : { - "type" : "integer", - "format" : "int64" - }, - "paymentOptionId" : { + "debtPositionTypeId" : { "type" : "integer", "format" : "int64" }, - "iuv" : { + "code" : { "type" : "string" }, - "status" : { - "type" : "string", - "enum" : [ "TO_SYNC", "REPORTED", "PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] + "description" : { + "type" : "string" }, - "dueDate" : { + "updateDate" : { "type" : "string", "format" : "date-time" }, - "amountCents" : { + "activeOrganizations" : { "type" : "integer", - "format" : "int64" - }, - "remittanceInformation" : { - "type" : "string" - }, - "debtorFiscalCodeHash" : { - "type" : "string", - "format" : "byte" + "format" : "int32" }, - "debtPositionTypeOrgDescription" : { - "type" : "string" + "brokerId" : { + "type" : "integer", + "format" : "int64" }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelInstallmentView" : { + "PagedModelDebtPositionTypeWithCount" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "installmentViews" : { + "debtPositionTypeWithCounts" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/InstallmentView" + "$ref" : "#/components/schemas/DebtPositionTypeWithCount" } } } @@ -4717,98 +4806,36 @@ } } }, - "InstallmentNoPII" : { + "DebtPositionView" : { "type" : "object", "properties" : { - "creationDate" : { - "type" : "string", - "format" : "date-time" - }, - "updateDate" : { - "type" : "string", - "format" : "date-time" - }, - "updateOperatorExternalId" : { - "type" : "string" - }, - "installmentId" : { - "type" : "integer", - "format" : "int64" - }, - "paymentOptionId" : { + "debtPositionId" : { "type" : "integer", "format" : "int64" }, - "status" : { - "type" : "string", - "enum" : [ "TO_SYNC", "REPORTED", "PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] - }, - "iupdPagopa" : { - "type" : "string" - }, - "iud" : { - "type" : "string" - }, - "iuv" : { - "type" : "string" - }, - "iur" : { - "type" : "string" - }, - "iuf" : { + "description" : { "type" : "string" }, - "nav" : { + "debtPositionTypeOrgDescription" : { "type" : "string" }, - "dueDate" : { + "creationDate" : { "type" : "string", "format" : "date-time" }, - "paymentTypeCode" : { - "type" : "string" - }, - "amountCents" : { - "type" : "integer", - "format" : "int64" - }, - "remittanceInformation" : { - "type" : "string" - }, - "balance" : { - "type" : "string" - }, - "legacyPaymentMetadata" : { - "type" : "string" - }, - "personalDataId" : { - "type" : "integer", - "format" : "int64" - }, - "debtorEntityType" : { - "type" : "string", - "enum" : [ "F", "G" ] - }, - "debtorFiscalCodeHash" : { + "status" : { "type" : "string", - "format" : "byte" - }, - "syncStatus" : { - "$ref" : "#/components/schemas/InstallmentSyncStatus" + "enum" : [ "TO_SYNC", "REPORTED", "PAID", "PARTIALLY_PAID", "CANCELLED", "EXPIRED", "UNPAID", "DRAFT" ] }, - "notificationDate" : { + "debtPositionOrigin" : { "type" : "string", - "format" : "date-time" - }, - "ingestionFlowFileId" : { - "type" : "integer", - "format" : "int64" + "enum" : [ "ORDINARY", "ORDINARY_SIL", "SPONTANEOUS", "SECONDARY_ORG", "RECEIPT_FILE", "RECEIPT_PAGOPA", "REPORTING_PAGOPA" ] }, - "ingestionFlowFileLineNumber" : { + "debtPositionTypeOrgId" : { "type" : "integer", "format" : "int64" }, - "receiptId" : { + "organizationId" : { "type" : "integer", "format" : "int64" }, @@ -4816,18 +4843,18 @@ "$ref" : "#/components/schemas/Links" } }, - "required" : [ "amountCents", "debtorEntityType", "debtorFiscalCodeHash", "iud", "paymentOptionId", "paymentTypeCode", "personalDataId", "remittanceInformation", "status" ] + "required" : [ "debtPositionOrigin", "debtPositionTypeOrgId", "organizationId", "status" ] }, - "PagedModelInstallmentNoPII" : { + "PagedModelDebtPositionView" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "installmentNoPIIs" : { + "debtPositionViews" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/InstallmentNoPII" + "$ref" : "#/components/schemas/DebtPositionView" } } } @@ -4840,65 +4867,47 @@ } } }, - "CollectionModelTransfer" : { - "type" : "object", - "properties" : { - "_embedded" : { - "type" : "object", - "properties" : { - "transfers" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/TransferResponse" - } - } - } - }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - } - }, - "DebtPositionTypeWithCount" : { + "DebtPositionTypeOrgOperators" : { "type" : "object", "properties" : { - "debtPositionTypeId" : { - "type" : "integer", - "format" : "int64" - }, - "code" : { - "type" : "string" - }, - "description" : { - "type" : "string" + "creationDate" : { + "type" : "string", + "format" : "date-time" }, "updateDate" : { "type" : "string", "format" : "date-time" }, - "activeOrganizations" : { + "updateOperatorExternalId" : { + "type" : "string" + }, + "debtPositionTypeOrgOperatorId" : { "type" : "integer", - "format" : "int32" + "format" : "int64" }, - "brokerId" : { + "debtPositionTypeOrgId" : { "type" : "integer", "format" : "int64" }, + "operatorExternalUserId" : { + "type" : "string" + }, "_links" : { "$ref" : "#/components/schemas/Links" } - } + }, + "required" : [ "debtPositionTypeOrgId", "operatorExternalUserId" ] }, - "PagedModelDebtPositionTypeWithCount" : { + "PagedModelDebtPositionTypeOrgOperators" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositionTypeWithCounts" : { + "debtPositionTypeOrgOperatorses" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPositionTypeWithCount" + "$ref" : "#/components/schemas/DebtPositionTypeOrgOperators" } } } @@ -5048,7 +5057,7 @@ } } }, - "DebtPositionType" : { + "Transfer" : { "type" : "object", "properties" : { "creationDate" : { @@ -5062,63 +5071,115 @@ "updateOperatorExternalId" : { "type" : "string" }, - "debtPositionTypeId" : { + "transferId" : { "type" : "integer", "format" : "int64" }, - "brokerId" : { + "installmentId" : { "type" : "integer", "format" : "int64" }, - "code" : { + "orgFiscalCode" : { "type" : "string" }, - "description" : { + "orgName" : { "type" : "string" }, - "orgType" : { - "type" : "string" + "amountCents" : { + "type" : "integer", + "format" : "int64" }, - "macroArea" : { + "remittanceInformation" : { "type" : "string" }, - "serviceType" : { + "stamp" : { + "$ref" : "#/components/schemas/Stamp" + }, + "iban" : { "type" : "string" }, - "collectingReason" : { + "postalIban" : { "type" : "string" }, - "taxonomyCode" : { + "category" : { "type" : "string" }, - "flagAnonymousFiscalCode" : { - "type" : "boolean" + "transferIndex" : { + "type" : "integer", + "format" : "int32" }, - "flagMandatoryDueDate" : { - "type" : "boolean" + "_links" : { + "$ref" : "#/components/schemas/Links" + } + }, + "required" : [ "amountCents", "category", "installmentId", "orgFiscalCode", "remittanceInformation", "transferIndex" ] + }, + "PagedModelTransfer" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "transfers" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Transfer" + } + } + } }, - "flagNotifyIo" : { - "type" : "boolean" + "_links" : { + "$ref" : "#/components/schemas/Links" }, - "ioTemplateMessage" : { + "page" : { + "$ref" : "#/components/schemas/PageMetadata" + } + } + }, + "ReceiptView" : { + "type" : "object", + "properties" : { + "receiptId" : { + "type" : "integer", + "format" : "int64" + }, + "paymentAmountCents" : { + "type" : "integer", + "format" : "int64" + }, + "paymentDateTime" : { + "type" : "string", + "format" : "date-time" + }, + "installmentId" : { + "type" : "integer", + "format" : "int64" + }, + "receiptOrigin" : { + "type" : "string", + "enum" : [ "RECEIPT_PAGOPA", "RECEIPT_FILE" ] + }, + "iuv" : { + "type" : "string" + }, + "description" : { "type" : "string" }, "_links" : { "$ref" : "#/components/schemas/Links" } - }, - "required" : [ "brokerId", "code", "collectingReason", "description", "macroArea", "orgType", "serviceType", "taxonomyCode" ] + } }, - "PagedModelDebtPositionType" : { + "PagedModelReceiptView" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositionTypes" : { + "receiptViews" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPositionType" + "$ref" : "#/components/schemas/ReceiptView" } } } diff --git a/openapi/p4pa-debt-position.openapi.yaml b/openapi/p4pa-debt-position.openapi.yaml index 47ba4cfa..f47c437a 100644 --- a/openapi/p4pa-debt-position.openapi.yaml +++ b/openapi/p4pa-debt-position.openapi.yaml @@ -52,6 +52,44 @@ paths: $ref: "#/components/schemas/DebtPositionErrorDTO" "500": description: Internal server error + /debt-positions/{debtPositionId}: + get: + tags: + - debt-position + operationId: getDebtPosition + parameters: + - name: debtPositionId + in: path + required: true + schema: + type: integer + format: int64 + description: The ID of the debt position + responses: + "200": + description: Ok + content: + application/json: + schema: + $ref: "#/components/schemas/DebtPositionDTO" + "400": + description: Invalid request + content: + application/json: + schema: + $ref: '#/components/schemas/DebtPositionErrorDTO' + "404": + description: Not found + content: + application/json: + schema: + $ref: '#/components/schemas/DebtPositionErrorDTO' + '500': + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/DebtPositionErrorDTO' /installments/{organizationId}/{nav}: get: tags: diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/controller/DebtPositionControllerImpl.java b/src/main/java/it/gov/pagopa/pu/debtpositions/controller/DebtPositionControllerImpl.java index c77e6430..800ec212 100644 --- a/src/main/java/it/gov/pagopa/pu/debtpositions/controller/DebtPositionControllerImpl.java +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/controller/DebtPositionControllerImpl.java @@ -3,24 +3,27 @@ import it.gov.pagopa.pu.debtpositions.controller.generated.DebtPositionApi; import it.gov.pagopa.pu.debtpositions.dto.generated.DebtPositionDTO; import it.gov.pagopa.pu.debtpositions.dto.generated.IupdSyncStatusUpdateDTO; +import it.gov.pagopa.pu.debtpositions.service.DebtPositionService; import it.gov.pagopa.pu.debtpositions.service.create.debtposition.CreateDebtPositionService; import it.gov.pagopa.pu.debtpositions.service.statusalign.DebtPositionHierarchyStatusAlignerService; import it.gov.pagopa.pu.debtpositions.util.SecurityUtils; +import java.util.Map; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; -import java.util.Map; - @RestController public class DebtPositionControllerImpl implements DebtPositionApi { private final DebtPositionHierarchyStatusAlignerService debtPositionHierarchyStatusAlignerService; private final CreateDebtPositionService createDebtPositionService; + private final DebtPositionService debtPositionService; - public DebtPositionControllerImpl(DebtPositionHierarchyStatusAlignerService debtPositionHierarchyStatusAlignerService, CreateDebtPositionService createDebtPositionService) { + public DebtPositionControllerImpl(DebtPositionHierarchyStatusAlignerService debtPositionHierarchyStatusAlignerService, CreateDebtPositionService createDebtPositionService, + DebtPositionService debtPositionService) { this.debtPositionHierarchyStatusAlignerService = debtPositionHierarchyStatusAlignerService; this.createDebtPositionService = createDebtPositionService; + this.debtPositionService = debtPositionService; } @Override @@ -43,5 +46,11 @@ public ResponseEntity checkAndUpdateInstallmentExpiration(Long DebtPositionDTO body = debtPositionHierarchyStatusAlignerService.checkAndUpdateInstallmentExpiration(debtPositionId); return new ResponseEntity<>(body, HttpStatus.OK); } + + @Override + public ResponseEntity getDebtPosition( + Long debtPositionId) { + return ResponseEntity.ok(debtPositionService.getDebtPosition(debtPositionId)); + } } diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/mapper/DebtPositionMapper.java b/src/main/java/it/gov/pagopa/pu/debtpositions/mapper/DebtPositionMapper.java index 9f9c9d08..6f5bc1de 100644 --- a/src/main/java/it/gov/pagopa/pu/debtpositions/mapper/DebtPositionMapper.java +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/mapper/DebtPositionMapper.java @@ -1,18 +1,20 @@ package it.gov.pagopa.pu.debtpositions.mapper; +import static it.gov.pagopa.pu.debtpositions.util.Utilities.localDatetimeToOffsetDateTime; + import it.gov.pagopa.pu.debtpositions.dto.Installment; import it.gov.pagopa.pu.debtpositions.dto.generated.DebtPositionDTO; import it.gov.pagopa.pu.debtpositions.model.DebtPosition; import it.gov.pagopa.pu.debtpositions.model.InstallmentNoPII; import it.gov.pagopa.pu.debtpositions.model.PaymentOption; -import org.springframework.data.util.Pair; -import org.springframework.stereotype.Service; - -import java.util.*; +import java.util.HashMap; +import java.util.Map; +import java.util.SortedSet; +import java.util.TreeSet; import java.util.stream.Collector; import java.util.stream.Collectors; - -import static it.gov.pagopa.pu.debtpositions.util.Utilities.localDatetimeToOffsetDateTime; +import org.springframework.data.util.Pair; +import org.springframework.stereotype.Service; @Service public class DebtPositionMapper { diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/repository/DebtPositionRepository.java b/src/main/java/it/gov/pagopa/pu/debtpositions/repository/DebtPositionRepository.java index 6b172325..563526b5 100644 --- a/src/main/java/it/gov/pagopa/pu/debtpositions/repository/DebtPositionRepository.java +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/repository/DebtPositionRepository.java @@ -49,5 +49,4 @@ WHERE EXISTS ( """) @EntityGraph(value = "completeDebtPosition") DebtPosition findByInstallmentId(@Param("installmentId") Long installmentId); - } diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/service/DebtPositionService.java b/src/main/java/it/gov/pagopa/pu/debtpositions/service/DebtPositionService.java index 936e260e..6329c511 100644 --- a/src/main/java/it/gov/pagopa/pu/debtpositions/service/DebtPositionService.java +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/service/DebtPositionService.java @@ -6,4 +6,5 @@ public interface DebtPositionService { DebtPositionDTO saveDebtPosition(DebtPositionDTO debtPositionDTO, Organization org); + DebtPositionDTO getDebtPosition(Long debtPositionId); } diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/service/DebtPositionServiceImpl.java b/src/main/java/it/gov/pagopa/pu/debtpositions/service/DebtPositionServiceImpl.java index ab50ce71..97f165f9 100644 --- a/src/main/java/it/gov/pagopa/pu/debtpositions/service/DebtPositionServiceImpl.java +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/service/DebtPositionServiceImpl.java @@ -3,6 +3,7 @@ import io.micrometer.common.util.StringUtils; import it.gov.pagopa.pu.debtpositions.dto.Installment; import it.gov.pagopa.pu.debtpositions.dto.generated.DebtPositionDTO; +import it.gov.pagopa.pu.debtpositions.exception.custom.NotFoundException; import it.gov.pagopa.pu.debtpositions.mapper.DebtPositionMapper; import it.gov.pagopa.pu.debtpositions.model.DebtPosition; import it.gov.pagopa.pu.debtpositions.model.InstallmentNoPII; @@ -14,11 +15,10 @@ import it.gov.pagopa.pu.debtpositions.util.Utilities; import it.gov.pagopa.pu.organization.dto.generated.Organization; import jakarta.transaction.Transactional; +import java.util.Map; import org.springframework.data.util.Pair; import org.springframework.stereotype.Service; -import java.util.Map; - @Service public class DebtPositionServiceImpl implements DebtPositionService { @@ -75,5 +75,14 @@ public DebtPositionDTO saveDebtPosition(DebtPositionDTO debtPositionDTO, Organiz return debtPositionMapper.mapToDto(savedDebtPosition); } + + @Override + public DebtPositionDTO getDebtPosition(Long debtPositionId) { + DebtPosition debtPosition = debtPositionRepository.findOneWithAllDataByDebtPositionId(debtPositionId); + if(debtPosition==null) { + throw new NotFoundException("DebtPosition having debtPositionId %d not found".formatted(debtPositionId)); + } + return debtPositionMapper.mapToDto(debtPosition); + } } diff --git a/src/test/java/it/gov/pagopa/pu/debtpositions/controller/DebtPositionControllerTest.java b/src/test/java/it/gov/pagopa/pu/debtpositions/controller/DebtPositionControllerTest.java index d1fafcea..6dcd3b2a 100644 --- a/src/test/java/it/gov/pagopa/pu/debtpositions/controller/DebtPositionControllerTest.java +++ b/src/test/java/it/gov/pagopa/pu/debtpositions/controller/DebtPositionControllerTest.java @@ -1,11 +1,21 @@ package it.gov.pagopa.pu.debtpositions.controller; +import static it.gov.pagopa.pu.debtpositions.util.faker.DebtPositionFaker.buildDebtPositionDTO; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + import com.fasterxml.jackson.databind.ObjectMapper; import it.gov.pagopa.pu.debtpositions.dto.generated.DebtPositionDTO; import it.gov.pagopa.pu.debtpositions.dto.generated.InstallmentStatus; import it.gov.pagopa.pu.debtpositions.dto.generated.IupdSyncStatusUpdateDTO; +import it.gov.pagopa.pu.debtpositions.service.DebtPositionService; import it.gov.pagopa.pu.debtpositions.service.create.debtposition.CreateDebtPositionService; import it.gov.pagopa.pu.debtpositions.service.statusalign.DebtPositionHierarchyStatusAlignerService; +import java.util.HashMap; +import java.util.Map; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; @@ -16,15 +26,6 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; -import java.util.HashMap; -import java.util.Map; - -import static it.gov.pagopa.pu.debtpositions.util.faker.DebtPositionFaker.buildDebtPositionDTO; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - @WebMvcTest(DebtPositionControllerImpl.class) @AutoConfigureMockMvc(addFilters = false) class DebtPositionControllerTest { @@ -41,6 +42,9 @@ class DebtPositionControllerTest { @MockitoBean private CreateDebtPositionService createDebtPositionService; + @MockitoBean + private DebtPositionService debtPositionService; + @Test void whenFinalizeSyncStatusThenOk() throws Exception { Long id = 1L; @@ -102,4 +106,21 @@ void whenCheckAndUpdateInstallmentExpirationThenOk() throws Exception { DebtPositionDTO resultResponse = objectMapper.readValue(result.getResponse().getContentAsString(), DebtPositionDTO.class); assertEquals(buildDebtPositionDTO(), resultResponse); } + + @Test + void whenGetDebtPositionThenOk() throws Exception { + Long debtPositionId = 1L; + + DebtPositionDTO expectedResult = new DebtPositionDTO(); + Mockito.when(debtPositionService.getDebtPosition(debtPositionId)).thenReturn(expectedResult); + + MvcResult result = mockMvc.perform( + get("/debt-positions/"+debtPositionId) + .contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(status().isOk()) + .andReturn(); + + DebtPositionDTO resultResponse = objectMapper.readValue(result.getResponse().getContentAsString(), DebtPositionDTO.class); + assertEquals(expectedResult, resultResponse); + } } diff --git a/src/test/java/it/gov/pagopa/pu/debtpositions/mapper/DebtPositionMapperTest.java b/src/test/java/it/gov/pagopa/pu/debtpositions/mapper/DebtPositionMapperTest.java index ef306809..d189fc8e 100644 --- a/src/test/java/it/gov/pagopa/pu/debtpositions/mapper/DebtPositionMapperTest.java +++ b/src/test/java/it/gov/pagopa/pu/debtpositions/mapper/DebtPositionMapperTest.java @@ -1,11 +1,22 @@ package it.gov.pagopa.pu.debtpositions.mapper; +import static it.gov.pagopa.pu.debtpositions.util.TestUtils.checkNotNullFields; +import static it.gov.pagopa.pu.debtpositions.util.TestUtils.reflectionEqualsByName; +import static it.gov.pagopa.pu.debtpositions.util.faker.DebtPositionFaker.buildDebtPosition; +import static it.gov.pagopa.pu.debtpositions.util.faker.DebtPositionFaker.buildDebtPositionDTO; +import static it.gov.pagopa.pu.debtpositions.util.faker.InstallmentFaker.buildInstallment; +import static it.gov.pagopa.pu.debtpositions.util.faker.InstallmentFaker.buildInstallmentNoPII; +import static it.gov.pagopa.pu.debtpositions.util.faker.PaymentOptionFaker.buildPaymentOption; +import static it.gov.pagopa.pu.debtpositions.util.faker.PaymentOptionFaker.buildPaymentOptionDTO; + import it.gov.pagopa.pu.debtpositions.dto.Installment; import it.gov.pagopa.pu.debtpositions.dto.generated.DebtPositionDTO; import it.gov.pagopa.pu.debtpositions.dto.generated.DebtPositionStatus; import it.gov.pagopa.pu.debtpositions.model.DebtPosition; import it.gov.pagopa.pu.debtpositions.model.InstallmentNoPII; import it.gov.pagopa.pu.debtpositions.model.PaymentOption; +import java.util.HashMap; +import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -14,18 +25,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.data.util.Pair; -import java.util.HashMap; -import java.util.Map; - -import static it.gov.pagopa.pu.debtpositions.util.TestUtils.checkNotNullFields; -import static it.gov.pagopa.pu.debtpositions.util.TestUtils.reflectionEqualsByName; -import static it.gov.pagopa.pu.debtpositions.util.faker.DebtPositionFaker.buildDebtPosition; -import static it.gov.pagopa.pu.debtpositions.util.faker.DebtPositionFaker.buildDebtPositionDTO; -import static it.gov.pagopa.pu.debtpositions.util.faker.InstallmentFaker.buildInstallment; -import static it.gov.pagopa.pu.debtpositions.util.faker.InstallmentFaker.buildInstallmentNoPII; -import static it.gov.pagopa.pu.debtpositions.util.faker.PaymentOptionFaker.buildPaymentOption; -import static it.gov.pagopa.pu.debtpositions.util.faker.PaymentOptionFaker.buildPaymentOptionDTO; - @ExtendWith(MockitoExtension.class) class DebtPositionMapperTest { diff --git a/src/test/java/it/gov/pagopa/pu/debtpositions/service/DebtPositionServiceImplTest.java b/src/test/java/it/gov/pagopa/pu/debtpositions/service/DebtPositionServiceImplTest.java index 111e2ea8..56c683e1 100644 --- a/src/test/java/it/gov/pagopa/pu/debtpositions/service/DebtPositionServiceImplTest.java +++ b/src/test/java/it/gov/pagopa/pu/debtpositions/service/DebtPositionServiceImplTest.java @@ -10,6 +10,7 @@ import it.gov.pagopa.pu.debtpositions.dto.Installment; import it.gov.pagopa.pu.debtpositions.dto.generated.DebtPositionDTO; +import it.gov.pagopa.pu.debtpositions.exception.custom.NotFoundException; import it.gov.pagopa.pu.debtpositions.mapper.DebtPositionMapper; import it.gov.pagopa.pu.debtpositions.model.DebtPosition; import it.gov.pagopa.pu.debtpositions.model.InstallmentNoPII; @@ -19,11 +20,13 @@ import it.gov.pagopa.pu.debtpositions.repository.InstallmentPIIRepository; import it.gov.pagopa.pu.debtpositions.repository.PaymentOptionRepository; import it.gov.pagopa.pu.debtpositions.repository.TransferRepository; +import it.gov.pagopa.pu.debtpositions.util.TestUtils; import it.gov.pagopa.pu.debtpositions.util.Utilities; import it.gov.pagopa.pu.organization.dto.generated.Organization; import java.util.List; import java.util.Map; import java.util.TreeSet; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -32,6 +35,7 @@ import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.data.util.Pair; +import uk.co.jemos.podam.api.PodamFactory; @ExtendWith(MockitoExtension.class) class DebtPositionServiceImplTest { @@ -53,6 +57,8 @@ class DebtPositionServiceImplTest { private DebtPositionServiceImpl debtPositionService; + private final PodamFactory podamFactory = TestUtils.getPodamFactory(); + @BeforeEach void setUp() { debtPositionService = new DebtPositionServiceImpl( @@ -184,5 +190,35 @@ void givenValidDebtPositionDTONoOrg_WhenSaveDebtPosition_ThenSaveAllEntities() { Mockito.verify(transferRepository, Mockito.times(2)).save(transfer); } } + + @Test + void givenExistingDebtPositionWhenGetDebtPositionThenOk(){ + Long debtPositionId = 1L; + DebtPositionDTO expectedResult = podamFactory.manufacturePojo(DebtPositionDTO.class); + DebtPosition debtPosition = podamFactory.manufacturePojo(DebtPosition.class); + + Mockito.when(debtPositionRepository.findOneWithAllDataByDebtPositionId(debtPositionId)).thenReturn(debtPosition); + Mockito.when(debtPositionMapper.mapToDto(debtPosition)).thenReturn(expectedResult); + + DebtPositionDTO result = debtPositionService.getDebtPosition( + debtPositionId); + + Assertions.assertNotNull(result); + Assertions.assertSame(expectedResult,result); + Mockito.verifyNoMoreInteractions(debtPositionRepository,debtPositionMapper); + } + + @Test + void givenNonExistingDebtPositionDetailWhenGetDebtPositionThenThrowNotFoundException(){ + Long debtPositionId = 1L; + + Mockito.when(debtPositionRepository.findOneWithAllDataByDebtPositionId(debtPositionId)).thenReturn(null); + + Assertions.assertThrows(NotFoundException.class, ()->debtPositionService.getDebtPosition( + debtPositionId)); + + Mockito.verifyNoMoreInteractions(debtPositionRepository); + Mockito.verifyNoInteractions(debtPositionMapper); + } }