mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 15:27:01 +00:00
feature/Add getCounterpartyByIbanAndBankAccountId connector method
This new connector method is used to target precisely a counterparty linked to an account. This method should be used to replace the old one (getCounterpartyByIban)
This commit is contained in:
parent
59daf4d144
commit
b5e5eb14d7
@ -815,6 +815,20 @@ object NewStyle {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
def getCounterpartyByIbanAndBankAccountId(iban: String, bankId: BankId, accountId: AccountId, callContext: Option[CallContext]) : OBPReturnType[CounterpartyTrait] =
|
||||
{
|
||||
Connector.connector.vend.getCounterpartyByIbanAndBankAccountId(iban: String, bankId: BankId, accountId: AccountId, callContext: Option[CallContext]) map { i =>
|
||||
(unboxFullOrFail(
|
||||
i._1,
|
||||
callContext,
|
||||
s"$CounterpartyNotFoundByIban. Please check how do you create Counterparty, " +
|
||||
s"set the proper Iban value to `other_account_secondary_routing_address`. Current Iban = $iban. " +
|
||||
s"Check also the bankId and the accountId, Current BankId = ${bankId.value}, Current AccountId = ${accountId.value}",
|
||||
404),
|
||||
i._2)
|
||||
}
|
||||
}
|
||||
|
||||
def getTransactionRequestImpl(transactionRequestId: TransactionRequestId, callContext: Option[CallContext]): OBPReturnType[TransactionRequest] =
|
||||
{
|
||||
|
||||
@ -842,7 +842,7 @@ trait APIMethods400 {
|
||||
json.extract[TransactionRequestBodySEPAJsonV400]
|
||||
}
|
||||
toIban = transDetailsSEPAJson.to.iban
|
||||
(toCounterparty, callContext) <- NewStyle.function.getCounterpartyByIban(toIban, cc.callContext)
|
||||
(toCounterparty, callContext) <- NewStyle.function.getCounterpartyByIbanAndBankAccountId(toIban, fromAccount.bankId, fromAccount.accountId, cc.callContext)
|
||||
toAccount <- NewStyle.function.getBankAccountFromCounterparty(toCounterparty, true, callContext)
|
||||
_ <- Helper.booleanToFuture(s"$CounterpartyBeneficiaryPermit") {
|
||||
toCounterparty.isBeneficiary
|
||||
|
||||
@ -541,6 +541,8 @@ trait Connector extends MdcLoggable {
|
||||
*/
|
||||
def getCounterpartyByIban(iban: String, callContext: Option[CallContext]) : OBPReturnType[Box[CounterpartyTrait]] = Future {(Failure(setUnimplementedError), callContext)}
|
||||
|
||||
def getCounterpartyByIbanAndBankAccountId(iban: String, bankId: BankId, accountId: AccountId, callContext: Option[CallContext]) : OBPReturnType[Box[CounterpartyTrait]] = Future {(Failure(setUnimplementedError), callContext)}
|
||||
|
||||
def getCounterpartiesLegacy(thisBankId: BankId, thisAccountId: AccountId, viewId :ViewId, callContext: Option[CallContext] = None): Box[(List[CounterpartyTrait], Option[CallContext])]= Failure(setUnimplementedError)
|
||||
|
||||
def getCounterparties(thisBankId: BankId, thisAccountId: AccountId, viewId: ViewId, callContext: Option[CallContext] = None): OBPReturnType[Box[List[CounterpartyTrait]]] = Future {(Failure(setUnimplementedError), callContext)}
|
||||
|
||||
@ -793,6 +793,10 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
Future(Counterparties.counterparties.vend.getCounterpartyByIban(iban), callContext)
|
||||
}
|
||||
|
||||
override def getCounterpartyByIbanAndBankAccountId(iban: String, bankId: BankId, accountId: AccountId, callContext: Option[CallContext]) = {
|
||||
Future(Counterparties.counterparties.vend.getCounterpartyByIbanAndBankAccountId(iban, bankId, accountId), callContext)
|
||||
}
|
||||
|
||||
|
||||
override def getPhysicalCardsForUser(user: User): Box[List[PhysicalCard]] = {
|
||||
val list = code.cards.PhysicalCard.physicalCardProvider.vend.getPhysicalCards(user)
|
||||
|
||||
@ -36,6 +36,8 @@ trait Counterparties {
|
||||
|
||||
def getCounterpartyByIban(iban : String): Box[CounterpartyTrait]
|
||||
|
||||
def getCounterpartyByIbanAndBankAccountId(iban: String, bankId: BankId, accountId: AccountId): Box[CounterpartyTrait]
|
||||
|
||||
def getCounterparties(thisBankId: BankId, thisAccountId: AccountId, viewId: ViewId): Box[List[CounterpartyTrait]]
|
||||
|
||||
def createCounterparty(
|
||||
@ -97,6 +99,8 @@ class RemotedataCounterpartiesCaseClasses {
|
||||
|
||||
case class getCounterpartyByIban(iban: String)
|
||||
|
||||
case class getCounterpartyByIbanAndBankAccountId(iban: String, bankId: BankId, accountId: AccountId)
|
||||
|
||||
case class getCounterparties(thisBankId: BankId, thisAccountId: AccountId, viewId: ViewId)
|
||||
|
||||
case class createCounterparty(
|
||||
|
||||
@ -133,6 +133,14 @@ object MapperCounterparties extends Counterparties with MdcLoggable {
|
||||
)
|
||||
}
|
||||
|
||||
def getCounterpartyByIbanAndBankAccountId(iban : String, bankId: BankId, accountId: AccountId) = {
|
||||
MappedCounterparty.find(
|
||||
By(MappedCounterparty.mOtherAccountSecondaryRoutingAddress, iban),
|
||||
By(MappedCounterparty.mThisBankId, bankId.value),
|
||||
By(MappedCounterparty.mThisAccountId, accountId.value)
|
||||
)
|
||||
}
|
||||
|
||||
override def getCounterparties(thisBankId: BankId, thisAccountId: AccountId, viewId: ViewId): Box[List[CounterpartyTrait]] = {
|
||||
Full(MappedCounterparty.findAll(By(MappedCounterparty.mThisAccountId, thisAccountId.value),
|
||||
By(MappedCounterparty.mThisBankId, thisBankId.value),
|
||||
|
||||
@ -109,7 +109,9 @@ object MongoCounterparties extends Counterparties with MdcLoggable {
|
||||
|
||||
override def getCounterparty(counterpartyId : String): Box[CounterpartyTrait] = Empty
|
||||
|
||||
override def getCounterpartyByIban(counterpartyId : String): Box[CounterpartyTrait] = Empty
|
||||
override def getCounterpartyByIban(iban : String): Box[CounterpartyTrait] = Empty
|
||||
|
||||
override def getCounterpartyByIbanAndBankAccountId(iban : String, bankId: BankId, accountId: AccountId): Box[CounterpartyTrait] = Empty
|
||||
|
||||
override def createCounterparty(
|
||||
createdByUserId: String,
|
||||
|
||||
@ -36,6 +36,10 @@ object RemotedataCounterparties extends ObpActorInit with Counterparties {
|
||||
(actor ? cc.getCounterpartyByIban(iban: String)).mapTo[Box[CounterpartyTrait]]
|
||||
)
|
||||
|
||||
override def getCounterpartyByIbanAndBankAccountId(iban: String, bankId: BankId, accountId: AccountId): Box[CounterpartyTrait] = getValueFromFuture(
|
||||
(actor ? cc.getCounterpartyByIbanAndBankAccountId(iban: String, bankId: BankId, accountId: AccountId)).mapTo[Box[CounterpartyTrait]]
|
||||
)
|
||||
|
||||
override def getCounterparties(thisBankId: BankId, thisAccountId: AccountId, viewId: ViewId): Box[List[CounterpartyTrait]] = getValueFromFuture(
|
||||
(actor ? cc.getCounterparties(thisBankId, thisAccountId, viewId)).mapTo[Box[List[CounterpartyTrait]]]
|
||||
)
|
||||
|
||||
@ -100,9 +100,9 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
|
||||
|
||||
//prepare for counterparty and SEPA stuff
|
||||
//For SEPA, otherAccountRoutingScheme must be 'IBAN'
|
||||
val counterpartySEPA = createCounterparty(bankId.value, accountId2.value, true, UUID.randomUUID.toString);
|
||||
val counterpartySEPA = createCounterparty(bankId.value, accountId1.value, accountId2.value, true, UUID.randomUUID.toString);
|
||||
//For Counterpart local mapper, the mOtherAccountRoutingScheme='OBP' and mOtherBankRoutingScheme = 'OBP'
|
||||
val counterpartyCounterparty = createCounterparty(bankId.value, accountId2.value, true, UUID.randomUUID.toString);
|
||||
val counterpartyCounterparty = createCounterparty(bankId.value, accountId1.value, accountId2.value, true, UUID.randomUUID.toString);
|
||||
|
||||
var transactionRequestBodySEPA = TransactionRequestBodySEPAJSON(bodyValue, IbanJson(counterpartySEPA.otherAccountSecondaryRoutingAddress), description, sharedChargePolicy)
|
||||
|
||||
|
||||
@ -113,9 +113,9 @@ class TransactionRequestsTest extends V400ServerSetup with DefaultUsers {
|
||||
|
||||
//prepare for counterparty and SEPA stuff
|
||||
//For SEPA, otherAccountRoutingScheme must be 'IBAN'
|
||||
val counterpartySEPA = createCounterparty(bankId.value, accountId2.value, true, UUID.randomUUID.toString);
|
||||
val counterpartySEPA = createCounterparty(bankId.value, accountId1.value, accountId2.value, true, UUID.randomUUID.toString);
|
||||
//For Counterpart local mapper, the mOtherAccountRoutingScheme='OBP' and mOtherBankRoutingScheme = 'OBP'
|
||||
val counterpartyCounterparty = createCounterparty(bankId.value, accountId2.value, true, UUID.randomUUID.toString);
|
||||
val counterpartyCounterparty = createCounterparty(bankId.value, accountId1.value, accountId2.value, true, UUID.randomUUID.toString);
|
||||
|
||||
var transactionRequestBodySEPA = TransactionRequestBodySEPAJSON(bodyValue, IbanJson(counterpartySEPA.otherAccountSecondaryRoutingAddress), description, sharedChargePolicy)
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ trait LocalMappedConnectorTestSetup extends TestConnectorSetupWithStandardPermis
|
||||
.saveMe
|
||||
}
|
||||
|
||||
override protected def createCounterparty(bankId: String, accountId: String, isBeneficiary: Boolean, createdByUserId:String): CounterpartyTrait = {
|
||||
override protected def createCounterparty(bankId: String, accountId: String, counterpartyObpRoutingAddress: String, isBeneficiary: Boolean, createdByUserId:String): CounterpartyTrait = {
|
||||
Counterparties.counterparties.vend.createCounterparty(
|
||||
createdByUserId = createdByUserId,
|
||||
thisBankId = bankId,
|
||||
@ -43,7 +43,7 @@ trait LocalMappedConnectorTestSetup extends TestConnectorSetupWithStandardPermis
|
||||
thisViewId = "",
|
||||
name = APIUtil.generateUUID(),
|
||||
otherAccountRoutingScheme = "OBP",
|
||||
otherAccountRoutingAddress = accountId,
|
||||
otherAccountRoutingAddress = counterpartyObpRoutingAddress,
|
||||
otherBankRoutingScheme = "OBP",
|
||||
otherBankRoutingAddress = bankId,
|
||||
otherBranchRoutingScheme ="OBP",
|
||||
|
||||
@ -21,7 +21,7 @@ trait TestConnectorSetup {
|
||||
protected def createTransactionRequest(account: BankAccount): List[MappedTransactionRequest]
|
||||
protected def updateAccountCurrency(bankId: BankId, accountId : AccountId, currency : String) : BankAccount
|
||||
|
||||
protected def createCounterparty(bankId: String, accountId: String, isBeneficiary: Boolean, createdByUserId:String): CounterpartyTrait
|
||||
protected def createCounterparty(bankId: String, accountId: String, counterpartyObpRoutingAddress: String, isBeneficiary: Boolean, createdByUserId:String): CounterpartyTrait
|
||||
|
||||
/**
|
||||
* This method, will do 4 things:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user