Skip to content

Commit

Permalink
[PRDP-358] feat: Rework Transaction Detail API (#37)
Browse files Browse the repository at this point in the history
* [PRDP-358] Added entities' models and moved classes

* [PRDP-358] Added collections repo interfaces and container name envs

* [PRDP-356] updated openapi definition as defined in documentation

* [PRDP-358] Added get biz-events-view-cart filtered by fiscal code

* [PRDP-358] Reworked transaction service getTransactionDetails and added errors

* [PRDP-358] Updated partially tests

* [PRDP-358] Completed unit test for transaction details

* [PRDP-358] Changed entity annotation

* [PRDP-358] Added id autogeneration to view entities

* [PRDP-358] Changed fiscalCode to taxCode

* [PRDP-358] Fix

---------

Co-authored-by: giomella <gioele.mella@emeal.nttdata.com>
  • Loading branch information
svariant and giomella authored Feb 1, 2024
1 parent fd545b7 commit 7a2fb76
Show file tree
Hide file tree
Showing 34 changed files with 580 additions and 973 deletions.
3 changes: 3 additions & 0 deletions helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ microservice-chart:
COSMOS_DB_URI: 'https://pagopa-d-weu-bizevents-ds-cosmos-account.documents.azure.com:443/'
COSMOS_DB_NAME: 'db'
COSMOS_DB_CONTAINER_NAME: 'biz-events'
COSMOS_DB_VIEW_USER_CONTAINER_NAME: 'biz-events-view-user'
COSMOS_DB_VIEW_GENERAL_CONTAINER_NAME: 'biz-events-view-general'
COSMOS_DB_VIEW_CART_CONTAINER_NAME: 'biz-events-view-cart'
COSMOS_QUERY_METRICS: 'false'
OTEL_SERVICE_NAME: "pagopabizeventsservice"
OTEL_RESOURCE_ATTRIBUTES: "service.name=pagopareceiptspdfserviceotl,deployment.environment=dev"
Expand Down
3 changes: 3 additions & 0 deletions helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ microservice-chart:
COSMOS_DB_URI: 'https://pagopa-p-weu-bizevents-ds-cosmos-account.documents.azure.com:443/'
COSMOS_DB_NAME: 'db'
COSMOS_DB_CONTAINER_NAME: 'biz-events'
COSMOS_DB_VIEW_USER_CONTAINER_NAME: 'biz-events-view-user'
COSMOS_DB_VIEW_GENERAL_CONTAINER_NAME: 'biz-events-view-general'
COSMOS_DB_VIEW_CART_CONTAINER_NAME: 'biz-events-view-cart'
COSMOS_QUERY_METRICS: 'false'
OTEL_SERVICE_NAME: "pagopabizeventsservice"
OTEL_RESOURCE_ATTRIBUTES: "service.name=pagopareceiptspdfserviceotl,deployment.environment=prod"
Expand Down
3 changes: 3 additions & 0 deletions helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ microservice-chart:
COSMOS_DB_URI: 'https://pagopa-u-weu-bizevents-ds-cosmos-account.documents.azure.com:443/'
COSMOS_DB_NAME: 'db'
COSMOS_DB_CONTAINER_NAME: 'biz-events'
COSMOS_DB_VIEW_USER_CONTAINER_NAME: 'biz-events-view-user'
COSMOS_DB_VIEW_GENERAL_CONTAINER_NAME: 'biz-events-view-general'
COSMOS_DB_VIEW_CART_CONTAINER_NAME: 'biz-events-view-cart'
COSMOS_QUERY_METRICS: 'false'
OTEL_SERVICE_NAME: "pagopabizeventsservice"
OTEL_RESOURCE_ATTRIBUTES: "service.name=pagopareceiptspdfserviceotl,deployment.environment=uat"
Expand Down
3 changes: 3 additions & 0 deletions integration-test/src/config/.env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ BIZ_EVENTS_SERVICE_HOST=https://api.dev.platform.pagopa.it/bizevents/service/v1/
COSMOS_DB_URI=https://pagopa-d-weu-bizevents-ds-cosmos-account.documents.azure.com:443/
COSMOS_DB_NAME=db
COSMOS_DB_CONTAINER_NAME=biz-events
COSMOS_DB_VIEW_USER_CONTAINER_NAME: 'biz-events-view-user'
COSMOS_DB_VIEW_GENERAL_CONTAINER_NAME: 'biz-events-view-general'
COSMOS_DB_VIEW_CART_CONTAINER_NAME: 'biz-events-view-cart'
3 changes: 3 additions & 0 deletions integration-test/src/config/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ BIZ_EVENTS_SERVICE_HOST=http://localhost:8080/
COSMOS_DB_URI=https://pagopa-d-weu-bizevents-ds-cosmos-account.documents.azure.com:443/
COSMOS_DB_NAME=db
COSMOS_DB_CONTAINER_NAME=biz-events
COSMOS_DB_VIEW_USER_CONTAINER_NAME: 'biz-events-view-user'
COSMOS_DB_VIEW_GENERAL_CONTAINER_NAME: 'biz-events-view-general'
COSMOS_DB_VIEW_CART_CONTAINER_NAME: 'biz-events-view-cart'
COSMOS_DB_PRIMARY_KEY=<AccountPrimaryKey>
3 changes: 3 additions & 0 deletions integration-test/src/config/.env.uat
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ BIZ_EVENTS_SERVICE_HOST=https://api.uat.platform.pagopa.it/bizevents/service/v1/
COSMOS_DB_URI=https://pagopa-u-weu-bizevents-ds-cosmos-account.documents.azure.com:443/
COSMOS_DB_NAME=db
COSMOS_DB_CONTAINER_NAME=biz-events
COSMOS_DB_VIEW_USER_CONTAINER_NAME: 'biz-events-view-user'
COSMOS_DB_VIEW_GENERAL_CONTAINER_NAME: 'biz-events-view-general'
COSMOS_DB_VIEW_CART_CONTAINER_NAME: 'biz-events-view-cart'
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.constraints.NotBlank;
import java.util.List;
Expand Down Expand Up @@ -52,7 +51,7 @@ public interface ITransactionController {
ResponseEntity<List<TransactionListItem>> getTransactionList(
@RequestHeader(name = "x-fiscal-code") String fiscalCode,
@RequestHeader(name = "x-continuation-token", required = false) String continuationToken,
@RequestParam(name = "size", required = false, defaultValue = "5") Integer size
@RequestHeader(name = "x-page-size", required = false, defaultValue = "5") Integer size
);

@Operation(summary = "Retrieve the transaction details given its id.", security = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package it.gov.pagopa.bizeventsservice.entity.view;

import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.GeneratedValue;
import com.azure.spring.data.cosmos.core.mapping.PartitionKey;
import lombok.*;

/**
* Entity model for biz-events-view-cart
*/
@Container(containerName = "${azure.cosmos.biz-events-view-cart-container-name}", autoCreateContainer = false, ru="1000")
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Getter
@Setter
public class BizEventsViewCart {
@GeneratedValue
private String id;
@PartitionKey
private String transactionId;
private String eventId;
private String subject;
private long amount;
private UserDetail payee;
private UserDetail debtor;
private String refNumberValue;
private String refNumberType;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package it.gov.pagopa.bizeventsservice.entity.view;

import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.GeneratedValue;
import com.azure.spring.data.cosmos.core.mapping.PartitionKey;
import it.gov.pagopa.bizeventsservice.entity.view.enumeration.OriginType;
import it.gov.pagopa.bizeventsservice.entity.view.enumeration.PaymentMethodType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* Entity model for biz-events-view-general
*/
@Container(containerName = "${azure.cosmos.biz-events-view-general-container-name}", autoCreateContainer = false, ru="1000")
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter
public class BizEventsViewGeneral {
@GeneratedValue
private String id;
@PartitionKey
private String transactionId;
private String authCode;
private PaymentMethodType paymentMethod;
private String rrn;
private String pspName;
private String transactionDate;
private WalletInfo walletInfo;
private UserDetail payer;
private boolean isCart;
private String fee;
private OriginType origin;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package it.gov.pagopa.bizeventsservice.entity.view;

import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.GeneratedValue;
import com.azure.spring.data.cosmos.core.mapping.PartitionKey;
import lombok.*;

/**
* Entity model for biz-events-view-user
*/
@Container(containerName = "${azure.cosmos.biz-events-view-user-container-name}", autoCreateContainer = false, ru="1000")
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Builder
public class BizEventsViewUser {
@GeneratedValue
private String id;
@PartitionKey
private String taxCode;
private String transactionId;
private String transactionDate;
private boolean hidden;
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package it.gov.pagopa.bizeventsservice.model.response.transaction;
package it.gov.pagopa.bizeventsservice.entity.view;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserDetail {
public class UserDetail implements Serializable {

private String name;
private String taxCode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package it.gov.pagopa.bizeventsservice.model.response.transaction;
package it.gov.pagopa.bizeventsservice.entity.view;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class WalletInfo {
public class WalletInfo implements Serializable {

private String accountHolder;
private String brand;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package it.gov.pagopa.bizeventsservice.model.response.transaction.enumeration;
package it.gov.pagopa.bizeventsservice.entity.view.enumeration;

import java.util.Arrays;

/**
* Enum for transaction origin
*/
public enum OriginType {
INTERNAL, PM, NDP001PROD , NDP002PROD, NDP003PROD, UNKNOWN;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package it.gov.pagopa.bizeventsservice.model.response.transaction.enumeration;
package it.gov.pagopa.bizeventsservice.entity.view.enumeration;

import java.util.Arrays;

/**
* Enum for transaction payment methods
*/
public enum PaymentMethodType {

BBT, BP, AD, CP, PO, OBEP, JIF, MYBK, PPAL, UNKNOWN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public enum AppError {

INVALID_FISCAL_CODE(HttpStatus.BAD_REQUEST, INVALID_DATA, "Provided Fiscal Code %s is invalid"),

VIEW_GENERAL_NOT_FOUND_WITH_TRANSACTION_ID(HttpStatus.NOT_FOUND, VIEW_GENERAL_NOT_FOUND, "Not found a biz-events-view-general with id %s"),
VIEW_CART_NOT_FOUND_WITH_TRANSACTION_ID_FOR_USER(HttpStatus.NOT_FOUND, VIEW_CART_NOT_FOUND, "Not found a biz-events-view-cart with id %s for the given fiscal code"),

ERROR_MAPPING_BIZ_EVENT_TO_TRANSACTION_DETAIL(HttpStatus.INTERNAL_SERVER_ERROR, INVALID_DATA, "Error mapping bizEvent data to transaction details, missing property %s for bizEvent with id %s"),
INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "Internal Server Error", "Something was wrong");

Expand Down
Loading

0 comments on commit 7a2fb76

Please sign in to comment.