refactor/added helper_info to createVRPConsentRequest endpoint

This commit is contained in:
Hongwei 2025-02-26 14:30:16 +01:00
parent e88babc741
commit eaacc5140f
5 changed files with 46 additions and 17 deletions

View File

@ -5230,7 +5230,7 @@ object SwaggerDefinitionsJSON {
bank_id = bankIdExample.value,
account_id = accountIdExample.value,
view_id = viewIdExample.value,
helper_info = helperInfoJson
helper_info = Some(helperInfoJson)
)
val consentJsonV500 = ConsentJsonV500(

View File

@ -739,7 +739,7 @@ trait APIMethods500 {
nameOf(getConsentByConsentRequestId),
"GET",
"/consumer/consent-requests/CONSENT_REQUEST_ID/consents",
"Get Consent By Consent Request Id",
"Get Consent By Consent Request Id via Consumner",
s"""
|
|This endpoint gets the Consent By consent request id.
@ -762,16 +762,32 @@ trait APIMethods500 {
consent <- Future { Consents.consentProvider.vend.getConsentByConsentRequestId(consentRequestId)} map {
unboxFullOrFail(_, callContext, ConsentRequestNotFound)
}
_ <- Helper.booleanToFuture(failMsg = ConsentNotFound, cc = cc.callContext) {
consent.mUserId == cc.userId
_ <- Helper.booleanToFuture(failMsg = ConsentNotFound, failCode = 404, cc = cc.callContext) {
consent.mConsumerId.get == cc.consumer.map(_.consumerId.get).getOrElse("None")
}
(bankId, accountId, viewId, helperInfo) <- NewStyle.function.tryons(failMsg = Oauth2BadJWTException, 400, callContext) {
val jsonWebTokenAsJValue = JwtUtil.getSignedPayloadAsJson(consent.jsonWebToken).map(json.parse(_).extract[ConsentJWT])
val bankId = BankId(jsonWebTokenAsJValue.head.views.head.bank_id)
val accountId = AccountId(jsonWebTokenAsJValue.head.views.head.account_id)
val viewId = ViewId(jsonWebTokenAsJValue.head.views.head.view_id)
val helperInfoFromJwtToken = jsonWebTokenAsJValue.head.views.head.helper_info
val viewCanGetCounterparty = Views.views.vend.customView(viewId, BankIdAccountId(bankId, accountId)).map(_.canGetCounterparty)
val helperInfo = if(viewCanGetCounterparty==Full(true)) helperInfoFromJwtToken else None
(bankId, accountId, viewId, helperInfo)
}
} yield {
(
ConsentJsonV500(
consent.consentId,
consent.jsonWebToken,
consent.status,
Some(consent.consentRequestId)
consent.consentId,
consent.jsonWebToken,
consent.status,
Some(consent.consentRequestId),
Some(ConsentAccountAccessJson(
bank_id = bankId.value,
account_id = accountId.value,
view_id = viewId.value,
helper_info = helperInfo
))
),
HttpCode.`200`(cc)
)
@ -1256,7 +1272,14 @@ trait APIMethods500 {
consentJWT,
mappedConsent.status,
Some(mappedConsent.consentRequestId),
if (isVRPConsentRequest) Some(ConsentAccountAccessJson(bankId.value, accountId.value, viewId.value, HelperInfoJson(List(counterpartyId.value)))) else None
if (isVRPConsentRequest) Some(
ConsentAccountAccessJson(
bankId.value,
accountId.value,
viewId.value,
Some(HelperInfoJson(List(counterpartyId.value))))
)
else None
), HttpCode.`201`(callContext))
}
}

View File

@ -239,11 +239,17 @@ case class ConsentAccountAccessJson(
bank_id:String,
account_id:String,
view_id:String,
helper_info: HelperInfoJson
helper_info: Option[HelperInfoJson]
)
case class ConsentJsonV500(consent_id: String, jwt: String, status: String, consent_request_id: Option[String], account_access:Option[ConsentAccountAccessJson] = None)
case class ConsentJsonV500(
consent_id: String,
jwt: String,
status: String,
consent_request_id: Option[String],
account_access:Option[ConsentAccountAccessJson] = None
)
case class CreatePhysicalCardJsonV500(
card_number: String,

View File

@ -1675,7 +1675,7 @@ trait APIMethods510 {
nameOf(getConsentByConsentId),
"GET",
"/user/current/consents/CONSENT_ID",
"Get Consent By Consent Id",
"Get Consent By Consent Id via User",
s"""
|
|This endpoint gets the Consent By consent id.
@ -1713,7 +1713,7 @@ trait APIMethods510 {
nameOf(getConsentByConsentIdViaConsumer),
"GET",
"/consumer/current/consents/CONSENT_ID",
"Get Consent By Consent Id",
"Get Consent By Consent Id via Consumer",
s"""
|
|This endpoint gets the Consent By consent id.

View File

@ -215,7 +215,7 @@ class VRPConsentRequestTest extends V510ServerSetup with PropsReset{
val consentRequestBankId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.bank_id
val consentRequestAccountId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.account_id
val consentRequestViewId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.view_id
val consentRequestCounterpartyId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.helper_info.counterparty_ids
val consentRequestCounterpartyId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.helper_info.head.counterparty_ids
val createTransReqRequest = (v4_0_0_Request / "banks" / consentRequestBankId / "accounts" / consentRequestAccountId /
consentRequestViewId / "transaction-request-types" / "COUNTERPARTY" / "transaction-requests").POST
@ -326,7 +326,7 @@ class VRPConsentRequestTest extends V510ServerSetup with PropsReset{
val consentRequestBankId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.bank_id
val consentRequestAccountId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.account_id
val consentRequestViewId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.view_id
val consentRequestCounterpartyId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.helper_info.counterparty_ids
val consentRequestCounterpartyId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.helper_info.head.counterparty_ids
val createTransReqRequest = (v4_0_0_Request / "banks" / consentRequestBankId / "accounts" / consentRequestAccountId /
consentRequestViewId / "transaction-request-types" / "COUNTERPARTY" / "transaction-requests").POST
@ -421,7 +421,7 @@ class VRPConsentRequestTest extends V510ServerSetup with PropsReset{
val consentRequestBankId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.bank_id
val consentRequestAccountId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.account_id
val consentRequestViewId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.view_id
val consentRequestCounterpartyId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.helper_info.counterparty_ids
val consentRequestCounterpartyId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.helper_info.head.counterparty_ids
val createTransReqRequest = (v4_0_0_Request / "banks" / consentRequestBankId / "accounts" / consentRequestAccountId /
consentRequestViewId / "transaction-request-types" / "COUNTERPARTY" / "transaction-requests").POST
@ -509,7 +509,7 @@ class VRPConsentRequestTest extends V510ServerSetup with PropsReset{
val consentRequestBankId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.bank_id
val consentRequestAccountId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.account_id
val consentRequestViewId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.view_id
val consentRequestCounterpartyId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.helper_info.counterparty_ids
val consentRequestCounterpartyId = createConsentByRequestResponse.body.extract[ConsentJsonV500].account_access.get.helper_info.head.counterparty_ids
val createTransReqRequest = (v4_0_0_Request / "banks" / consentRequestBankId / "accounts" / consentRequestAccountId /
consentRequestViewId / "transaction-request-types" / "COUNTERPARTY" / "transaction-requests").POST