Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception handling #12

Merged
merged 10 commits into from
Aug 10, 2023
110 changes: 63 additions & 47 deletions api-spec/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ components:
maximum: 600
exclusiveMaximum: true
example: 200
PmSearchTransactionRequestFiscalCode:
SearchTransactionRequestFiscalCode:
type: object
description: Search transaction by user fiscal code
properties:
Expand All @@ -230,7 +230,7 @@ components:
example:
type: "USER_FISCAL_CODE"
userFiscalCode: "MRGHRN97L02C469W"
PmSearchTransactionRequestEmail:
SearchTransactionRequestEmail:
type: object
description: Search transaction by user fiscal code
properties:
Expand Down Expand Up @@ -258,7 +258,7 @@ components:
required:
- transactions
- page
EcommerceSearchTransactionRequestRptId:
SearchTransactionRequestRptId:
type: object
description: Search transaction by user fiscal code
properties:
Expand All @@ -273,7 +273,7 @@ components:
example:
type: "RPT_ID"
rptId: "77777777777302011111111111111"
EcommerceSearchTransactionRequestPaymentToken:
SearchTransactionRequestPaymentToken:
type: object
description: Search transaction by payment token
properties:
Expand All @@ -287,7 +287,7 @@ components:
example:
type: "PAYMENT_TOKEN"
paymentToken: "paymentToken"
EcommerceSearchTransactionRequestTransactionId:
SearchTransactionRequestTransactionId:
type: object
description: Search transaction by transaction id
properties:
Expand Down Expand Up @@ -327,7 +327,7 @@ components:
- product
UserInfo:
type: object
description: TransactionResponse
description: User informations
properties:
userFiscalCode:
type: string
Expand All @@ -345,77 +345,93 @@ components:
username:
type: string
maxLength: 128
status:
authenticationType:
type: string
example:
userFiscalCode: "user_fiscal_code"
notificationEmail: "[email protected]"
surname: "Surname"
name: "Name"
username: "username"
status: "TO BE DEFINED"
authenticationType: "auth type"

TransactionInfo:
type: object
description: TransactionResponse
description: Transaction info
properties:
creationDate:
type: string
format: date-time
description: transaction creation date
status:
type: string
statusDetails:
type: string
amount:
$ref: '#/components/schemas/AmountEuroCents'
fee:
$ref: '#/components/schemas/AmountEuroCents'
grandTotal:
$ref: '#/components/schemas/AmountEuroCents'
rrn:
type: string
authotizationCode:
type: string
paymentMethodName:
type: string
brand:
type: string
example:
creationDate: "2023-08-02T14:42:54.047"
status: "TO BE DEFINED"
status: "status"
statusDetails: "status detail"
amount: 100
fee: 10
grandTotal: 110
rrn: "rrn"
authorizationCode: "auth code"
paymentMethodName: "payment method name"
brand: "brand"
PaymentInfo:
type: object
description: TransactionResponse
description: Payment info
properties:
amount:
$ref: '#/components/schemas/AmountEuroCents'
subject:
type: string
origin:
type: string
example:
amount: 100
subject: "Causale pagamento"
origin: "CHECKOUT"
PaymentDetailInfo:
type: object
description: TransactionResponse
description: Payment details
properties:
iuv:
type: string
minLength: 18
maxLength: 18
paymentContextCode:
rptIds:
type: array
items:
type: string
idTransaction:
type: string
paymentToken:
type: string
creditorInstitution:
type: string
amount:
$ref: '#/components/schemas/AmountEuroCents'
paFiscalCode:
type: string
example:
iuv: "302001069073736640"
paymentContextCode: "paymentContextCode"
rptId: [ "rptId1","rptId2" ]
idTransaction: "paymentContextCode"
paymentToken: "payment token"
creditorInstitution: "66666666666"
amount: 99999999
paFiscalCode: "77777777777"
PspInfo:
type: object
description: TransactionResponse
description: PSP info
properties:
pspId:
type: string
Expand Down Expand Up @@ -456,39 +472,39 @@ components:
PmSearchTransactionRequest:
type: object
oneOf:
- $ref: '#/components/schemas/PmSearchTransactionRequestFiscalCode'
- $ref: '#/components/schemas/PmSearchTransactionRequestEmail'
- $ref: '#/components/schemas/SearchTransactionRequestFiscalCode'
- $ref: '#/components/schemas/SearchTransactionRequestEmail'
discriminator:
propertyName: type
mapping:
USER_FISCAL_CODE: "#/components/schemas/PmSearchTransactionRequestFiscalCode"
USER_EMAIL: "#/components/schemas/PmSearchTransactionRequestEmail"
USER_FISCAL_CODE: "#/components/schemas/SearchTransactionRequestFiscalCode"
USER_EMAIL: "#/components/schemas/SearchTransactionRequestEmail"
EcommerceSearchTransactionRequest:
type: object
oneOf:
- $ref: '#/components/schemas/EcommerceSearchTransactionRequestRptId'
- $ref: '#/components/schemas/EcommerceSearchTransactionRequestPaymentToken'
- $ref: '#/components/schemas/EcommerceSearchTransactionRequestTransactionId'
- $ref: '#/components/schemas/SearchTransactionRequestRptId'
- $ref: '#/components/schemas/SearchTransactionRequestPaymentToken'
- $ref: '#/components/schemas/SearchTransactionRequestTransactionId'
discriminator:
propertyName: type
mapping:
RPT_ID: "#/components/schemas/EcommerceSearchTransactionRequestRptId"
PAYMENT_TOKEN: "#/components/schemas/EcommerceSearchTransactionRequestPaymentToken"
TRANSACTION_ID: "#/components/schemas/EcommerceSearchTransactionRequestTransactionId"
RPT_ID: "#/components/schemas/SearchTransactionRequestRptId"
PAYMENT_TOKEN: "#/components/schemas/SearchTransactionRequestPaymentToken"
TRANSACTION_ID: "#/components/schemas/SearchTransactionRequestTransactionId"
requestBodies:
PmSearchTransactionRequest:
required: true
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/PmSearchTransactionRequestFiscalCode'
- $ref: '#/components/schemas/PmSearchTransactionRequestEmail'
- $ref: '#/components/schemas/SearchTransactionRequestFiscalCode'
- $ref: '#/components/schemas/SearchTransactionRequestEmail'
discriminator:
propertyName: type
mapping:
USER_FISCAL_CODE: "#/components/schemas/PmSearchTransactionRequestFiscalCode"
USER_EMAIL: "#/components/schemas/PmSearchTransactionRequestEmail"
USER_FISCAL_CODE: "#/components/schemas/SearchTransactionRequestFiscalCode"
USER_EMAIL: "#/components/schemas/SearchTransactionRequestEmail"
examples:
search by user fiscal code:
value:
Expand All @@ -510,15 +526,15 @@ components:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/EcommerceSearchTransactionRequestRptId'
- $ref: '#/components/schemas/EcommerceSearchTransactionRequestPaymentToken'
- $ref: '#/components/schemas/EcommerceSearchTransactionRequestTransactionId'
- $ref: '#/components/schemas/SearchTransactionRequestRptId'
- $ref: '#/components/schemas/SearchTransactionRequestPaymentToken'
- $ref: '#/components/schemas/SearchTransactionRequestTransactionId'
discriminator:
propertyName: type
mapping:
RPT_ID: "#/components/schemas/EcommerceSearchTransactionRequestRptId"
PAYMENT_TOKEN: "#/components/schemas/EcommerceSearchTransactionRequestPaymentToken"
TRANSACTION_ID: "#/components/schemas/EcommerceSearchTransactionRequestTransactionId"
RPT_ID: "#/components/schemas/SearchTransactionRequestRptId"
PAYMENT_TOKEN: "#/components/schemas/SearchTransactionRequestPaymentToken"
TRANSACTION_ID: "#/components/schemas/SearchTransactionRequestTransactionId"
examples:
search by rpt id:
value:
Expand Down Expand Up @@ -549,11 +565,11 @@ components:
discriminator:
propertyName: type
mapping:
USER_FISCAL_CODE: "#/components/schemas/PmSearchTransactionRequestFiscalCode"
USER_EMAIL: "#/components/schemas/PmSearchTransactionRequestEmail"
RPT_ID: "#/components/schemas/EcommerceSearchTransactionRequestRptId"
PAYMENT_TOKEN: "#/components/schemas/EcommerceSearchTransactionRequestPaymentToken"
TRANSACTION_ID: "#/components/schemas/EcommerceSearchTransactionRequestTransactionId"
USER_FISCAL_CODE: "#/components/schemas/SearchTransactionRequestFiscalCode"
USER_EMAIL: "#/components/schemas/SearchTransactionRequestEmail"
RPT_ID: "#/components/schemas/SearchTransactionRequestRptId"
PAYMENT_TOKEN: "#/components/schemas/SearchTransactionRequestPaymentToken"
TRANSACTION_ID: "#/components/schemas/SearchTransactionRequestTransactionId"
examples:
search by user fiscal code:
value:
Expand Down
7 changes: 6 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ dependencies {
testImplementation("org.mockito.kotlin:mockito-kotlin:4.0.0")
testImplementation("com.squareup.okhttp3:mockwebserver:$mockWebServerVersion")
testImplementation("com.squareup.okhttp3:okhttp:$mockWebServerVersion")
testImplementation("it.pagopa:pagopa-ecommerce-commons:$ecommerceCommonsVersion:tests")
}

configurations {
Expand Down Expand Up @@ -117,7 +118,10 @@ tasks.create("applySemanticVersionPlugin") {
apply(plugin = "com.dipien.semantic-version")
}

tasks.withType(JavaCompile::class.java).configureEach { options.encoding = "UTF-8" }
tasks.withType(JavaCompile::class.java).configureEach {
options.encoding = "UTF-8"
options.compilerArgs.add("--enable-preview")
}

tasks.withType(Javadoc::class.java).configureEach { options.encoding = "UTF-8" }

Expand Down Expand Up @@ -191,6 +195,7 @@ tasks.named<Jar>("jar") { enabled = false }
tasks.test {
useJUnitPlatform()
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
jvmArgs(listOf("--enable-preview"))
}

tasks.jacocoTestReport {
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pluginManagement { repositories { gradlePluginPortal() } }

rootProject.name = "pagopa-ecommerce-helpdesk-service"
rootProject.name = "pagopa-ecommerce-helpdesk-service"
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ class EcommerceController(@Autowired val ecommerceService: EcommerceService) : E
exchange: ServerWebExchange
): Mono<ResponseEntity<SearchTransactionResponseDto>> {
logger.info("[HelpDesk controller] ecommerceSearchTransaction")
return ecommerceService
.searchTransaction(pageNumber, pageSize, ecommerceSearchTransactionRequestDto)
return ecommerceSearchTransactionRequestDto
.flatMap {
ecommerceService.searchTransaction(
pageNumber = pageNumber,
pageSize = pageSize,
ecommerceSearchTransactionRequestDto = it
)
}
.map { ResponseEntity.ok(it) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package it.pagopa.ecommerce.helpdesk.controllers
import it.pagopa.ecommerce.helpdesk.services.EcommerceService
import it.pagopa.ecommerce.helpdesk.services.PmService
import it.pagopa.generated.ecommerce.helpdesk.api.HelpdeskApi
import it.pagopa.generated.ecommerce.helpdesk.model.*
import it.pagopa.generated.ecommerce.helpdesk.model.EcommerceSearchTransactionRequestDto
import it.pagopa.generated.ecommerce.helpdesk.model.HelpDeskSearchTransactionRequestDto
import it.pagopa.generated.ecommerce.helpdesk.model.PmSearchTransactionRequestDto
import it.pagopa.generated.ecommerce.helpdesk.model.SearchTransactionResponseDto
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.RestController
Expand All @@ -29,15 +32,15 @@ class HelpdeskController(
.searchTransaction(
pageNumber = pageNumber,
pageSize = pageSize,
ecommerceSearchTransactionRequestDto = Mono.just(it)
ecommerceSearchTransactionRequestDto = it
)
.map { response -> ResponseEntity.ok(response) }
is PmSearchTransactionRequestDto ->
pmService
.searchTransaction(
pageNumber = pageNumber,
pageSize = pageSize,
pmSearchTransactionRequestDto = Mono.just(it)
pmSearchTransactionRequestDto = it
)
.map { response -> ResponseEntity.ok(response) }
else -> Mono.error(RuntimeException("Unknown search criteria"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ class PmController(@Autowired val pmService: PmService) : PmApi {
exchange: ServerWebExchange
): Mono<ResponseEntity<SearchTransactionResponseDto>> {
logger.info("[HelpDesk controller] pmSearchTransaction")
return pmService
.searchTransaction(pageSize, pageNumber, pmSearchTransactionRequestDto)
return pmSearchTransactionRequestDto
.flatMap {
pmService.searchTransaction(
pageSize = pageSize,
pageNumber = pageNumber,
pmSearchTransactionRequestDto = it
)
}
.map { ResponseEntity.ok(it) }
}
}
Loading
Loading