feature/Add system views ReadBalancesBerlinGroup and ReadTransactionsBerlinGroup

This commit is contained in:
Marko Milić 2021-03-03 19:40:09 +01:00
parent 3783f5d513
commit 279ab18f81
5 changed files with 18 additions and 10 deletions

View File

@ -660,7 +660,9 @@ class Boot extends MdcLoggable {
SYSTEM_READ_ACCOUNTS_BASIC_VIEW_ID, SYSTEM_READ_ACCOUNTS_DETAIL_VIEW_ID,
SYSTEM_READ_BALANCES_VIEW_ID, SYSTEM_READ_TRANSACTIONS_BASIC_VIEW_ID,
SYSTEM_READ_TRANSACTIONS_DEBITS_VIEW_ID, SYSTEM_READ_TRANSACTIONS_DETAIL_VIEW_ID,
SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID
SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID,
SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID,
SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID
)
for {
systemView <- viewSetUKOpenBanking

View File

@ -2,8 +2,8 @@ package code.api.builder.AccountInformationServiceAISApi
import java.text.SimpleDateFormat
import code.api.APIFailureNewStyle
import code.api.Constant.SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID
import code.api.{APIFailureNewStyle}
import code.api.Constant.{SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID, SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID, SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID}
import code.api.berlin.group.v1_3.JSONFactory_BERLIN_GROUP_1_3.{PostConsentResponseJson, _}
import code.api.berlin.group.v1_3.{JSONFactory_BERLIN_GROUP_1_3, JvalueCaseClass, OBP_BERLIN_GROUP_1_3}
import code.api.util.APIUtil.{passesPsd2Aisp, _}
@ -353,7 +353,7 @@ The account-id is constant at least throughout the lifecycle of a given consent.
(Full(u), callContext) <- authenticatedAccess(cc)
_ <- passesPsd2Aisp(callContext)
(account: BankAccount, callContext) <- NewStyle.function.getBankAccountByAccountId(accountId, callContext)
_ <- checkAccountAccess(ViewId(SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID), u, account)
_ <- checkAccountAccess(ViewId(SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID), u, account)
} yield {
(JSONFactory_BERLIN_GROUP_1_3.createAccountBalanceJSON(account), HttpCode.`200`(callContext))
}
@ -483,7 +483,7 @@ This account-id then can be retrieved by the
(Full(u), callContext) <- authenticatedAccess(cc)
_ <- passesPsd2Aisp(callContext)
(account: BankAccount, callContext) <- NewStyle.function.getBankAccountByAccountId(AccountId(accountId), callContext)
_ <- checkAccountAccess(ViewId(SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID), u, account)
_ <- checkAccountAccess(ViewId(SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID), u, account)
} yield {
(JSONFactory_BERLIN_GROUP_1_3.createCardAccountBalanceJSON(account), HttpCode.`200`(callContext))
}
@ -809,7 +809,7 @@ of the "Read Transaction List" call within the _links subfield.
for {
(Full(user), callContext) <- authenticatedAccess(cc)
(account: BankAccount, callContext) <- NewStyle.function.getBankAccountByAccountId(AccountId(accountId), callContext)
viewId = ViewId(SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID)
viewId = ViewId(SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID)
bankIdAccountId = BankIdAccountId(account.bankId, account.accountId)
view <- NewStyle.function.checkAccountAccessAndGetView(viewId, bankIdAccountId, Full(user), callContext)
(moderatedTransaction, callContext) <- account.moderatedTransactionFuture(TransactionId(transactionId), view, Some(user), callContext) map {
@ -903,7 +903,7 @@ The ASPSP might add balance information, if transaction lists without balances a
_ <- passesPsd2Aisp(callContext)
(bankAccount: BankAccount, callContext) <- NewStyle.function.getBankAccountByAccountId(accountId, callContext)
(bank, callContext) <- NewStyle.function.getBank(bankAccount.bankId, callContext)
viewId = ViewId(SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID)
viewId = ViewId(SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID)
bankIdAccountId = BankIdAccountId(bankAccount.bankId, bankAccount.accountId)
view <- NewStyle.function.checkAccountAccessAndGetView(viewId, bankIdAccountId, Full(u), callContext)
params <- Future { createQueriesByHttpParams(callContext.get.requestHeaders)} map {

View File

@ -33,6 +33,8 @@ object Constant extends MdcLoggable {
final val SYSTEM_READ_TRANSACTIONS_DETAIL_VIEW_ID = "ReadTransactionsDetail"
// Berlin Group
final val SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID = "ReadAccountsBerlinGroup"
final val SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID = "ReadBalancesBerlinGroup"
final val SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID = "ReadTransactionsBerlinGroup"
//These are the default incoming and outgoing account ids. we will create both during the boot.scala.
final val INCOMING_ACCOUNT_ID= "OBP_DEFAULT_INCOMING_ACCOUNT_ID"

View File

@ -1,5 +1,6 @@
package code.api.berlin.group.v1_3
import code.api.Constant
import code.api.Constant.SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID
import code.api.berlin.group.v1_3.JSONFactory_BERLIN_GROUP_1_3._
import code.api.builder.AccountInformationServiceAISApi.APIMethods_AccountInformationServiceAISApi
@ -110,7 +111,7 @@ class AccountInformationServiceAISApiTest extends BerlinGroupServerSetupV1_3 wit
testAccountId1.value,
resourceUser1.userId,
user1,
PostViewJsonV400(view_id = SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID, is_system = true)
PostViewJsonV400(view_id = Constant.SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID, is_system = true)
)
val requestGet = (V1_3_BG / "accounts" / testAccountId1.value / "balances").GET <@ (user1)
@ -139,7 +140,7 @@ class AccountInformationServiceAISApiTest extends BerlinGroupServerSetupV1_3 wit
testAccountId.value,
resourceUser1.userId,
user1,
PostViewJsonV400(view_id = SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID, is_system = true)
PostViewJsonV400(view_id = Constant.SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID, is_system = true)
)
val requestGet = (V1_3_BG / "accounts" /testAccountId1.value/ "transactions").GET <@ (user1)
val response: APIResponse = makeGetRequest(requestGet)
@ -168,7 +169,7 @@ class AccountInformationServiceAISApiTest extends BerlinGroupServerSetupV1_3 wit
testAccountId.value,
resourceUser1.userId,
user1,
PostViewJsonV400(view_id = SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID, is_system = true)
PostViewJsonV400(view_id = Constant.SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID, is_system = true)
)
val requestGet = (V1_3_BG / "accounts" / testAccountId.value / "transactions").GET <@ (user1)
val response: APIResponse = makeGetRequest(requestGet)

View File

@ -1,5 +1,6 @@
package code.api.berlin.group.v1_3
import code.api.Constant
import code.api.Constant.SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID
import code.api.util.APIUtil.OAuth._
import code.api.util.APIUtil.OAuth.{Consumer, Token}
@ -20,6 +21,8 @@ trait BerlinGroupServerSetupV1_3 extends ServerSetupWithTestData {
super.beforeEach()
// Create necessary system views for APIs of Berlin Group)
Views.views.vend.getOrCreateSystemView(SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID)
Views.views.vend.getOrCreateSystemView(Constant.SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID)
Views.views.vend.getOrCreateSystemView(Constant.SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID)
}
def grantUserAccessToViewViaEndpoint(bankId: String,