feature/add support for retrieving bank account balances by multiple account IDs

This commit is contained in:
hongwei 2025-05-27 10:27:09 +02:00
parent 574e3a6c3a
commit 9bcd1055d7
4 changed files with 150 additions and 11 deletions

View File

@ -438,6 +438,7 @@ object ConnectorBuilderUtil {
"getRegulatedEntities",
"getRegulatedEntityByEntityId",
"getBankAccountBalancesByAccountId",
"getBankAccountsBalancesByAccountIds",
"getBankAccountBalanceById",
"createOrUpdateBankAccountBalance",
"deleteBankAccountBalance",

View File

@ -3,6 +3,8 @@ package code.bankconnectors.rabbitmq.Adapter
import bootstrap.liftweb.ToSchemify
import code.api.util.APIUtil
import code.bankconnectors.rabbitmq.RabbitMQUtils
import code.bankconnectors.rabbitmq.RabbitMQUtils._
import code.util.Helper.MdcLoggable
import com.openbankproject.commons.ExecutionContext.Implicits.global
import com.openbankproject.commons.dto._
import com.openbankproject.commons.model._
@ -13,11 +15,8 @@ import net.liftweb.json
import net.liftweb.json.Serialization.write
import net.liftweb.mapper.Schemifier
import scala.concurrent.Future
import com.openbankproject.commons.ExecutionContext.Implicits.global
import code.bankconnectors.rabbitmq.RabbitMQUtils._
import java.util.Date
import code.util.Helper.MdcLoggable
import scala.concurrent.Future
class ServerCallback(val ch: Channel) extends DeliverCallback with MdcLoggable{
@ -77,7 +76,7 @@ class ServerCallback(val ch: Channel) extends DeliverCallback with MdcLoggable{
))
}
//---------------- dynamic start -------------------please don't modify this line
// ---------- created on 2025-04-07T14:53:47Z
// ---------- created on 2025-05-27T08:15:58Z
} else if (obpMessageId.contains("get_adapter_info")) {
val outBound = json.parse(message).extract[OutBoundGetAdapterInfo]
@ -3151,6 +3150,111 @@ class ServerCallback(val ch: Channel) extends DeliverCallback with MdcLoggable{
data = null
))
}
} else if (obpMessageId.contains("get_bank_account_balances_by_account_id")) {
val outBound = json.parse(message).extract[OutBoundGetBankAccountBalancesByAccountId]
val obpMappedResponse = code.bankconnectors.LocalMappedConnector.getBankAccountBalancesByAccountId(outBound.accountId,None).map(_._1.head)
obpMappedResponse.map(response => InBoundGetBankAccountBalancesByAccountId(
inboundAdapterCallContext = InboundAdapterCallContext(
correlationId = outBound.outboundAdapterCallContext.correlationId
),
status = Status("", Nil),
data = response
)).recoverWith {
case e: Exception => Future(InBoundGetBankAccountBalancesByAccountId(
inboundAdapterCallContext = InboundAdapterCallContext(
correlationId = outBound.outboundAdapterCallContext.correlationId
),
status = Status(e.getMessage, Nil),
data = null
))
}
} else if (obpMessageId.contains("get_bank_accounts_balances_by_account_ids")) {
val outBound = json.parse(message).extract[OutBoundGetBankAccountsBalancesByAccountIds]
val obpMappedResponse = code.bankconnectors.LocalMappedConnector.getBankAccountsBalancesByAccountIds(outBound.accountIds,None).map(_._1.head)
obpMappedResponse.map(response => InBoundGetBankAccountsBalancesByAccountIds(
inboundAdapterCallContext = InboundAdapterCallContext(
correlationId = outBound.outboundAdapterCallContext.correlationId
),
status = Status("", Nil),
data = response
)).recoverWith {
case e: Exception => Future(InBoundGetBankAccountsBalancesByAccountIds(
inboundAdapterCallContext = InboundAdapterCallContext(
correlationId = outBound.outboundAdapterCallContext.correlationId
),
status = Status(e.getMessage, Nil),
data = null
))
}
} else if (obpMessageId.contains("get_bank_account_balance_by_id")) {
val outBound = json.parse(message).extract[OutBoundGetBankAccountBalanceById]
val obpMappedResponse = code.bankconnectors.LocalMappedConnector.getBankAccountBalanceById(outBound.balanceId,None).map(_._1.head)
obpMappedResponse.map(response => InBoundGetBankAccountBalanceById(
inboundAdapterCallContext = InboundAdapterCallContext(
correlationId = outBound.outboundAdapterCallContext.correlationId
),
status = Status("", Nil),
data = response
)).recoverWith {
case e: Exception => Future(InBoundGetBankAccountBalanceById(
inboundAdapterCallContext = InboundAdapterCallContext(
correlationId = outBound.outboundAdapterCallContext.correlationId
),
status = Status(e.getMessage, Nil),
data = null
))
}
} else if (obpMessageId.contains("create_or_update_bank_account_balance")) {
val outBound = json.parse(message).extract[OutBoundCreateOrUpdateBankAccountBalance]
val obpMappedResponse = code.bankconnectors.LocalMappedConnector.createOrUpdateBankAccountBalance(outBound.bankId,outBound.accountId,outBound.balanceId,outBound.balanceType,outBound.balanceAmount,None).map(_._1.head)
obpMappedResponse.map(response => InBoundCreateOrUpdateBankAccountBalance(
inboundAdapterCallContext = InboundAdapterCallContext(
correlationId = outBound.outboundAdapterCallContext.correlationId
),
status = Status("", Nil),
data = response
)).recoverWith {
case e: Exception => Future(InBoundCreateOrUpdateBankAccountBalance(
inboundAdapterCallContext = InboundAdapterCallContext(
correlationId = outBound.outboundAdapterCallContext.correlationId
),
status = Status(e.getMessage, Nil),
data = null
))
}
} else if (obpMessageId.contains("delete_bank_account_balance")) {
val outBound = json.parse(message).extract[OutBoundDeleteBankAccountBalance]
val obpMappedResponse = code.bankconnectors.LocalMappedConnector.deleteBankAccountBalance(outBound.balanceId,None).map(_._1.head)
obpMappedResponse.map(response => InBoundDeleteBankAccountBalance(
inboundAdapterCallContext = InboundAdapterCallContext(
correlationId = outBound.outboundAdapterCallContext.correlationId
),
status = Status("", Nil),
data = response
)).recoverWith {
case e: Exception => Future(InBoundDeleteBankAccountBalance(
inboundAdapterCallContext = InboundAdapterCallContext(
correlationId = outBound.outboundAdapterCallContext.correlationId
),
status = Status(e.getMessage, Nil),
data = false
))
}
} else if (obpMessageId.contains("dynamic_entity_process")) {
val outBound = json.parse(message).extract[OutBoundDynamicEntityProcess]
val obpMappedResponse = code.bankconnectors.LocalMappedConnector.dynamicEntityProcess(outBound.operation,outBound.entityName,outBound.requestBody,outBound.entityId,None,None,None,false,None).map(_._1.head)
@ -3172,8 +3276,8 @@ class ServerCallback(val ch: Channel) extends DeliverCallback with MdcLoggable{
data = null
))
}
// ---------- created on 2025-04-07T14:53:47Z
//---------------- dynamic end ---------------------please don't modify this line
// ---------- created on 2025-05-27T08:15:58Z
//---------------- dynamic end ---------------------please don't modify this line
} else {
Future {
1

View File

@ -67,7 +67,7 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
val errorCodeExample = "INTERNAL-OBP-ADAPTER-6001: ..."
//---------------- dynamic start -------------------please don't modify this line
// ---------- created on 2025-05-22T11:32:05Z
// ---------- created on 2025-05-27T10:14:24Z
messageDocs += getAdapterInfoDoc
def getAdapterInfoDoc = MessageDoc(
@ -7176,6 +7176,36 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
response.map(convertToTuple[List[BankAccountBalanceTraitCommons]](callContext))
}
messageDocs += getBankAccountsBalancesByAccountIdsDoc
def getBankAccountsBalancesByAccountIdsDoc = MessageDoc(
process = "obp.getBankAccountsBalancesByAccountIds",
messageFormat = messageFormat,
description = "Get Bank Accounts Balances By Account Ids",
outboundTopic = None,
inboundTopic = None,
exampleOutboundMessage = (
OutBoundGetBankAccountsBalancesByAccountIds(outboundAdapterCallContext=MessageDocsSwaggerDefinitions.outboundAdapterCallContext,
accountIds=List(AccountId(accountIdExample.value)))
),
exampleInboundMessage = (
InBoundGetBankAccountsBalancesByAccountIds(inboundAdapterCallContext=MessageDocsSwaggerDefinitions.inboundAdapterCallContext,
status=MessageDocsSwaggerDefinitions.inboundStatus,
data=List( BankAccountBalanceTraitCommons(bankId=BankId(bankIdExample.value),
accountId=AccountId(accountIdExample.value),
balanceId=BalanceId(balanceIdExample.value),
balanceType=balanceTypeExample.value,
balanceAmount=BigDecimal(balanceAmountExample.value))))
),
adapterImplementation = Some(AdapterImplementation("- Core", 1))
)
override def getBankAccountsBalancesByAccountIds(accountIds: List[AccountId], callContext: Option[CallContext]): OBPReturnType[Box[List[BankAccountBalanceTrait]]] = {
import com.openbankproject.commons.dto.{InBoundGetBankAccountsBalancesByAccountIds => InBound, OutBoundGetBankAccountsBalancesByAccountIds => OutBound}
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, accountIds)
val response: Future[Box[InBound]] = sendRequest[InBound]("obp_get_bank_accounts_balances_by_account_ids", req, callContext)
response.map(convertToTuple[List[BankAccountBalanceTraitCommons]](callContext))
}
messageDocs += getBankAccountBalanceByIdDoc
def getBankAccountBalanceByIdDoc = MessageDoc(
process = "obp.getBankAccountBalanceById",
@ -7266,8 +7296,8 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
response.map(convertToTuple[Boolean](callContext))
}
// ---------- created on 2025-05-22T11:32:05Z
//---------------- dynamic end ---------------------please don't modify this line
// ---------- created on 2025-05-27T10:14:24Z
//---------------- dynamic end ---------------------please don't modify this line
private val availableOperation = DynamicEntityOperation.values.map(it => s""""$it"""").mkString("[", ", ", "]")

View File

@ -26,10 +26,10 @@
package com.openbankproject.commons.dto
import com.openbankproject.commons.model._
import com.openbankproject.commons.model.enums.StrongCustomerAuthentication.SCA
import com.openbankproject.commons.model.enums.StrongCustomerAuthenticationStatus.SCAStatus
import com.openbankproject.commons.model.enums.{TransactionRequestStatus, _}
import com.openbankproject.commons.model._
import net.liftweb.json.{JObject, JValue}
import java.util.Date
@ -392,6 +392,10 @@ case class OutBoundCreateTaxResidence(outboundAdapterCallContext: OutboundAdapte
case class InBoundCreateTaxResidence(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: TaxResidenceCommons) extends InBoundTrait[TaxResidenceCommons]
case class OutBoundGetBankAccountsBalancesByAccountIds (outboundAdapterCallContext: OutboundAdapterCallContext,
accountIds: List[AccountId]) extends TopicTrait
case class InBoundGetBankAccountsBalancesByAccountIds (inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[BankAccountBalanceTraitCommons]) extends InBoundTrait[List[BankAccountBalanceTraitCommons]]
case class OutBoundGetTaxResidence(outboundAdapterCallContext: OutboundAdapterCallContext,
customerId: String) extends TopicTrait