mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 17:37:00 +00:00
refector the explicit Counterparty_Id generated in Adapter side.
This commit is contained in:
parent
9d1cedcd63
commit
a742d3a8fc
@ -1798,7 +1798,23 @@ object SwaggerDefinitionsJSON {
|
||||
val counterpartyMetadataJson = CounterpartyMetadataJson(publicAlias = "String")
|
||||
|
||||
val counterpartyWithMetadataJson = CounterpartyWithMetadataJson(
|
||||
counterparty = counterpartyJsonV220,
|
||||
name = postCounterpartyJSON.name,
|
||||
description = postCounterpartyJSON.description,
|
||||
created_by_user_id = "49e1e147-64c1-4823-ad9f-89efcd02a9fa",
|
||||
this_bank_id = "gh.29.uk",
|
||||
this_account_id = "8ca8a7e4-6d02-48e3-a029-0b2bf89de9f0",
|
||||
this_view_id = "owner",
|
||||
counterparty_id = "1d65db7c-a7b2-4839-af41-958276ab7790",
|
||||
other_bank_routing_scheme = postCounterpartyJSON.other_bank_routing_scheme,
|
||||
other_bank_routing_address = postCounterpartyJSON.other_bank_routing_scheme,
|
||||
other_branch_routing_scheme = postCounterpartyJSON.other_bank_routing_scheme,
|
||||
other_branch_routing_address = postCounterpartyJSON.other_bank_routing_scheme,
|
||||
other_account_routing_scheme = postCounterpartyJSON.other_bank_routing_scheme,
|
||||
other_account_routing_address = postCounterpartyJSON.other_bank_routing_scheme,
|
||||
is_beneficiary = true,
|
||||
other_account_secondary_routing_scheme = postCounterpartyJSON.other_bank_routing_scheme,
|
||||
other_account_secondary_routing_address= postCounterpartyJSON.other_bank_routing_scheme,
|
||||
bespoke = postCounterpartyJSON.bespoke,
|
||||
metadata = counterpartyMetadataJson
|
||||
)
|
||||
|
||||
|
||||
@ -302,6 +302,9 @@ trait APIMethods220 {
|
||||
canAddCounterparty <- booleanToBox(view.canAddCounterparty == true, s"${ViewNoPermission}canAddCounterparty")
|
||||
canUserAccessView <- Full(account.permittedViews(user).find(_ == viewId)) ?~! UserNoPermissionAccessView
|
||||
counterparties <- Connector.connector.vend.getCounterparties(bankId,accountId,viewId)
|
||||
//Here we need create the metadata for all the explicit counterparties. maybe show them in json response.
|
||||
//Note: actually we need update all the counterparty metadata when they from adapter. Some counterparties may be the first time to api, there is no metadata.
|
||||
_ <- tryo {for{counterparty <-counterparties}Counterparties.counterparties.vend.getOrCreateMetadata(bankId, accountId, counterparty.counterpartyId, counterparty.name)} ?~! CreateOrUpdateCounterpartyMetadataError
|
||||
} yield {
|
||||
val counterpartiesJson = JSONFactory220.createCounterpartiesJSON(counterparties)
|
||||
successJsonResponse(Extraction.decompose(counterpartiesJson))
|
||||
@ -1050,12 +1053,7 @@ trait APIMethods220 {
|
||||
checkCounterpartyAvailable(postJson.name,bankId.value, accountId.value,viewId.value) == true)
|
||||
) ?~! CounterpartyAlreadyExists
|
||||
|
||||
//This is the `EXPLICIT` Counterparty, we also create the metaData for it
|
||||
counterpartyId <- Full(APIUtil.createExplicitCounterpartyId())
|
||||
counterpartyMetadata <- Counterparties.counterparties.vend.getOrCreateMetadata(bankId, accountId, counterpartyId, postJson.name) ?~! CreateOrUpdateCounterpartyMetadataError
|
||||
|
||||
counterparty <- Connector.connector.vend.createCounterparty(
|
||||
counterpartyId=counterpartyMetadata.getCounterpartyId,
|
||||
name=postJson.name,
|
||||
description=postJson.description,
|
||||
createdByUserId=u.userId,
|
||||
@ -1073,6 +1071,9 @@ trait APIMethods220 {
|
||||
isBeneficiary=postJson.is_beneficiary,
|
||||
bespoke=postJson.bespoke
|
||||
)
|
||||
|
||||
counterpartyMetadata <- Counterparties.counterparties.vend.getOrCreateMetadata(bankId, accountId, counterparty.counterpartyId, postJson.name) ?~! CreateOrUpdateCounterpartyMetadataError
|
||||
|
||||
} yield {
|
||||
val list = JSONFactory220.createCounterpartyWithMetadataJSON(counterparty,counterpartyMetadata)
|
||||
successJsonResponse(Extraction.decompose(list))
|
||||
|
||||
@ -146,7 +146,23 @@ case class FXRateJsonV220(
|
||||
)
|
||||
|
||||
case class CounterpartyWithMetadataJson(
|
||||
counterparty: CounterpartyJsonV220,
|
||||
name: String,
|
||||
description: String,
|
||||
created_by_user_id: String,
|
||||
this_bank_id: String,
|
||||
this_account_id: String,
|
||||
this_view_id: String,
|
||||
counterparty_id: String,
|
||||
other_bank_routing_scheme: String,
|
||||
other_bank_routing_address: String,
|
||||
other_branch_routing_scheme: String,
|
||||
other_branch_routing_address: String,
|
||||
other_account_routing_scheme: String,
|
||||
other_account_routing_address: String,
|
||||
other_account_secondary_routing_scheme: String,
|
||||
other_account_secondary_routing_address: String,
|
||||
is_beneficiary: Boolean,
|
||||
bespoke:List[PostCounterpartyBespoke],
|
||||
metadata: CounterpartyMetadataJson
|
||||
)
|
||||
case class CounterpartyJsonV220(
|
||||
@ -455,7 +471,6 @@ object JSONFactory220{
|
||||
|
||||
def createCounterpartyWithMetadataJSON(counterparty: CounterpartyTrait, counterpartyMetadata: CounterpartyMetadata): CounterpartyWithMetadataJson = {
|
||||
CounterpartyWithMetadataJson(
|
||||
CounterpartyJsonV220(
|
||||
name = counterparty.name,
|
||||
description = counterparty.description,
|
||||
created_by_user_id = counterparty.createdByUserId,
|
||||
@ -472,9 +487,8 @@ object JSONFactory220{
|
||||
other_branch_routing_scheme = counterparty.otherBranchRoutingScheme,
|
||||
other_branch_routing_address =counterparty.otherBranchRoutingAddress,
|
||||
is_beneficiary = counterparty.isBeneficiary,
|
||||
bespoke= counterparty.bespoke
|
||||
),
|
||||
CounterpartyMetadataJson(
|
||||
bespoke= counterparty.bespoke,
|
||||
metadata=CounterpartyMetadataJson(
|
||||
publicAlias = counterpartyMetadata.getPublicAlias
|
||||
)
|
||||
)
|
||||
|
||||
@ -1227,7 +1227,6 @@ trait Connector extends MdcLoggable{
|
||||
}
|
||||
|
||||
def createCounterparty(
|
||||
counterpartyId: String,
|
||||
name: String,
|
||||
description: String,
|
||||
createdByUserId: String,
|
||||
|
||||
@ -1538,7 +1538,6 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
}
|
||||
|
||||
override def createCounterparty(
|
||||
counterpartyId: String,
|
||||
name: String,
|
||||
description: String,
|
||||
createdByUserId: String,
|
||||
@ -1557,7 +1556,6 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
bespoke: List[PostCounterpartyBespoke]
|
||||
): Box[CounterpartyTrait] =
|
||||
Counterparties.counterparties.vend.createCounterparty(
|
||||
counterpartyId = counterpartyId,
|
||||
createdByUserId = createdByUserId,
|
||||
thisBankId = thisBankId,
|
||||
thisAccountId = thisAccountId,
|
||||
|
||||
@ -187,7 +187,6 @@ case class InternalGetTransactionRequests(
|
||||
)
|
||||
|
||||
case class OutboundCounterparty(
|
||||
counterpartyId: String,
|
||||
name: String,
|
||||
description: String,
|
||||
createdByUserId: String,
|
||||
|
||||
@ -989,7 +989,6 @@ trait KafkaMappedConnector_vJune2017 extends Connector with KafkaHelper with Mdc
|
||||
OutboundCreateCounterparty(
|
||||
authInfoExample,
|
||||
OutboundCounterparty(
|
||||
counterpartyId= "String",
|
||||
name = "name",
|
||||
description = "description",
|
||||
createdByUserId = "createdByUserId",
|
||||
@ -1040,7 +1039,6 @@ trait KafkaMappedConnector_vJune2017 extends Connector with KafkaHelper with Mdc
|
||||
)
|
||||
)
|
||||
override def createCounterparty(
|
||||
counterpartyId: String,
|
||||
name: String,
|
||||
description: String,
|
||||
createdByUserId: String,
|
||||
@ -1061,7 +1059,6 @@ trait KafkaMappedConnector_vJune2017 extends Connector with KafkaHelper with Mdc
|
||||
val req = OutboundCreateCounterparty(
|
||||
authInfo = AuthInfo(currentResourceUserId, getUsername, getCbsToken),
|
||||
counterparty = OutboundCounterparty(
|
||||
counterpartyId: String,
|
||||
name: String,
|
||||
description: String,
|
||||
createdByUserId: String,
|
||||
|
||||
@ -36,7 +36,6 @@ trait Counterparties {
|
||||
def getCounterparties(thisBankId: BankId, thisAccountId: AccountId, viewId: ViewId): Box[List[CounterpartyTrait]]
|
||||
|
||||
def createCounterparty(
|
||||
counterpartyId: String,
|
||||
createdByUserId: String,
|
||||
thisBankId: String,
|
||||
thisAccountId: String,
|
||||
@ -116,7 +115,7 @@ class RemotedataCounterpartiesCaseClasses {
|
||||
case class getCounterparties(thisBankId: BankId, thisAccountId: AccountId, viewId: ViewId)
|
||||
|
||||
case class createCounterparty(
|
||||
counterpartyId: String,createdByUserId: String, thisBankId: String, thisAccountId: String, thisViewId: String,
|
||||
createdByUserId: String, thisBankId: String, thisAccountId: String, thisViewId: String,
|
||||
name: String,
|
||||
otherAccountRoutingScheme: String,
|
||||
otherAccountRoutingAddress: String, otherBankRoutingScheme: String,
|
||||
|
||||
@ -129,7 +129,7 @@ object MapperCounterparties extends Counterparties with MdcLoggable {
|
||||
By(MappedCounterparty.mThisViewId, viewId.value)))
|
||||
}
|
||||
|
||||
override def createCounterparty(counterpartyId: String,
|
||||
override def createCounterparty(
|
||||
createdByUserId: String,
|
||||
thisBankId: String,
|
||||
thisAccountId : String,
|
||||
@ -148,13 +148,8 @@ object MapperCounterparties extends Counterparties with MdcLoggable {
|
||||
bespoke: List[PostCounterpartyBespoke]
|
||||
): Box[CounterpartyTrait] = {
|
||||
|
||||
val counterpartyId = APIUtil.createExplicitCounterpartyId()
|
||||
|
||||
//This is the `EXPLICIT` Counterparty, we also create the metaData for it
|
||||
val metadata = Counterparties.counterparties.vend.getOrCreateMetadata(BankId(thisBankId), AccountId(thisAccountId), counterpartyId, name).openOrThrowException("Can not getOrCreateMetadata !")
|
||||
|
||||
val mappedCounterparty = MappedCounterparty.create
|
||||
.mCounterPartyId(metadata.getCounterpartyId)
|
||||
.mCounterPartyId(APIUtil.createExplicitCounterpartyId) //We create the Counterparty_Id here, it means, it will be create in each connnector.
|
||||
.mName(name)
|
||||
.mCreatedByUserId(createdByUserId)
|
||||
.mThisBankId(thisBankId)
|
||||
|
||||
@ -112,7 +112,6 @@ object MongoCounterparties extends Counterparties with MdcLoggable {
|
||||
override def getCounterpartyByIban(counterPartyId : String): Box[CounterpartyTrait] = Empty
|
||||
|
||||
override def createCounterparty(
|
||||
counterpartyId: String,
|
||||
createdByUserId: String,
|
||||
thisBankId: String,
|
||||
thisAccountId: String,
|
||||
|
||||
@ -34,7 +34,7 @@ object RemotedataCounterparties extends ObpActorInit with Counterparties {
|
||||
override def getCounterparties(thisBankId: BankId, thisAccountId: AccountId, viewId: ViewId): Box[List[CounterpartyTrait]] =
|
||||
extractFutureToBox(actor ? cc.getCounterparties(thisBankId, thisAccountId, viewId))
|
||||
|
||||
override def createCounterparty(counterpartyId: String,
|
||||
override def createCounterparty(
|
||||
createdByUserId: String,
|
||||
thisBankId: String,
|
||||
thisAccountId: String,
|
||||
@ -51,7 +51,7 @@ object RemotedataCounterparties extends ObpActorInit with Counterparties {
|
||||
otherAccountSecondaryRoutingAddress: String,
|
||||
description: String,
|
||||
bespoke: List[PostCounterpartyBespoke]): Box[CounterpartyTrait] =
|
||||
extractFutureToBox(actor ? cc.createCounterparty( counterpartyId, createdByUserId, thisBankId,
|
||||
extractFutureToBox(actor ? cc.createCounterparty(createdByUserId, thisBankId,
|
||||
thisAccountId, thisViewId, name,
|
||||
otherAccountRoutingScheme,
|
||||
otherAccountRoutingAddress,
|
||||
|
||||
@ -21,7 +21,7 @@ class RemotedataCounterpartiesActor extends Actor with ObpActorHelper with MdcLo
|
||||
logger.debug("checkCounterpartyAvailable(" + name +", "+ thisBankId +", "+ thisAccountId +", "+ thisViewId +")")
|
||||
sender ! extractResult(mapper.checkCounterpartyAvailable(name: String, thisBankId: String, thisAccountId: String, thisViewId: String))
|
||||
|
||||
case cc.createCounterparty(counterpartyId, createdByUserId, thisBankId, thisAccountId, thisViewId,
|
||||
case cc.createCounterparty(createdByUserId, thisBankId, thisAccountId, thisViewId,
|
||||
name, otherAccountRoutingScheme,
|
||||
otherAccountRoutingAddress, otherBankRoutingScheme,
|
||||
otherBranchRoutingScheme, otherBranchRoutingAddress,
|
||||
@ -31,11 +31,10 @@ class RemotedataCounterpartiesActor extends Actor with ObpActorHelper with MdcLo
|
||||
description: String,
|
||||
bespoke: List[PostCounterpartyBespoke]
|
||||
) =>
|
||||
logger.debug("createCounterparty(" +counterpartyId +createdByUserId + ", " + thisBankId + ", " + thisAccountId + ", " + thisViewId + ", " + name + ", "
|
||||
logger.debug("createCounterparty(" +createdByUserId + ", " + thisBankId + ", " + thisAccountId + ", " + thisViewId + ", " + name + ", "
|
||||
+ otherAccountRoutingScheme +", "+ otherAccountRoutingAddress +", "+ otherBankRoutingScheme +", "+ otherBankRoutingAddress +", "+ otherBranchRoutingScheme+
|
||||
", "+ otherBranchRoutingAddress+ ", "+ isBeneficiary+", "+ otherAccountSecondaryRoutingScheme+", "+ otherAccountSecondaryRoutingAddress+", "+ description+", "+ bespoke+")")
|
||||
sender ! extractResult(mapper.createCounterparty(
|
||||
counterpartyId:String,
|
||||
createdByUserId: String,
|
||||
thisBankId: String,
|
||||
thisAccountId : String,
|
||||
|
||||
@ -95,9 +95,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, "IBAN", "IBAN", true, UUID.randomUUID.toString, UUID.randomUUID.toString);
|
||||
val counterPartySEPA = createCounterparty(bankId.value, accountId2.value, "IBAN", "IBAN", true, UUID.randomUUID.toString);
|
||||
//For Counterpart local mapper, the mOtherAccountRoutingScheme='OBP' and mOtherBankRoutingScheme = 'OBP'
|
||||
val counterPartyCounterparty = createCounterparty(bankId.value, accountId2.value, "IBAN", "OBP", true, UUID.randomUUID.toString, UUID.randomUUID.toString);
|
||||
val counterPartyCounterparty = createCounterparty(bankId.value, accountId2.value, "IBAN", "OBP", true, UUID.randomUUID.toString);
|
||||
|
||||
var transactionRequestBodySEPA = TransactionRequestBodySEPAJSON(bodyValue, IbanJson(counterPartySEPA.otherAccountRoutingAddress), discription, sharedChargePolicy)
|
||||
|
||||
|
||||
@ -44,14 +44,14 @@ class CreateCounterpartyTest extends V220ServerSetup with DefaultUsers {
|
||||
Then("We should get a 200 and check all the fields")
|
||||
responsePost.code should equal(200)
|
||||
|
||||
var accountRoutingAddress = (responsePost.body \ "counterparty" \ "other_account_routing_address" ) match {
|
||||
var accountRoutingAddress = (responsePost.body \ "other_account_routing_address" ) match {
|
||||
case JString(i) => i
|
||||
case _ => ""
|
||||
}
|
||||
|
||||
accountRoutingAddress should equal(counterpartyPostJSON.other_account_routing_address)
|
||||
|
||||
val counterpartyId = (responsePost.body \ "counterparty" \ "counterparty_id" ) match {
|
||||
val counterpartyId = (responsePost.body \ "counterparty_id" ) match {
|
||||
case JString(i) => i
|
||||
case _ => ""
|
||||
}
|
||||
@ -65,7 +65,7 @@ class CreateCounterpartyTest extends V220ServerSetup with DefaultUsers {
|
||||
Then("We should get a 200 and check all the fields")
|
||||
responsePost.code should equal(200)
|
||||
|
||||
val accountRoutingAddressGet = (responsePost.body \ "counterparty" \ "other_account_routing_address" ) match {
|
||||
val accountRoutingAddressGet = (responsePost.body \ "other_account_routing_address" ) match {
|
||||
case JString(i) => i
|
||||
case _ => ""
|
||||
}
|
||||
@ -73,7 +73,7 @@ class CreateCounterpartyTest extends V220ServerSetup with DefaultUsers {
|
||||
accountRoutingAddressGet should equal(counterpartyPostJSON.other_account_routing_address)
|
||||
|
||||
|
||||
val counterpartyIdGet = (responsePost.body \ "counterparty" \ "counterparty_id" ) match {
|
||||
val counterpartyIdGet = (responsePost.body \ "counterparty_id" ) match {
|
||||
case JString(i) => i
|
||||
case _ => ""
|
||||
}
|
||||
|
||||
@ -35,9 +35,8 @@ trait LocalMappedConnectorTestSetup extends TestConnectorSetupWithStandardPermis
|
||||
.saveMe
|
||||
}
|
||||
|
||||
override protected def createCounterparty(bankId: String, accountId: String, accountRoutingAddress: String, otherAccountRoutingScheme: String, isBeneficiary: Boolean, counterpartyId: String, createdByUserId:String): CounterpartyTrait = {
|
||||
override protected def createCounterparty(bankId: String, accountId: String, accountRoutingAddress: String, otherAccountRoutingScheme: String, isBeneficiary: Boolean, createdByUserId:String): CounterpartyTrait = {
|
||||
Counterparties.counterparties.vend.createCounterparty(
|
||||
counterpartyId= counterpartyId,
|
||||
createdByUserId = createdByUserId,
|
||||
thisBankId = bankId,
|
||||
thisAccountId = accountId,
|
||||
|
||||
@ -15,7 +15,7 @@ trait TestConnectorSetup {
|
||||
protected def createTransaction(account : BankAccount, startDate : Date, finishDate : Date)
|
||||
protected def updateAccountCurrency(bankId: BankId, accountId : AccountId, currency : String) : BankAccount
|
||||
|
||||
protected def createCounterparty(bankId: String, accountId: String, accountRoutingAddress: String, otherAccountRoutingScheme: String, isBeneficiary: Boolean, counterpartyId: String, createdByUserId:String): CounterpartyTrait
|
||||
protected def createCounterparty(bankId: String, accountId: String, accountRoutingAddress: String, otherAccountRoutingScheme: String, isBeneficiary: Boolean, createdByUserId:String): CounterpartyTrait
|
||||
|
||||
/**
|
||||
* This method, will do three things:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user