From 4d321f3148f47f554c4bbec1af67b4094e156c8b Mon Sep 17 00:00:00 2001 From: Hongwei Date: Tue, 22 Apr 2025 15:09:01 +0200 Subject: [PATCH] refactor/added accountBalances to CoreAccountsJsonV13 --- .../v1_3/JSONFactory_BERLIN_GROUP_1_3.scala | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/obp-api/src/main/scala/code/api/berlin/group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala b/obp-api/src/main/scala/code/api/berlin/group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala index 44315adbb..0cfa2bad1 100644 --- a/obp-api/src/main/scala/code/api/berlin/group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala +++ b/obp-api/src/main/scala/code/api/berlin/group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala @@ -51,12 +51,12 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats { transactions: Option[LinkHrefJson] = None // These links are only supported, when the corresponding consent has been already granted. ) - case class CoreAccountBalancesJson( - balanceAmount:AmountOfMoneyV13 = AmountOfMoneyV13("EUR","123"), - balanceType: String = "closingBooked", - lastChangeDateTime: String = "2019-01-28T06:26:52.185Z", - referenceDate: String = "2020-07-02", - lastCommittedTransaction: String = "string", + case class CoreAccountBalanceJson( + balanceAmount:AmountOfMoneyV13,// = AmountOfMoneyV13("EUR","123"), + balanceType: String //= "closingBooked", +// lastChangeDateTime: String = "2019-01-28T06:26:52.185Z", +// referenceDate: String = "2020-07-02", +// lastCommittedTransaction: String = "string", ) case class CoreAccountJsonV13( resourceId: String, @@ -70,7 +70,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats { // linkedAccounts: String ="string", // usage: String ="PRIV", // details: String ="", -// balances: CoreAccountBalancesJson,// We put this under the _links, not need to show it here. + balances: Option[List[CoreAccountBalanceJson]] = None, _links: CoreAccountLinksJsonV13, ) @@ -317,7 +317,10 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats { val balanceRef = LinkHrefJson(s"/$commonPath/balances") val transactionRef = LinkHrefJson(s"/$commonPath/transactions") val canReadTransactions = canReadTransactionsAccounts.map(_.accountId.value).contains(x.accountId.value) - + val accountBalances = Some(List(CoreAccountBalanceJson( + balanceAmount = AmountOfMoneyV13(x.currency, x.balance.toString), + balanceType = "closingBooked" + ))) CoreAccountJsonV13( resourceId = x.accountId.value, @@ -327,6 +330,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats { name = x.name, cashAccountType = x.accountType, product = x.accountType, + balances = accountBalances, _links = CoreAccountLinksJsonV13( balances = balanceRef, transactions = if(canReadTransactions) Some(transactionRef) else None, @@ -341,6 +345,11 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats { x => val (iBan: String, bBan: String) = getIbanAndBban(x) + val accountBalances = Some(List(CoreAccountBalanceJson( + balanceAmount = AmountOfMoneyV13(x.currency, x.balance.toString), + balanceType = "closingBooked" + ))) + CoreAccountJsonV13( resourceId = x.accountId.value, iban = iBan, @@ -349,6 +358,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats { name = x.name, cashAccountType = x.accountType, product = x.accountType, + balances = accountBalances, _links = CoreAccountLinksJsonV13(LinkHrefJson(s"/${OBP_BERLIN_GROUP_1_3.apiVersion.urlPrefix}/${OBP_BERLIN_GROUP_1_3.version}/accounts/${x.accountId.value}/balances")) ) }