From a8c95a0878c90acda11ebeb9def4316bc3ccad25 Mon Sep 17 00:00:00 2001 From: Guillaume Kergreis Date: Mon, 14 Sep 2020 16:18:11 +0200 Subject: [PATCH] feature/Add currency to a counterparty --- .../SwaggerDefinitionsJSON.scala | 65 +++- .../main/scala/code/api/util/NewStyle.scala | 2 + .../scala/code/api/v2_2_0/APIMethods220.scala | 1 + .../scala/code/api/v4_0_0/APIMethods400.scala | 325 +++++++++++++++++- .../code/api/v4_0_0/JSONFactory4.0.0.scala | 126 ++++++- .../scala/code/bankconnectors/Connector.scala | 1 + .../bankconnectors/KafkaMappedConnector.scala | 1 + .../KafkaMappedConnector_JVMcompatible.scala | 1 + .../bankconnectors/LocalMappedConnector.scala | 2 + .../akka/AkkaConnector_vDec2018.scala | 12 +- .../rest/RestConnector_vMar2019.scala | 14 +- .../StoredProcedureConnector_vDec2019.scala | 12 +- .../KafkaJsonFactory_vJune2017.scala | 1 + .../KafkaMappedConnector_vJune2017.scala | 5 +- .../vMar2017/KafkaJsonFactory_vMar2017.scala | 1 + .../KafkaJsonFactory_vSept2018.scala | 2 + .../KafkaMappedConnector_vSept2018.scala | 11 +- .../counterparties/Counterparties.scala | 2 + .../counterparties/MapperCounterparties.scala | 4 + .../counterparties/MongoCounterparties.scala | 1 + .../remotedata/RemotedataCounterparties.scala | 2 + .../RemotedataCounterpartiesActor.scala | 2 + .../code/api/v4_0_0/CounterpartyTest.scala | 28 +- .../RestConnector_vMar2019_frozen_meta_data | Bin 95422 -> 95462 bytes .../src/test/scala/code/kafka/KafkaTest.scala | 3 +- .../setup/LocalMappedConnectorTestSetup.scala | 1 + .../commons/dto/JsonsTransfer.scala | 2 +- .../commons/model/CommonModel.scala | 1 + .../commons/model/CounterpartyModel.scala | 1 + 29 files changed, 583 insertions(+), 46 deletions(-) diff --git a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala index 0f141e5e1..541de28d4 100644 --- a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala +++ b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala @@ -16,7 +16,7 @@ import code.api.v3_0_0.JSONFactory300.createBranchJsonV300 import code.api.v3_0_0.custom.JSONFactoryCustom300 import code.api.v3_0_0.{LobbyJsonV330, _} import code.api.v3_1_0.{AccountBalanceV310, AccountsBalancesV310Json, BadLoginStatusJson, ContactDetailsJson, CustomerWithAttributesJsonV310, InviteeJson, ObpApiLoopbackJson, PhysicalCardWithAttributesJsonV310, PutUpdateCustomerEmailJsonV310, _} -import code.api.v4_0_0.{APIInfoJson400, AccountTagJSON, AccountTagsJSON, AttributeDefinitionJsonV400, AttributeDefinitionResponseJsonV400, AttributeDefinitionsResponseJsonV400, BankJson400, BanksJson400, ChallengeJsonV400, CustomerAttributeJsonV400, CustomerAttributesResponseJson, DirectDebitJsonV400, EnergySource400, HostedAt400, HostedBy400, LogoutLinkJson, ModeratedAccountJSON400, ModeratedCoreAccountJsonV400, PostAccountAccessJsonV400, PostAccountTagJSON, PostCustomerPhoneNumberJsonV400, PostDirectDebitJsonV400, PostStandingOrderJsonV400, PostViewJsonV400, RefundJson, RevokedJsonV400, SettlementAccountJson, SettlementAccountRequestJson, SettlementAccountResponseJson, SettlementAccountsJson, StandingOrderJsonV400, TransactionAttributeJsonV400, TransactionAttributeResponseJson, TransactionAttributesResponseJson, TransactionRequestBodyRefundJsonV400, TransactionRequestBodySEPAJsonV400, TransactionRequestReasonJsonV400, TransactionRequestWithChargeJSON400, UserLockStatusJson, When} +import code.api.v4_0_0.{APIInfoJson400, AccountTagJSON, AccountTagsJSON, AttributeDefinitionJsonV400, AttributeDefinitionResponseJsonV400, AttributeDefinitionsResponseJsonV400, BankJson400, BanksJson400, ChallengeJsonV400, CounterpartiesJson400, CounterpartyJson400, CounterpartyWithMetadataJson400, CustomerAttributeJsonV400, CustomerAttributesResponseJson, DirectDebitJsonV400, EnergySource400, HostedAt400, HostedBy400, LogoutLinkJson, ModeratedAccountJSON400, ModeratedCoreAccountJsonV400, PostAccountAccessJsonV400, PostAccountTagJSON, PostCustomerPhoneNumberJsonV400, PostDirectDebitJsonV400, PostStandingOrderJsonV400, PostViewJsonV400, RefundJson, RevokedJsonV400, SettlementAccountJson, SettlementAccountRequestJson, SettlementAccountResponseJson, SettlementAccountsJson, StandingOrderJsonV400, TransactionAttributeJsonV400, TransactionAttributeResponseJson, TransactionAttributesResponseJson, TransactionRequestBodyRefundJsonV400, TransactionRequestBodySEPAJsonV400, TransactionRequestReasonJsonV400, TransactionRequestWithChargeJSON400, UserLockStatusJson, When, PostCounterpartyJson400} import code.api.v3_1_0.{AccountBalanceV310, AccountsBalancesV310Json, BadLoginStatusJson, ContactDetailsJson, InviteeJson, ObpApiLoopbackJson, PhysicalCardWithAttributesJsonV310, PutUpdateCustomerEmailJsonV310, _} import code.branches.Branches.{Branch, DriveUpString, LobbyString} import code.consent.ConsentStatus @@ -2324,6 +2324,22 @@ object SwaggerDefinitionsJSON { bespoke = List(postCounterpartyBespokeJson) ) + val postCounterpartyJson400 = PostCounterpartyJson400( + name = "CounterpartyName", + description ="My landlord", + currency = currencyExample.value, + other_account_routing_scheme = counterpartyOtherAccountRoutingSchemeExample.value, + other_account_routing_address = counterpartyOtherAccountRoutingAddressExample.value, + other_account_secondary_routing_scheme = counterpartyOtherAccountSecondaryRoutingSchemeExample.value, + other_account_secondary_routing_address = counterpartyOtherAccountSecondaryRoutingAddressExample.value, + other_bank_routing_scheme = counterpartyOtherBankRoutingSchemeExample.value, + other_bank_routing_address = counterpartyOtherBankRoutingAddressExample.value, + other_branch_routing_scheme = counterpartyOtherBranchRoutingSchemeExample.value, + other_branch_routing_address = counterpartyOtherBranchRoutingAddressExample.value, + is_beneficiary = true, + bespoke = List(postCounterpartyBespokeJson) + ) + val metricsJson = MetricsJson( metrics = List(metricJson) ) @@ -2454,6 +2470,27 @@ object SwaggerDefinitionsJSON { other_account_secondary_routing_address= counterpartyOtherAccountSecondaryRoutingAddressExample.value, bespoke = postCounterpartyJSON.bespoke ) + + val counterpartyJson400 = CounterpartyJson400( + name = postCounterpartyJson400.name, + description = postCounterpartyJson400.description, + currency = postCounterpartyJson400.currency, + created_by_user_id = ExampleValue.userIdExample.value, + this_bank_id = bankIdExample.value, + this_account_id =accountIdExample.value, + this_view_id = SYSTEM_OWNER_VIEW_ID, + counterparty_id = counterpartyIdExample.value, + other_bank_routing_scheme = postCounterpartyJson400.other_bank_routing_scheme, + other_bank_routing_address = postCounterpartyJson400.other_bank_routing_address, + other_branch_routing_scheme = postCounterpartyJson400.other_branch_routing_scheme, + other_branch_routing_address = postCounterpartyJson400.other_branch_routing_address, + other_account_routing_scheme = postCounterpartyJson400.other_account_routing_scheme, + other_account_routing_address = postCounterpartyJson400.other_account_routing_address, + is_beneficiary = true, + other_account_secondary_routing_scheme = counterpartyOtherAccountSecondaryRoutingSchemeExample.value, + other_account_secondary_routing_address= counterpartyOtherAccountSecondaryRoutingAddressExample.value, + bespoke = postCounterpartyJson400.bespoke + ) val counterpartyMetadataJson = CounterpartyMetadataJson( public_alias = "String", @@ -2487,10 +2524,36 @@ object SwaggerDefinitionsJSON { metadata = counterpartyMetadataJson ) + val counterpartyWithMetadataJson400 = CounterpartyWithMetadataJson400( + name = postCounterpartyJson400.name, + description = postCounterpartyJson400.description, + currency = postCounterpartyJson400.currency, + created_by_user_id = ExampleValue.userIdExample.value, + this_bank_id = bankIdExample.value, + this_account_id =accountIdExample.value, + this_view_id = SYSTEM_OWNER_VIEW_ID, + counterparty_id = counterpartyIdExample.value, + other_bank_routing_scheme = postCounterpartyJson400.other_bank_routing_scheme, + other_bank_routing_address = postCounterpartyJson400.other_bank_routing_address, + other_branch_routing_scheme = postCounterpartyJson400.other_branch_routing_scheme, + other_branch_routing_address = postCounterpartyJson400.other_branch_routing_address, + other_account_routing_scheme = postCounterpartyJson400.other_account_routing_scheme, + other_account_routing_address = postCounterpartyJson400.other_account_routing_address, + is_beneficiary = true, + other_account_secondary_routing_scheme = counterpartyOtherAccountSecondaryRoutingSchemeExample.value, + other_account_secondary_routing_address= counterpartyOtherAccountSecondaryRoutingAddressExample.value, + bespoke = postCounterpartyJson400.bespoke, + metadata = counterpartyMetadataJson + ) + val counterpartiesJsonV220 = CounterpartiesJsonV220( counterparties = List(counterpartyJsonV220) ) + val counterpartiesJson400 = CounterpartiesJson400( + counterparties = List(counterpartyJson400) + ) + val bankJSONV220 = BankJSONV220( id = "gh.29.uk.x", full_name = "uk", diff --git a/obp-api/src/main/scala/code/api/util/NewStyle.scala b/obp-api/src/main/scala/code/api/util/NewStyle.scala index 4299b3fc9..82ca4c358 100644 --- a/obp-api/src/main/scala/code/api/util/NewStyle.scala +++ b/obp-api/src/main/scala/code/api/util/NewStyle.scala @@ -2275,6 +2275,7 @@ object NewStyle { def createCounterparty( name: String, description: String, + currency: String, createdByUserId: String, thisBankId: String, thisAccountId: String, @@ -2294,6 +2295,7 @@ object NewStyle { unboxFullOrFail(Connector.connector.vend.createCounterparty( name: String, description: String, + currency: String, createdByUserId: String, thisBankId: String, thisAccountId: String, diff --git a/obp-api/src/main/scala/code/api/v2_2_0/APIMethods220.scala b/obp-api/src/main/scala/code/api/v2_2_0/APIMethods220.scala index 815133ec1..93d5ffdfc 100644 --- a/obp-api/src/main/scala/code/api/v2_2_0/APIMethods220.scala +++ b/obp-api/src/main/scala/code/api/v2_2_0/APIMethods220.scala @@ -1151,6 +1151,7 @@ trait APIMethods220 { (counterparty, callContext) <- NewStyle.function.createCounterparty( name=postJson.name, description=postJson.description, + currency = "", createdByUserId=u.userId, thisBankId=bankId.value, thisAccountId=accountId.value, diff --git a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala index 802292b14..753c04b11 100644 --- a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala +++ b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala @@ -45,6 +45,7 @@ import code.transactionrequests.TransactionRequests.TransactionRequestTypes.{app import code.userlocks.UserLocksProvider import code.users.Users import code.util.Helper +import code.util.Helper.booleanToFuture import com.openbankproject.commons.util.JsonUtils import code.views.Views import com.github.dwickern.macros.NameOf.nameOf @@ -4206,13 +4207,13 @@ trait APIMethods400 { } staticResourceDocs += ResourceDoc( - createCounterpartyForAnyAccount, + createCounterparty, implementedInApiVersion, - "createCounterpartyForAnyAccount", + "createCounterparty", "POST", - "/management/banks/BANK_ID/accounts/ACCOUNT_ID/VIEW_ID/counterparties", - "Create Counterparty for any account (Explicit)", - s"""Create Counterparty for any Account. (Explicit) + "/banks/BANK_ID/accounts/ACCOUNT_ID/VIEW_ID/counterparties", + "Create Counterparty (Explicit)", + s"""Create Counterparty (Explicit) for an Account. | |In OBP, there are two types of Counterparty. | @@ -4227,6 +4228,8 @@ trait APIMethods400 { | |description : the human readable name (e.g. Piano teacher, Miss Nipa) | + |currency : counterparty account currency (e.g. EUR, GBP, USD, ...) + | |bank_routing_scheme : eg: bankId or bankCode or any other strings | |bank_routing_address : eg: `gh.29.uk`, must be valid sandbox bankIds @@ -4257,6 +4260,7 @@ trait APIMethods400 { | { | "name": "Tesobe1", | "description": "Good Company", + | "currency": "EUR", | "other_bank_routing_scheme": "OBP", | "other_bank_routing_address": "gh.29.uk", | "other_account_routing_scheme": "OBP", @@ -4275,6 +4279,7 @@ trait APIMethods400 { | { | "name": "Tesobe2", | "description": "Good Company", + | "currency": "EUR", | "other_bank_routing_scheme": "OBP", | "other_bank_routing_address": "gh.29.uk", | "other_account_routing_scheme": "OBP", @@ -4290,8 +4295,8 @@ trait APIMethods400 { |${authenticationRequiredMessage(true)} | |""".stripMargin, - postCounterpartyJSON, - counterpartyWithMetadataJson, + postCounterpartyJson400, + counterpartyWithMetadataJson400, List( UserNotLoggedIn, InvalidAccountIdFormat, @@ -4299,25 +4304,30 @@ trait APIMethods400 { BankNotFound, AccountNotFound, InvalidJsonFormat, + InvalidISOCurrencyCode, ViewNotFound, CounterpartyAlreadyExists, UnknownError ), Catalogs(notCore, notPSD2, notOBWG), - List(apiTagCounterparty, apiTagAccount), - Some(List(canCreateCounterpartyAtBank))) + List(apiTagCounterparty, apiTagAccount)) - lazy val createCounterpartyForAnyAccount: OBPEndpoint = { - case "management" :: "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId):: "counterparties" :: Nil JsonPost json -> _ => { + lazy val createCounterparty: OBPEndpoint = { + case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "counterparties" :: Nil JsonPost json -> _ => { cc => for { - (Full(u), callContext) <- authenticatedAccess(cc) - postJson <- NewStyle.function.tryons(InvalidJsonFormat, 400, cc.callContext) { - json.extract[PostCounterpartyJSON] + (Full(u), callContext) <- authenticatedAccess(cc) + _ <- Helper.booleanToFuture(InvalidAccountIdFormat) {isValidID(accountId.value)} + _ <- Helper.booleanToFuture(InvalidBankIdFormat) {isValidID(bankId.value)} + (bank, callContext ) <- NewStyle.function.getBank(bankId, callContext) + (account, callContext) <- NewStyle.function.checkBankAccountExists(bankId, accountId, callContext) + postJson <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $PostCounterpartyJSON", 400, cc.callContext) { + json.extract[PostCounterpartyJson400] } - _ <- Helper.booleanToFuture(s"$InvalidValueLength. The maximum length of `description` field is ${MappedCounterparty.mDescription.maxLen}"){postJson.description.length <= 36} + view <- NewStyle.function.checkViewAccessAndReturnView(viewId, BankIdAccountId(bankId, accountId), Some(u), callContext) + _ <- Helper.booleanToFuture(s"$NoViewPermission can_add_counterparty. Please use a view with that permission or add the permission to this view.") {view.canAddCounterparty} (counterparty, callContext) <- Connector.connector.vend.checkCounterpartyExists(postJson.name, bankId.value, accountId.value, viewId.value, callContext) @@ -4325,6 +4335,12 @@ trait APIMethods400 { s"COUNTERPARTY_NAME(${postJson.name}) for the BANK_ID(${bankId.value}) and ACCOUNT_ID(${accountId.value}) and VIEW_ID($viewId)")){ counterparty.isEmpty } + _ <- booleanToFuture(s"$InvalidValueLength. The maximum length of `description` field is ${MappedCounterparty.mDescription.maxLen}"){ + postJson.description.length <= 36 + } + _ <- Helper.booleanToFuture(s"$InvalidISOCurrencyCode Current input is: '${postJson.currency}'") { + isValidCurrencyISOCode(postJson.currency) + } //If other_account_routing_scheme=="OBP" or other_account_secondary_routing_address=="OBP" we will check if it is a real obp bank account. (_, callContext)<- if (postJson.other_bank_routing_scheme == "OBP" && postJson.other_account_routing_scheme =="OBP"){ @@ -4350,6 +4366,186 @@ trait APIMethods400 { (counterparty, callContext) <- NewStyle.function.createCounterparty( name=postJson.name, description=postJson.description, + currency=postJson.currency, + createdByUserId=u.userId, + thisBankId=bankId.value, + thisAccountId=accountId.value, + thisViewId = viewId.value, + otherAccountRoutingScheme=postJson.other_account_routing_scheme, + otherAccountRoutingAddress=postJson.other_account_routing_address, + otherAccountSecondaryRoutingScheme=postJson.other_account_secondary_routing_scheme, + otherAccountSecondaryRoutingAddress=postJson.other_account_secondary_routing_address, + otherBankRoutingScheme=postJson.other_bank_routing_scheme, + otherBankRoutingAddress=postJson.other_bank_routing_address, + otherBranchRoutingScheme=postJson.other_branch_routing_scheme, + otherBranchRoutingAddress=postJson.other_branch_routing_address, + isBeneficiary=postJson.is_beneficiary, + bespoke=postJson.bespoke.map(bespoke =>CounterpartyBespoke(bespoke.key,bespoke.value)) + , callContext) + + (counterpartyMetadata, callContext) <- NewStyle.function.getOrCreateMetadata(bankId, accountId, counterparty.counterpartyId, postJson.name, callContext) + + } yield { + (JSONFactory400.createCounterpartyWithMetadataJson400(counterparty,counterpartyMetadata), HttpCode.`201`(callContext)) + } + } + } + + staticResourceDocs += ResourceDoc( + createCounterpartyForAnyAccount, + implementedInApiVersion, + "createCounterpartyForAnyAccount", + "POST", + "/management/banks/BANK_ID/accounts/ACCOUNT_ID/VIEW_ID/counterparties", + "Create Counterparty for any account (Explicit)", + s"""Create Counterparty for any Account. (Explicit) + | + |In OBP, there are two types of Counterparty. + | + |* Explicit Counterparties (those here) which we create explicitly and are used in COUNTERPARTY Transaction Requests + | + |* Implicit Counterparties (AKA Other Accounts) which are generated automatically from the other sides of Transactions. + | + |Explicit Counterparties are created for the account / view + |They are how the user of the view (e.g. account owner) refers to the other side of the transaction + | + |name : the human readable name (e.g. Piano teacher, Miss Nipa) + | + |description : the human readable name (e.g. Piano teacher, Miss Nipa) + | + |currency : counterparty account currency (e.g. EUR, GBP, USD, ...) + | + |bank_routing_scheme : eg: bankId or bankCode or any other strings + | + |bank_routing_address : eg: `gh.29.uk`, must be valid sandbox bankIds + | + |account_routing_scheme : eg: AccountId or AccountNumber or any other strings + | + |account_routing_address : eg: `1d65db7c-a7b2-4839-af41-95`, must be valid accountIds + | + |other_account_secondary_routing_scheme : eg: IBan or any other strings + | + |other_account_secondary_routing_address : if it is an IBAN, it should be unique for each counterparty. + | + |other_branch_routing_scheme : eg: branchId or any other strings or you can leave it empty, not useful in sandbox mode. + | + |other_branch_routing_address : eg: `branch-id-123` or you can leave it empty, not useful in sandbox mode. + | + |is_beneficiary : must be set to `true` in order to send payments to this counterparty + | + |bespoke: It supports a list of key-value, you can add it to the counterparty. + | + |bespoke.key : any info-key you want to add to this counterparty + | + |bespoke.value : any info-value you want to add to this counterparty + | + |The view specified by VIEW_ID must have the canAddCounterparty permission + | + |A minimal example for TransactionRequestType == COUNTERPARTY + | { + | "name": "Tesobe1", + | "description": "Good Company", + | "currency": "EUR", + | "other_bank_routing_scheme": "OBP", + | "other_bank_routing_address": "gh.29.uk", + | "other_account_routing_scheme": "OBP", + | "other_account_routing_address": "8ca8a7e4-6d02-48e3-a029-0b2bf89de9f0", + | "is_beneficiary": true, + | "other_account_secondary_routing_scheme": "", + | "other_account_secondary_routing_address": "", + | "other_branch_routing_scheme": "", + | "other_branch_routing_address": "", + | "bespoke": [] + |} + | + | + |A minimal example for TransactionRequestType == SEPA + | + | { + | "name": "Tesobe2", + | "description": "Good Company", + | "currency": "EUR", + | "other_bank_routing_scheme": "OBP", + | "other_bank_routing_address": "gh.29.uk", + | "other_account_routing_scheme": "OBP", + | "other_account_routing_address": "8ca8a7e4-6d02-48e3-a029-0b2bf89de9f0", + | "other_account_secondary_routing_scheme": "IBAN", + | "other_account_secondary_routing_address": "DE89 3704 0044 0532 0130 00", + | "is_beneficiary": true, + | "other_branch_routing_scheme": "", + | "other_branch_routing_address": "", + | "bespoke": [] + |} + | + |${authenticationRequiredMessage(true)} + | + |""".stripMargin, + postCounterpartyJson400, + counterpartyWithMetadataJson400, + List( + UserNotLoggedIn, + InvalidAccountIdFormat, + InvalidBankIdFormat, + BankNotFound, + AccountNotFound, + InvalidJsonFormat, + InvalidISOCurrencyCode, + ViewNotFound, + CounterpartyAlreadyExists, + UnknownError + ), + Catalogs(notCore, notPSD2, notOBWG), + List(apiTagCounterparty, apiTagAccount), + Some(List(canCreateCounterpartyAtBank))) + + + lazy val createCounterpartyForAnyAccount: OBPEndpoint = { + case "management" :: "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId):: "counterparties" :: Nil JsonPost json -> _ => { + cc => + for { + (Full(u), callContext) <- authenticatedAccess(cc) + postJson <- NewStyle.function.tryons(InvalidJsonFormat, 400, cc.callContext) { + json.extract[PostCounterpartyJson400] + } + _ <- Helper.booleanToFuture(s"$InvalidValueLength. The maximum length of `description` field is ${MappedCounterparty.mDescription.maxLen}"){postJson.description.length <= 36} + + + (counterparty, callContext) <- Connector.connector.vend.checkCounterpartyExists(postJson.name, bankId.value, accountId.value, viewId.value, callContext) + + _ <- Helper.booleanToFuture(CounterpartyAlreadyExists.replace("value for BANK_ID or ACCOUNT_ID or VIEW_ID or NAME.", + s"COUNTERPARTY_NAME(${postJson.name}) for the BANK_ID(${bankId.value}) and ACCOUNT_ID(${accountId.value}) and VIEW_ID($viewId)")){ + counterparty.isEmpty + } + + _ <- Helper.booleanToFuture(s"$InvalidISOCurrencyCode Current input is: '${postJson.currency}'") { + isValidCurrencyISOCode(postJson.currency) + } + + //If other_account_routing_scheme=="OBP" or other_account_secondary_routing_address=="OBP" we will check if it is a real obp bank account. + (_, callContext)<- if (postJson.other_bank_routing_scheme == "OBP" && postJson.other_account_routing_scheme =="OBP"){ + for{ + (_, callContext) <- NewStyle.function.getBank(BankId(postJson.other_bank_routing_address), Some(cc)) + (account, callContext) <- NewStyle.function.checkBankAccountExists(BankId(postJson.other_bank_routing_address), AccountId(postJson.other_account_routing_address), callContext) + + } yield { + (account, callContext) + } + } else if (postJson.other_bank_routing_scheme == "OBP" && postJson.other_account_secondary_routing_scheme=="OBP"){ + for{ + (_, callContext) <- NewStyle.function.getBank(BankId(postJson.other_bank_routing_address), Some(cc)) + (account, callContext) <- NewStyle.function.checkBankAccountExists(BankId(postJson.other_bank_routing_address), AccountId(postJson.other_account_secondary_routing_address), callContext) + + } yield { + (account, callContext) + } + } + else + Future{(Full(), Some(cc))} + + (counterparty, callContext) <- NewStyle.function.createCounterparty( + name=postJson.name, + description=postJson.description, + currency=postJson.currency, createdByUserId=u.userId, thisBankId=bankId.value, thisAccountId=accountId.value, @@ -4369,7 +4565,100 @@ trait APIMethods400 { (counterpartyMetadata, callContext) <- NewStyle.function.getOrCreateMetadata(bankId, accountId, counterparty.counterpartyId, postJson.name, callContext) } yield { - (JSONFactory220.createCounterpartyWithMetadataJSON(counterparty,counterpartyMetadata), HttpCode.`201`(callContext)) + (JSONFactory400.createCounterpartyWithMetadataJson400(counterparty,counterpartyMetadata), HttpCode.`201`(callContext)) + } + } + } + + staticResourceDocs += ResourceDoc( + getExplictCounterpartiesForAccount, + implementedInApiVersion, + "getExplictCounterpartiesForAccount", + "GET", + "/banks/BANK_ID/accounts/ACCOUNT_ID/VIEW_ID/counterparties", + "Get Counterparties (Explicit)", + s"""Get the Counterparties (Explicit) for the account / view. + | + |${authenticationRequiredMessage(true)} + |""".stripMargin, + emptyObjectJson, + counterpartiesJson400, + List( + UserNotLoggedIn, + BankAccountNotFound, + ViewNotFound, + NoViewPermission, + UserNoPermissionAccessView, + UnknownError + ), + Catalogs(Core, PSD2, OBWG), + List(apiTagCounterparty, apiTagPSD2PIS, apiTagAccount)) + + lazy val getExplictCounterpartiesForAccount : OBPEndpoint = { + case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "counterparties" :: Nil JsonGet req => { + cc => + for { + (Full(u), callContext) <- authenticatedAccess(cc) + (account, callContext) <- NewStyle.function.checkBankAccountExists(bankId, accountId, callContext) + view <- NewStyle.function.checkViewAccessAndReturnView(viewId, BankIdAccountId(account.bankId, account.accountId), Some(u), callContext) + _ <- Helper.booleanToFuture(failMsg = s"${NoViewPermission}canAddCounterparty") { + view.canAddCounterparty == true + } + (counterparties, callContext) <- NewStyle.function.getCounterparties(bankId,accountId,viewId, callContext) + //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. + _ <- Helper.booleanToFuture(CreateOrUpdateCounterpartyMetadataError, 400) { + { + for { + counterparty <- counterparties + } yield { + Counterparties.counterparties.vend.getOrCreateMetadata(bankId, accountId, counterparty.counterpartyId, counterparty.name) match { + case Full(_) => true + case _ => false + } + } + }.forall(_ == true) + } + } yield { + val counterpartiesJson = JSONFactory400.createCounterpartiesJson400(counterparties) + (counterpartiesJson, HttpCode.`200`(callContext)) + } + } + } + + staticResourceDocs += ResourceDoc( + getExplictCounterpartyById, + implementedInApiVersion, + "getExplictCounterpartyById", + "GET", + "/banks/BANK_ID/accounts/ACCOUNT_ID/VIEW_ID/counterparties/COUNTERPARTY_ID", + "Get Counterparty by Counterparty Id (Explicit)", + s"""Information returned about the Counterparty specified by COUNTERPARTY_ID: + | + |${authenticationRequiredMessage(true)} + |""".stripMargin, + emptyObjectJson, + counterpartyWithMetadataJson400, + List(UserNotLoggedIn, BankNotFound, UnknownError), + Catalogs(Core, PSD2, OBWG), + List(apiTagCounterparty, apiTagPSD2PIS, apiTagCounterpartyMetaData) + ) + + lazy val getExplictCounterpartyById : OBPEndpoint = { + case "banks" :: BankId(bankId) :: "accounts" :: AccountId(accountId) :: ViewId(viewId) :: "counterparties" :: CounterpartyId(counterpartyId) :: Nil JsonGet req => { + cc => + for { + (Full(u), callContext) <- authenticatedAccess(cc) + (account, callContext) <- NewStyle.function.checkBankAccountExists(bankId, accountId, callContext) + view <- NewStyle.function.checkViewAccessAndReturnView(viewId, BankIdAccountId(account.bankId, account.accountId), Some(u), callContext) + _ <- Helper.booleanToFuture(failMsg = s"${NoViewPermission}canAddCounterparty") { + view.canAddCounterparty == true + } + counterpartyMetadata <- NewStyle.function.getMetadata(bankId, accountId, counterpartyId.value, callContext) + (counterparty, callContext) <- NewStyle.function.getCounterpartyTrait(bankId, accountId, counterpartyId.value, callContext) + } yield { + val counterpartyJson = JSONFactory400.createCounterpartyWithMetadataJson400(counterparty,counterpartyMetadata) + (counterpartyJson, HttpCode.`200`(callContext)) } } } @@ -4387,7 +4676,7 @@ trait APIMethods400 { | |""".stripMargin, emptyObjectJson, - counterpartyWithMetadataJson, + counterpartyWithMetadataJson400, List( UserNotLoggedIn, InvalidAccountIdFormat, @@ -4419,7 +4708,7 @@ trait APIMethods400 { (counterpartyMetadata, callContext) <- NewStyle.function.getOrCreateMetadata(bankId, accountId, counterparty.counterpartyId, counterparty.name, callContext) } yield { - (JSONFactory220.createCounterpartyWithMetadataJSON(counterparty,counterpartyMetadata), HttpCode.`200`(callContext)) + (JSONFactory400.createCounterpartyWithMetadataJson400(counterparty,counterpartyMetadata), HttpCode.`200`(callContext)) } } } diff --git a/obp-api/src/main/scala/code/api/v4_0_0/JSONFactory4.0.0.scala b/obp-api/src/main/scala/code/api/v4_0_0/JSONFactory4.0.0.scala index 203889d2e..a7223d2b0 100644 --- a/obp-api/src/main/scala/code/api/v4_0_0/JSONFactory4.0.0.scala +++ b/obp-api/src/main/scala/code/api/v4_0_0/JSONFactory4.0.0.scala @@ -35,7 +35,8 @@ import code.api.v1_2_1.JSONFactory.{createAmountOfMoneyJSON, createOwnersJSON} import code.api.v1_2_1.{BankRoutingJsonV121, JSONFactory, UserJSONV121, ViewJSONV121} import code.api.v1_4_0.JSONFactory1_4_0.TransactionRequestAccountJsonV140 import code.api.v2_0_0.TransactionRequestChargeJsonV200 -import code.api.v2_1_0.{IbanJson, ResourceUserJSON} +import code.api.v2_1_0.{IbanJson, JSONFactory210, PostCounterpartyBespokeJson, ResourceUserJSON} +import code.api.v2_2_0.CounterpartyMetadataJson import code.api.v3_0_0.JSONFactory300.createAccountRoutingsJSON import code.api.v3_0_0.{CustomerAttributeResponseJsonV300, ViewBasicV300} import code.api.v3_1_0.AccountAttributeResponseJson @@ -360,6 +361,70 @@ case class SettlementAccountsJson( settlement_accounts: List[SettlementAccountJson] ) +case class CounterpartyWithMetadataJson400( + name: String, + description: String, + currency: 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[PostCounterpartyBespokeJson], + metadata: CounterpartyMetadataJson + ) + +case class PostCounterpartyJson400( + name: String, + description: String, + currency: String, + other_account_routing_scheme: String, + other_account_routing_address: String, + other_account_secondary_routing_scheme: String, + other_account_secondary_routing_address: String, + other_bank_routing_scheme: String, + other_bank_routing_address: String, + other_branch_routing_scheme: String, + other_branch_routing_address: String, + is_beneficiary: Boolean, + bespoke: List[PostCounterpartyBespokeJson] + ) + +case class CounterpartyJson400( + name: String, + description: String, + currency: 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[PostCounterpartyBespokeJson] + ) + +case class CounterpartiesJson400( + counterparties: List[CounterpartyJson400] + ) + + object JSONFactory400 { def createBankJSON400(bank: Bank): BankJson400 = { val obp = BankRoutingJsonV121("OBP", bank.bankId.value) @@ -649,6 +714,65 @@ object JSONFactory400 { userLock.typeOfLock, userLock.lastLockDate) } + + def createCounterpartyWithMetadataJson400(counterparty: CounterpartyTrait, counterpartyMetadata: CounterpartyMetadata): CounterpartyWithMetadataJson400 = { + CounterpartyWithMetadataJson400( + name = counterparty.name, + description = counterparty.description, + currency = counterparty.currency, + created_by_user_id = counterparty.createdByUserId, + this_bank_id = counterparty.thisBankId, + this_account_id = counterparty.thisAccountId, + this_view_id = counterparty.thisViewId, + counterparty_id = counterparty.counterpartyId, + other_bank_routing_scheme = counterparty.otherBankRoutingScheme, + other_bank_routing_address = counterparty.otherBankRoutingAddress, + other_account_routing_scheme = counterparty.otherAccountRoutingScheme, + other_account_routing_address = counterparty.otherAccountRoutingAddress, + other_account_secondary_routing_scheme = counterparty.otherAccountSecondaryRoutingScheme, + other_account_secondary_routing_address = counterparty.otherAccountSecondaryRoutingAddress, + other_branch_routing_scheme = counterparty.otherBranchRoutingScheme, + other_branch_routing_address =counterparty.otherBranchRoutingAddress, + is_beneficiary = counterparty.isBeneficiary, + bespoke = counterparty.bespoke.map(bespoke =>PostCounterpartyBespokeJson(bespoke.key,bespoke.value)), + metadata=CounterpartyMetadataJson( + public_alias = counterpartyMetadata.getPublicAlias, + more_info = counterpartyMetadata.getMoreInfo, + url = counterpartyMetadata.getUrl, + image_url = counterpartyMetadata.getImageURL, + open_corporates_url = counterpartyMetadata.getOpenCorporatesURL, + corporate_location = JSONFactory210.createLocationJSON(counterpartyMetadata.getCorporateLocation), + physical_location = JSONFactory210.createLocationJSON(counterpartyMetadata.getPhysicalLocation), + private_alias = counterpartyMetadata.getPrivateAlias + ) + ) + } + + def createCounterpartyJson400(counterparty: CounterpartyTrait): CounterpartyJson400 = { + CounterpartyJson400( + name = counterparty.name, + description = counterparty.description, + currency = counterparty.currency, + created_by_user_id = counterparty.createdByUserId, + this_bank_id = counterparty.thisBankId, + this_account_id = counterparty.thisAccountId, + this_view_id = counterparty.thisViewId, + counterparty_id = counterparty.counterpartyId, + other_bank_routing_scheme = counterparty.otherBankRoutingScheme, + other_bank_routing_address = counterparty.otherBankRoutingAddress, + other_account_routing_scheme = counterparty.otherAccountRoutingScheme, + other_account_routing_address = counterparty.otherAccountRoutingAddress, + other_account_secondary_routing_scheme = counterparty.otherAccountSecondaryRoutingScheme, + other_account_secondary_routing_address = counterparty.otherAccountSecondaryRoutingAddress, + other_branch_routing_scheme = counterparty.otherBranchRoutingScheme, + other_branch_routing_address =counterparty.otherBranchRoutingAddress, + is_beneficiary = counterparty.isBeneficiary, + bespoke = counterparty.bespoke.map(bespoke =>PostCounterpartyBespokeJson(bespoke.key,bespoke.value)) + ) + } + + def createCounterpartiesJson400(counterparties: List[CounterpartyTrait]): CounterpartiesJson400 = + CounterpartiesJson400(counterparties.map(createCounterpartyJson400)) } diff --git a/obp-api/src/main/scala/code/bankconnectors/Connector.scala b/obp-api/src/main/scala/code/bankconnectors/Connector.scala index f969e238c..fe098f54d 100644 --- a/obp-api/src/main/scala/code/bankconnectors/Connector.scala +++ b/obp-api/src/main/scala/code/bankconnectors/Connector.scala @@ -1720,6 +1720,7 @@ trait Connector extends MdcLoggable { def createCounterparty( name: String, description: String, + currency: String, createdByUserId: String, thisBankId: String, thisAccountId: String, diff --git a/obp-api/src/main/scala/code/bankconnectors/KafkaMappedConnector.scala b/obp-api/src/main/scala/code/bankconnectors/KafkaMappedConnector.scala index 3b329a88d..9186bcddb 100644 --- a/obp-api/src/main/scala/code/bankconnectors/KafkaMappedConnector.scala +++ b/obp-api/src/main/scala/code/bankconnectors/KafkaMappedConnector.scala @@ -1161,6 +1161,7 @@ object KafkaMappedConnector extends Connector with KafkaHelper with MdcLoggable def otherBranchRoutingAddress: String = counterparty.other_branch_routing_address def isBeneficiary : Boolean = counterparty.is_beneficiary def description: String = "" + def currency: String = "" def otherAccountSecondaryRoutingScheme: String = "" def otherAccountSecondaryRoutingAddress: String = "" def bespoke: List[CounterpartyBespoke] = Nil diff --git a/obp-api/src/main/scala/code/bankconnectors/KafkaMappedConnector_JVMcompatible.scala b/obp-api/src/main/scala/code/bankconnectors/KafkaMappedConnector_JVMcompatible.scala index 3fd3592be..041511a73 100644 --- a/obp-api/src/main/scala/code/bankconnectors/KafkaMappedConnector_JVMcompatible.scala +++ b/obp-api/src/main/scala/code/bankconnectors/KafkaMappedConnector_JVMcompatible.scala @@ -1334,6 +1334,7 @@ object KafkaMappedConnector_JVMcompatible extends Connector with KafkaHelper wit def otherBranchRoutingAddress: String = counterparty.other_branch_routing_address def isBeneficiary : Boolean = counterparty.is_beneficiary def description: String = "" + def currency: String = "" def otherAccountSecondaryRoutingScheme: String = "" def otherAccountSecondaryRoutingAddress: String = "" def bespoke: List[CounterpartyBespoke] = Nil diff --git a/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala b/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala index 3c62e373e..161046f50 100644 --- a/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala +++ b/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala @@ -2585,6 +2585,7 @@ object LocalMappedConnector extends Connector with MdcLoggable { override def createCounterparty( name: String, description: String, + currency: String, createdByUserId: String, thisBankId: String, thisAccountId: String, @@ -2616,6 +2617,7 @@ object LocalMappedConnector extends Connector with MdcLoggable { otherAccountSecondaryRoutingScheme = otherAccountSecondaryRoutingScheme, otherAccountSecondaryRoutingAddress = otherAccountSecondaryRoutingAddress, description = description, + currency = currency, bespoke = bespoke ).map(counterparty => (counterparty, callContext)) diff --git a/obp-api/src/main/scala/code/bankconnectors/akka/AkkaConnector_vDec2018.scala b/obp-api/src/main/scala/code/bankconnectors/akka/AkkaConnector_vDec2018.scala index c6ddf0cbc..10d93a8de 100644 --- a/obp-api/src/main/scala/code/bankconnectors/akka/AkkaConnector_vDec2018.scala +++ b/obp-api/src/main/scala/code/bankconnectors/akka/AkkaConnector_vDec2018.scala @@ -740,6 +740,7 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit { data= CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -783,6 +784,7 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit { data= CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -826,6 +828,7 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit { data= CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -871,6 +874,7 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit { data=List( CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -2450,6 +2454,7 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit { toCounterparty= CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -2535,6 +2540,7 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit { toCounterparty= CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -2648,6 +2654,7 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit { OutBoundCreateCounterparty(outboundAdapterCallContext=MessageDocsSwaggerDefinitions.outboundAdapterCallContext, name="string", description="string", + currency=currencyExample.value, createdByUserId="string", thisBankId="string", thisAccountId="string", @@ -2670,6 +2677,7 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit { data= CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -2689,9 +2697,9 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit { adapterImplementation = Some(AdapterImplementation("- Core", 1)) ) - override def createCounterparty(name: String, description: String, createdByUserId: String, thisBankId: String, thisAccountId: String, thisViewId: String, otherAccountRoutingScheme: String, otherAccountRoutingAddress: String, otherAccountSecondaryRoutingScheme: String, otherAccountSecondaryRoutingAddress: String, otherBankRoutingScheme: String, otherBankRoutingAddress: String, otherBranchRoutingScheme: String, otherBranchRoutingAddress: String, isBeneficiary: Boolean, bespoke: List[CounterpartyBespoke], callContext: Option[CallContext]): Box[(CounterpartyTrait, Option[CallContext])] = { + override def createCounterparty(name: String, description: String, currency: String, createdByUserId: String, thisBankId: String, thisAccountId: String, thisViewId: String, otherAccountRoutingScheme: String, otherAccountRoutingAddress: String, otherAccountSecondaryRoutingScheme: String, otherAccountSecondaryRoutingAddress: String, otherBankRoutingScheme: String, otherBankRoutingAddress: String, otherBranchRoutingScheme: String, otherBranchRoutingAddress: String, isBeneficiary: Boolean, bespoke: List[CounterpartyBespoke], callContext: Option[CallContext]): Box[(CounterpartyTrait, Option[CallContext])] = { import com.openbankproject.commons.dto.{OutBoundCreateCounterparty => OutBound, InBoundCreateCounterparty => InBound} - val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, name, description, createdByUserId, thisBankId, thisAccountId, thisViewId, otherAccountRoutingScheme, otherAccountRoutingAddress, otherAccountSecondaryRoutingScheme, otherAccountSecondaryRoutingAddress, otherBankRoutingScheme, otherBankRoutingAddress, otherBranchRoutingScheme, otherBranchRoutingAddress, isBeneficiary, bespoke) + val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, name, description, currency, createdByUserId, thisBankId, thisAccountId, thisViewId, otherAccountRoutingScheme, otherAccountRoutingAddress, otherAccountSecondaryRoutingScheme, otherAccountSecondaryRoutingAddress, otherBankRoutingScheme, otherBankRoutingAddress, otherBranchRoutingScheme, otherBranchRoutingAddress, isBeneficiary, bespoke) val response: Future[Box[InBound]] = (southSideActor ? req).mapTo[InBound].recoverWith(recoverFunction).map(Box !! _) response.map(convertToTuple[CounterpartyTraitCommons](callContext)) } diff --git a/obp-api/src/main/scala/code/bankconnectors/rest/RestConnector_vMar2019.scala b/obp-api/src/main/scala/code/bankconnectors/rest/RestConnector_vMar2019.scala index 2b407d495..cee41fa31 100644 --- a/obp-api/src/main/scala/code/bankconnectors/rest/RestConnector_vMar2019.scala +++ b/obp-api/src/main/scala/code/bankconnectors/rest/RestConnector_vMar2019.scala @@ -1663,6 +1663,7 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable data= CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -1739,6 +1740,7 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable data= CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -1815,6 +1817,7 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable data= CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -1891,6 +1894,7 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable data= CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -1969,6 +1973,7 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable data=List( CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -2047,6 +2052,7 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable data=List( CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -4724,6 +4730,7 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable toCounterparty= CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -4842,6 +4849,7 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable toCounterparty= CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -4988,6 +4996,7 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable name=usernameExample.value))))))))), name="string", description="string", + currency=currencyExample.value, createdByUserId="string", thisBankId="string", thisAccountId="string", @@ -5017,6 +5026,7 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable data= CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -5036,10 +5046,10 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable adapterImplementation = Some(AdapterImplementation("- Core", 1)) ) // url example: /createCounterparty - override def createCounterparty(name: String, description: String, createdByUserId: String, thisBankId: String, thisAccountId: String, thisViewId: String, otherAccountRoutingScheme: String, otherAccountRoutingAddress: String, otherAccountSecondaryRoutingScheme: String, otherAccountSecondaryRoutingAddress: String, otherBankRoutingScheme: String, otherBankRoutingAddress: String, otherBranchRoutingScheme: String, otherBranchRoutingAddress: String, isBeneficiary: Boolean, bespoke: List[CounterpartyBespoke], callContext: Option[CallContext]): Box[(CounterpartyTrait, Option[CallContext])] = { + override def createCounterparty(name: String, description: String, currency: String, createdByUserId: String, thisBankId: String, thisAccountId: String, thisViewId: String, otherAccountRoutingScheme: String, otherAccountRoutingAddress: String, otherAccountSecondaryRoutingScheme: String, otherAccountSecondaryRoutingAddress: String, otherBankRoutingScheme: String, otherBankRoutingAddress: String, otherBranchRoutingScheme: String, otherBranchRoutingAddress: String, isBeneficiary: Boolean, bespoke: List[CounterpartyBespoke], callContext: Option[CallContext]): Box[(CounterpartyTrait, Option[CallContext])] = { import com.openbankproject.commons.dto.{OutBoundCreateCounterparty => OutBound, InBoundCreateCounterparty => InBound} val url = getUrl(callContext, "createCounterparty") - val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull , name, description, createdByUserId, thisBankId, thisAccountId, thisViewId, otherAccountRoutingScheme, otherAccountRoutingAddress, otherAccountSecondaryRoutingScheme, otherAccountSecondaryRoutingAddress, otherBankRoutingScheme, otherBankRoutingAddress, otherBranchRoutingScheme, otherBranchRoutingAddress, isBeneficiary, bespoke) + val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull , name, description, currency, createdByUserId, thisBankId, thisAccountId, thisViewId, otherAccountRoutingScheme, otherAccountRoutingAddress, otherAccountSecondaryRoutingScheme, otherAccountSecondaryRoutingAddress, otherBankRoutingScheme, otherBankRoutingAddress, otherBranchRoutingScheme, otherBranchRoutingAddress, isBeneficiary, bespoke) val result: OBPReturnType[Box[CounterpartyTraitCommons]] = sendRequest[InBound](url, HttpMethods.POST, req, callContext).map(convertToTuple(callContext)) result } diff --git a/obp-api/src/main/scala/code/bankconnectors/storedprocedure/StoredProcedureConnector_vDec2019.scala b/obp-api/src/main/scala/code/bankconnectors/storedprocedure/StoredProcedureConnector_vDec2019.scala index 7ce5aee53..bf491f6b7 100644 --- a/obp-api/src/main/scala/code/bankconnectors/storedprocedure/StoredProcedureConnector_vDec2019.scala +++ b/obp-api/src/main/scala/code/bankconnectors/storedprocedure/StoredProcedureConnector_vDec2019.scala @@ -887,6 +887,7 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable { data= CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -930,6 +931,7 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable { data= CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -973,6 +975,7 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable { data= CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -1018,6 +1021,7 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable { data=List( CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -3101,6 +3105,7 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable { toCounterparty= CounterpartyTraitCommons(createdByUserId="string", name=counterpartyNameExample.value, description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -3192,6 +3197,7 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable { toCounterparty= CounterpartyTraitCommons(createdByUserId="string", name=counterpartyNameExample.value, description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -3401,6 +3407,7 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable { OutBoundCreateCounterparty(outboundAdapterCallContext=MessageDocsSwaggerDefinitions.outboundAdapterCallContext, name="string", description="string", + currency=currencyExample.value, createdByUserId="string", thisBankId="string", thisAccountId="string", @@ -3423,6 +3430,7 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable { data= CounterpartyTraitCommons(createdByUserId="string", name="string", description="string", + currency=currencyExample.value, thisBankId="string", thisAccountId="string", thisViewId="string", @@ -3442,9 +3450,9 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable { adapterImplementation = Some(AdapterImplementation("- Core", 1)) ) - override def createCounterparty(name: String, description: String, createdByUserId: String, thisBankId: String, thisAccountId: String, thisViewId: String, otherAccountRoutingScheme: String, otherAccountRoutingAddress: String, otherAccountSecondaryRoutingScheme: String, otherAccountSecondaryRoutingAddress: String, otherBankRoutingScheme: String, otherBankRoutingAddress: String, otherBranchRoutingScheme: String, otherBranchRoutingAddress: String, isBeneficiary: Boolean, bespoke: List[CounterpartyBespoke], callContext: Option[CallContext]): Box[(CounterpartyTrait, Option[CallContext])] = { + override def createCounterparty(name: String, description: String, currency: String, createdByUserId: String, thisBankId: String, thisAccountId: String, thisViewId: String, otherAccountRoutingScheme: String, otherAccountRoutingAddress: String, otherAccountSecondaryRoutingScheme: String, otherAccountSecondaryRoutingAddress: String, otherBankRoutingScheme: String, otherBankRoutingAddress: String, otherBranchRoutingScheme: String, otherBranchRoutingAddress: String, isBeneficiary: Boolean, bespoke: List[CounterpartyBespoke], callContext: Option[CallContext]): Box[(CounterpartyTrait, Option[CallContext])] = { import com.openbankproject.commons.dto.{InBoundCreateCounterparty => InBound, OutBoundCreateCounterparty => OutBound} - val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, name, description, createdByUserId, thisBankId, thisAccountId, thisViewId, otherAccountRoutingScheme, otherAccountRoutingAddress, otherAccountSecondaryRoutingScheme, otherAccountSecondaryRoutingAddress, otherBankRoutingScheme, otherBankRoutingAddress, otherBranchRoutingScheme, otherBranchRoutingAddress, isBeneficiary, bespoke) + val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, name, description, currency, createdByUserId, thisBankId, thisAccountId, thisViewId, otherAccountRoutingScheme, otherAccountRoutingAddress, otherAccountSecondaryRoutingScheme, otherAccountSecondaryRoutingAddress, otherBankRoutingScheme, otherBankRoutingAddress, otherBranchRoutingScheme, otherBranchRoutingAddress, isBeneficiary, bespoke) val response: Future[Box[InBound]] = sendRequest[InBound]("obp_create_counterparty", req, callContext) response.map(convertToTuple[CounterpartyTraitCommons](callContext)) } diff --git a/obp-api/src/main/scala/code/bankconnectors/vJune2017/KafkaJsonFactory_vJune2017.scala b/obp-api/src/main/scala/code/bankconnectors/vJune2017/KafkaJsonFactory_vJune2017.scala index 44b1a32b9..1c0fd6851 100644 --- a/obp-api/src/main/scala/code/bankconnectors/vJune2017/KafkaJsonFactory_vJune2017.scala +++ b/obp-api/src/main/scala/code/bankconnectors/vJune2017/KafkaJsonFactory_vJune2017.scala @@ -266,6 +266,7 @@ case class InternalCounterparty( otherBranchRoutingAddress: String, isBeneficiary: Boolean, description: String, + currency: String, otherAccountSecondaryRoutingScheme: String, otherAccountSecondaryRoutingAddress: String, bespoke: List[CounterpartyBespoke]) extends CounterpartyTrait diff --git a/obp-api/src/main/scala/code/bankconnectors/vJune2017/KafkaMappedConnector_vJune2017.scala b/obp-api/src/main/scala/code/bankconnectors/vJune2017/KafkaMappedConnector_vJune2017.scala index 60a239efe..306e876c1 100644 --- a/obp-api/src/main/scala/code/bankconnectors/vJune2017/KafkaMappedConnector_vJune2017.scala +++ b/obp-api/src/main/scala/code/bankconnectors/vJune2017/KafkaMappedConnector_vJune2017.scala @@ -1164,6 +1164,7 @@ trait KafkaMappedConnector_vJune2017 extends Connector with KafkaHelper with Mdc otherBranchRoutingAddress= "String", isBeneficiary = false, description= "String", + currency= "String", otherAccountSecondaryRoutingScheme= "String", otherAccountSecondaryRoutingAddress= "String", bespoke = List(CounterpartyBespoke( @@ -1175,6 +1176,7 @@ trait KafkaMappedConnector_vJune2017 extends Connector with KafkaHelper with Mdc override def createCounterparty( name: String, description: String, + currency: String, createdByUserId: String, thisBankId: String, thisAccountId: String, @@ -1392,6 +1394,7 @@ trait KafkaMappedConnector_vJune2017 extends Connector with KafkaHelper with Mdc otherBranchRoutingAddress = "", isBeneficiary = true, description = "", + currency= "", otherAccountSecondaryRoutingScheme = "", otherAccountSecondaryRoutingAddress = "", bespoke = List( @@ -1463,7 +1466,7 @@ trait KafkaMappedConnector_vJune2017 extends Connector with KafkaHelper with Mdc ) ), exampleInboundMessage = ( - InboundGetCounterparty(authInfoExample, statusExample, Some(InternalCounterparty(createdByUserId = "String", name = "String", thisBankId = "String", thisAccountId = "String", thisViewId = "String", counterpartyId = "String", otherAccountRoutingScheme = "String", otherAccountRoutingAddress = "String", otherBankRoutingScheme = "String", otherBankRoutingAddress = "String", otherBranchRoutingScheme = "String", otherBranchRoutingAddress = "String", isBeneficiary = true, description = "String", otherAccountSecondaryRoutingScheme = "String", otherAccountSecondaryRoutingAddress = "String", bespoke = Nil))) + InboundGetCounterparty(authInfoExample, statusExample, Some(InternalCounterparty(createdByUserId = "String", name = "String", thisBankId = "String", thisAccountId = "String", thisViewId = "String", counterpartyId = "String", otherAccountRoutingScheme = "String", otherAccountRoutingAddress = "String", otherBankRoutingScheme = "String", otherBankRoutingAddress = "String", otherBranchRoutingScheme = "String", otherBranchRoutingAddress = "String", isBeneficiary = true, description = "String", currency = "String", otherAccountSecondaryRoutingScheme = "String", otherAccountSecondaryRoutingAddress = "String", bespoke = Nil))) ) ) override def getCounterpartyByCounterpartyId(counterpartyId: CounterpartyId, callContext: Option[CallContext]) = saveConnectorMetric{ diff --git a/obp-api/src/main/scala/code/bankconnectors/vMar2017/KafkaJsonFactory_vMar2017.scala b/obp-api/src/main/scala/code/bankconnectors/vMar2017/KafkaJsonFactory_vMar2017.scala index d3f9fcb1d..09e40d2c5 100644 --- a/obp-api/src/main/scala/code/bankconnectors/vMar2017/KafkaJsonFactory_vMar2017.scala +++ b/obp-api/src/main/scala/code/bankconnectors/vMar2017/KafkaJsonFactory_vMar2017.scala @@ -293,6 +293,7 @@ case class CounterpartyTrait2(counterparty: InboundCounterparty) extends Counter def otherBranchRoutingAddress: String = counterparty.otherBranchRoutingAddress def isBeneficiary: Boolean = counterparty.isBeneficiary def description: String = "" + def currency: String = "" def otherAccountSecondaryRoutingScheme: String = "" def otherAccountSecondaryRoutingAddress: String = "" def bespoke: List[CounterpartyBespoke] = Nil diff --git a/obp-api/src/main/scala/code/bankconnectors/vSept2018/KafkaJsonFactory_vSept2018.scala b/obp-api/src/main/scala/code/bankconnectors/vSept2018/KafkaJsonFactory_vSept2018.scala index da888f897..4adc58dcf 100644 --- a/obp-api/src/main/scala/code/bankconnectors/vSept2018/KafkaJsonFactory_vSept2018.scala +++ b/obp-api/src/main/scala/code/bankconnectors/vSept2018/KafkaJsonFactory_vSept2018.scala @@ -257,6 +257,7 @@ case class InternalGetTransactionRequests( case class OutboundCounterparty( name: String, description: String, + currency: String, createdByUserId: String, thisBankId: String, thisAccountId: String, @@ -311,6 +312,7 @@ case class InternalCounterparty( otherBranchRoutingAddress: String, isBeneficiary: Boolean, description: String, + currency: String, otherAccountSecondaryRoutingScheme: String, otherAccountSecondaryRoutingAddress: String, bespoke: List[CounterpartyBespoke]) extends CounterpartyTrait diff --git a/obp-api/src/main/scala/code/bankconnectors/vSept2018/KafkaMappedConnector_vSept2018.scala b/obp-api/src/main/scala/code/bankconnectors/vSept2018/KafkaMappedConnector_vSept2018.scala index 73ce7e773..77ebf9b15 100644 --- a/obp-api/src/main/scala/code/bankconnectors/vSept2018/KafkaMappedConnector_vSept2018.scala +++ b/obp-api/src/main/scala/code/bankconnectors/vSept2018/KafkaMappedConnector_vSept2018.scala @@ -995,6 +995,7 @@ trait KafkaMappedConnector_vSept2018 extends Connector with KafkaHelper with Mdc OutboundCounterparty( name = "name", description = "description", + currency = "currency", createdByUserId = "createdByUserId", thisBankId = "thisBankId", thisAccountId = "thisAccountId", @@ -1032,7 +1033,8 @@ trait KafkaMappedConnector_vSept2018 extends Connector with KafkaHelper with Mdc otherBranchRoutingAddress= "String", isBeneficiary = false, description= "String", - otherAccountSecondaryRoutingScheme= "String", + currency= "String", + otherAccountSecondaryRoutingScheme= "String", otherAccountSecondaryRoutingAddress= "String", bespoke = List(CounterpartyBespoke( key = "String", @@ -1044,6 +1046,7 @@ trait KafkaMappedConnector_vSept2018 extends Connector with KafkaHelper with Mdc override def createCounterparty( name: String, description: String, + currency: String, createdByUserId: String, thisBankId: String, thisAccountId: String, @@ -1066,6 +1069,7 @@ trait KafkaMappedConnector_vSept2018 extends Connector with KafkaHelper with Mdc counterparty = OutboundCounterparty( name: String, description: String, + currency: String, createdByUserId: String, thisBankId: String, thisAccountId: String, @@ -1250,6 +1254,7 @@ trait KafkaMappedConnector_vSept2018 extends Connector with KafkaHelper with Mdc otherBranchRoutingAddress = "", isBeneficiary = true, description = "", + currency = "", otherAccountSecondaryRoutingScheme = "", otherAccountSecondaryRoutingAddress = "", bespoke = List( @@ -1329,7 +1334,7 @@ trait KafkaMappedConnector_vSept2018 extends Connector with KafkaHelper with Mdc ) ), exampleInboundMessage = ( - InboundGetCounterparty(inboundAuthInfoExample, statusExample, Some(InternalCounterparty(createdByUserId = "String", name = "String", thisBankId = "String", thisAccountId = "String", thisViewId = "String", counterpartyId = "String", otherAccountRoutingScheme = "String", otherAccountRoutingAddress = "String", otherBankRoutingScheme = "String", otherBankRoutingAddress = "String", otherBranchRoutingScheme = "String", otherBranchRoutingAddress = "String", isBeneficiary = true, description = "String", otherAccountSecondaryRoutingScheme = "String", otherAccountSecondaryRoutingAddress = "String", bespoke = Nil))) + InboundGetCounterparty(inboundAuthInfoExample, statusExample, Some(InternalCounterparty(createdByUserId = "String", name = "String", thisBankId = "String", thisAccountId = "String", thisViewId = "String", counterpartyId = "String", otherAccountRoutingScheme = "String", otherAccountRoutingAddress = "String", otherBankRoutingScheme = "String", otherBankRoutingAddress = "String", otherBranchRoutingScheme = "String", otherBranchRoutingAddress = "String", isBeneficiary = true, description = "String", currency = "String", otherAccountSecondaryRoutingScheme = "String", otherAccountSecondaryRoutingAddress = "String", bespoke = Nil))) ), adapterImplementation = Some(AdapterImplementation("Payments", 1)) ) @@ -1396,7 +1401,7 @@ trait KafkaMappedConnector_vSept2018 extends Connector with KafkaHelper with Mdc exampleInboundMessage = ( InboundGetCounterparty(inboundAuthInfoExample, statusExample, - Some(InternalCounterparty(createdByUserId = "String", name = "String", thisBankId = "String", thisAccountId = "String", thisViewId = "String", counterpartyId = "String", otherAccountRoutingScheme = "String", otherAccountRoutingAddress = "String", otherBankRoutingScheme = "String", otherBankRoutingAddress = "String", otherBranchRoutingScheme = "String", otherBranchRoutingAddress = "String", isBeneficiary = true, description = "String", otherAccountSecondaryRoutingScheme = "String", otherAccountSecondaryRoutingAddress = "String", bespoke = Nil))) + Some(InternalCounterparty(createdByUserId = "String", name = "String", thisBankId = "String", thisAccountId = "String", thisViewId = "String", counterpartyId = "String", otherAccountRoutingScheme = "String", otherAccountRoutingAddress = "String", otherBankRoutingScheme = "String", otherBankRoutingAddress = "String", otherBranchRoutingScheme = "String", otherBranchRoutingAddress = "String", isBeneficiary = true, description = "String", currency = "String", otherAccountSecondaryRoutingScheme = "String", otherAccountSecondaryRoutingAddress = "String", bespoke = Nil))) ), adapterImplementation = Some(AdapterImplementation("Payments", 1)) ) diff --git a/obp-api/src/main/scala/code/metadata/counterparties/Counterparties.scala b/obp-api/src/main/scala/code/metadata/counterparties/Counterparties.scala index f88ebaa02..a6c7ba04d 100644 --- a/obp-api/src/main/scala/code/metadata/counterparties/Counterparties.scala +++ b/obp-api/src/main/scala/code/metadata/counterparties/Counterparties.scala @@ -54,6 +54,7 @@ trait Counterparties { otherAccountSecondaryRoutingScheme: String, otherAccountSecondaryRoutingAddress: String, description: String, + currency: String, bespoke: List[CounterpartyBespoke] ): Box[CounterpartyTrait] @@ -114,6 +115,7 @@ class RemotedataCounterpartiesCaseClasses { otherAccountSecondaryRoutingScheme: String, otherAccountSecondaryRoutingAddress: String, description: String, + currency: String, bespoke: List[CounterpartyBespoke] ) diff --git a/obp-api/src/main/scala/code/metadata/counterparties/MapperCounterparties.scala b/obp-api/src/main/scala/code/metadata/counterparties/MapperCounterparties.scala index f99f5a4a3..d4804e389 100644 --- a/obp-api/src/main/scala/code/metadata/counterparties/MapperCounterparties.scala +++ b/obp-api/src/main/scala/code/metadata/counterparties/MapperCounterparties.scala @@ -155,6 +155,7 @@ object MapperCounterparties extends Counterparties with MdcLoggable { otherAccountSecondaryRoutingScheme: String, otherAccountSecondaryRoutingAddress: String, description: String, + currency: String, bespoke: List[CounterpartyBespoke] ): Box[CounterpartyTrait] = { @@ -173,6 +174,7 @@ object MapperCounterparties extends Counterparties with MdcLoggable { .mOtherBranchRoutingScheme(otherBranchRoutingScheme) .mIsBeneficiary(isBeneficiary) .mDescription(description) + .mCurrency(currency) .mOtherAccountSecondaryRoutingScheme(otherAccountSecondaryRoutingScheme) .mOtherAccountSecondaryRoutingAddress(otherAccountSecondaryRoutingAddress) .saveMe() @@ -437,6 +439,7 @@ class MappedCounterparty extends CounterpartyTrait with LongKeyedMapper[MappedCo object mOtherBranchRoutingAddress extends MappedString(this, 255) object mIsBeneficiary extends MappedBoolean(this) object mDescription extends MappedString(this, 36) + object mCurrency extends MappedString(this, 255) object mOtherAccountSecondaryRoutingScheme extends MappedString(this, 255) object mOtherAccountSecondaryRoutingAddress extends MappedString(this, 255) object mBespoke extends MappedOneToMany(MappedCounterpartyBespoke, MappedCounterpartyBespoke.mCounterparty, OrderBy(MappedCounterpartyBespoke.id, Ascending)) @@ -455,6 +458,7 @@ class MappedCounterparty extends CounterpartyTrait with LongKeyedMapper[MappedCo override def otherBankRoutingAddress: String = mOtherBankRoutingAddress.get override def isBeneficiary: Boolean = mIsBeneficiary.get override def description: String = mDescription.get + override def currency: String = mCurrency.toString override def otherAccountSecondaryRoutingScheme: String = mOtherAccountSecondaryRoutingScheme.get override def otherAccountSecondaryRoutingAddress: String = mOtherAccountSecondaryRoutingAddress.get override def bespoke: List[CounterpartyBespoke] = diff --git a/obp-api/src/main/scala/code/metadata/counterparties/MongoCounterparties.scala b/obp-api/src/main/scala/code/metadata/counterparties/MongoCounterparties.scala index d88ea24a0..1e2a50485 100644 --- a/obp-api/src/main/scala/code/metadata/counterparties/MongoCounterparties.scala +++ b/obp-api/src/main/scala/code/metadata/counterparties/MongoCounterparties.scala @@ -127,6 +127,7 @@ object MongoCounterparties extends Counterparties with MdcLoggable { otherAccountSecondaryRoutingScheme: String, otherAccountSecondaryRoutingAddress: String, description: String, + currency: String, bespoke: List[CounterpartyBespoke] ): Box[CounterpartyTrait] = Empty diff --git a/obp-api/src/main/scala/code/remotedata/RemotedataCounterparties.scala b/obp-api/src/main/scala/code/remotedata/RemotedataCounterparties.scala index c8ca990cd..42290bd95 100644 --- a/obp-api/src/main/scala/code/remotedata/RemotedataCounterparties.scala +++ b/obp-api/src/main/scala/code/remotedata/RemotedataCounterparties.scala @@ -56,6 +56,7 @@ object RemotedataCounterparties extends ObpActorInit with Counterparties { otherAccountSecondaryRoutingScheme: String, otherAccountSecondaryRoutingAddress: String, description: String, + currency: String, bespoke: List[CounterpartyBespoke]): Box[CounterpartyTrait] = getValueFromFuture( (actor ? cc.createCounterparty(createdByUserId, thisBankId, @@ -70,6 +71,7 @@ object RemotedataCounterparties extends ObpActorInit with Counterparties { otherAccountSecondaryRoutingScheme, otherAccountSecondaryRoutingAddress, description, + currency, bespoke)).mapTo[Box[CounterpartyTrait]] ) diff --git a/obp-api/src/main/scala/code/remotedata/RemotedataCounterpartiesActor.scala b/obp-api/src/main/scala/code/remotedata/RemotedataCounterpartiesActor.scala index f931e4a2e..165674d49 100644 --- a/obp-api/src/main/scala/code/remotedata/RemotedataCounterpartiesActor.scala +++ b/obp-api/src/main/scala/code/remotedata/RemotedataCounterpartiesActor.scala @@ -39,6 +39,7 @@ class RemotedataCounterpartiesActor extends Actor with ObpActorHelper with MdcLo otherAccountSecondaryRoutingScheme: String, otherAccountSecondaryRoutingAddress: String, description: String, + currency: String, bespoke: List[CounterpartyBespoke] ) => logger.debug(s"createCounterparty($createdByUserId, $thisBankId, $thisAccountId, $thisViewId, $name, " + @@ -60,6 +61,7 @@ class RemotedataCounterpartiesActor extends Actor with ObpActorHelper with MdcLo otherAccountSecondaryRoutingScheme: String, otherAccountSecondaryRoutingAddress: String, description: String, + currency: String, bespoke: List[CounterpartyBespoke] )) diff --git a/obp-api/src/test/scala/code/api/v4_0_0/CounterpartyTest.scala b/obp-api/src/test/scala/code/api/v4_0_0/CounterpartyTest.scala index 8b9b1fd13..c60b9e2ac 100644 --- a/obp-api/src/test/scala/code/api/v4_0_0/CounterpartyTest.scala +++ b/obp-api/src/test/scala/code/api/v4_0_0/CounterpartyTest.scala @@ -26,7 +26,7 @@ class CounterpartyTest extends V400ServerSetup { */ object VersionOfApi extends Tag(ApiVersion.v4_0_0.toString) object ApiEndpoint1 extends Tag(nameOf(Implementations4_0_0.createCounterpartyForAnyAccount)) - object ApiEndpoint2 extends Tag(nameOf(Implementations2_2_0.getExplictCounterpartyById)) + object ApiEndpoint2 extends Tag(nameOf(Implementations4_0_0.getExplictCounterpartyById)) object ApiEndpoint3 extends Tag(nameOf(Implementations4_0_0.getCounterpartyByNameForAnyAccount)) @@ -40,7 +40,7 @@ class CounterpartyTest extends V400ServerSetup { val viewId =ViewId(SYSTEM_OWNER_VIEW_ID) - val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJSON.copy(other_bank_routing_address=bankId.value,other_account_routing_address=accountId.value) + val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJson400.copy(other_bank_routing_address=bankId.value,other_account_routing_address=accountId.value) Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, CanCreateCounterpartyAtBank.toString) When("We make the request Create counterparty for an account") @@ -49,7 +49,7 @@ class CounterpartyTest extends V400ServerSetup { Then("We should get a 201 and check all the fields") responsePost.code should equal(201) - val counterpartyWithMetadataJson = responsePost.body.extract[CounterpartyWithMetadataJson] + val counterpartyWithMetadataJson = responsePost.body.extract[CounterpartyWithMetadataJson400] counterpartyWithMetadataJson.other_account_routing_address should equal(counterpartyPostJSON.other_account_routing_address) counterpartyWithMetadataJson.other_account_secondary_routing_scheme should equal(counterpartyPostJSON.other_account_secondary_routing_scheme) @@ -63,7 +63,7 @@ class CounterpartyTest extends V400ServerSetup { Then("We should get a 200 and check all the fields") responseGet.code should equal(200) - val counterpartyWithMetadataJsonGet = responseGet.body.extract[CounterpartyWithMetadataJson] + val counterpartyWithMetadataJsonGet = responseGet.body.extract[CounterpartyWithMetadataJson400] counterpartyWithMetadataJsonGet.other_account_routing_address should equal(counterpartyPostJSON.other_account_routing_address) @@ -81,7 +81,7 @@ class CounterpartyTest extends V400ServerSetup { //This will use a non exiting obp account, and it should also work - val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJSON.copy(other_bank_routing_scheme = "xx") + val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJson400.copy(other_bank_routing_scheme = "xx") Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, CanCreateCounterpartyAtBank.toString) When("We make the request Create counterparty for an account") @@ -90,7 +90,7 @@ class CounterpartyTest extends V400ServerSetup { Then("We should get a 201 and check all the fields") responsePost.code should equal(201) - val counterpartyWithMetadataJson = responsePost.body.extract[CounterpartyWithMetadataJson] + val counterpartyWithMetadataJson = responsePost.body.extract[CounterpartyWithMetadataJson400] counterpartyWithMetadataJson.other_account_routing_address should equal(counterpartyPostJSON.other_account_routing_address) counterpartyWithMetadataJson.other_account_secondary_routing_scheme should equal(counterpartyPostJSON.other_account_secondary_routing_scheme) @@ -104,7 +104,7 @@ class CounterpartyTest extends V400ServerSetup { Then("We should get a 200 and check all the fields") responseGet.code should equal(200) - val counterpartyWithMetadataJsonGet = responseGet.body.extract[CounterpartyWithMetadataJson] + val counterpartyWithMetadataJsonGet = responseGet.body.extract[CounterpartyWithMetadataJson400] counterpartyWithMetadataJsonGet.other_account_routing_address should equal(counterpartyPostJSON.other_account_routing_address) @@ -120,7 +120,7 @@ class CounterpartyTest extends V400ServerSetup { val accountId = testAccountId1 val viewId =ViewId(SYSTEM_OWNER_VIEW_ID) - val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJSON.copy(other_bank_routing_address=bankId.value,other_account_routing_address=accountId.value) + val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJson400.copy(other_bank_routing_address=bankId.value,other_account_routing_address=accountId.value) val requestPost = (v4_0_0_Request / "management" /"banks" / bankId.value / "accounts" / accountId.value / viewId.value / "counterparties" ).POST <@ (user1) val responsePost = makePostRequest(requestPost, write(counterpartyPostJSON)) @@ -140,7 +140,7 @@ class CounterpartyTest extends V400ServerSetup { Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, CanCreateCounterpartyAtBank.toString) - val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJSON.copy(other_bank_routing_address=bankId.value,other_account_routing_address=accountId.value) + val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJson400.copy(other_bank_routing_address=bankId.value,other_account_routing_address=accountId.value) val requestPost = (v4_0_0_Request / "management" /"banks" / bankId.value / "accounts" / accountId.value / viewId.value / "counterparties" ).POST <@ (user1) val responsePost = makePostRequest(requestPost, write(counterpartyPostJSON)) @@ -157,7 +157,7 @@ class CounterpartyTest extends V400ServerSetup { val viewId =ViewId(SYSTEM_OWNER_VIEW_ID) Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, CanCreateCounterpartyAtBank.toString) - val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJSON.copy(other_bank_routing_address=bankId.value,other_account_routing_address=accountId.value) + val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJson400.copy(other_bank_routing_address=bankId.value,other_account_routing_address=accountId.value) When("We make the request Create counterparty for an account") val requestPost = (v4_0_0_Request /"management" / "banks" / bankId.value / "accounts" / accountId.value / viewId.value / "counterparties" ).POST <@ (user1) @@ -183,7 +183,7 @@ class CounterpartyTest extends V400ServerSetup { val viewId =ViewId(SYSTEM_OWNER_VIEW_ID) - val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJSON.copy(other_bank_routing_address=bankId.value,other_account_routing_address=accountId.value) + val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJson400.copy(other_bank_routing_address=bankId.value,other_account_routing_address=accountId.value) Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, CanCreateCounterpartyAtBank.toString) When("We make the request Create counterparty for an account") @@ -208,7 +208,7 @@ class CounterpartyTest extends V400ServerSetup { Then("We should get a 200 and check all the fields") responseGet.code should equal(200) - val counterpartyWithMetadataJsonGet = responseGet.body.extract[CounterpartyWithMetadataJson] + val counterpartyWithMetadataJsonGet = responseGet.body.extract[CounterpartyWithMetadataJson400] counterpartyWithMetadataJsonGet.other_account_routing_address should equal(counterpartyPostJSON.other_account_routing_address) @@ -223,7 +223,7 @@ class CounterpartyTest extends V400ServerSetup { val viewId =ViewId(SYSTEM_OWNER_VIEW_ID) - val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJSON.copy(other_bank_routing_address=bankId.value,other_account_routing_address=accountId.value) + val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJson400.copy(other_bank_routing_address=bankId.value,other_account_routing_address=accountId.value) Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, CanCreateCounterpartyAtBank.toString) When("We make the request Create counterparty for an account") @@ -232,7 +232,7 @@ class CounterpartyTest extends V400ServerSetup { Then("We should get a 201 and check all the fields") responsePost.code should equal(201) - val counterpartyWithMetadataJson = responsePost.body.extract[CounterpartyWithMetadataJson] + val counterpartyWithMetadataJson = responsePost.body.extract[CounterpartyWithMetadataJson400] counterpartyWithMetadataJson.other_account_routing_address should equal(counterpartyPostJSON.other_account_routing_address) counterpartyWithMetadataJson.other_account_secondary_routing_scheme should equal(counterpartyPostJSON.other_account_secondary_routing_scheme) diff --git a/obp-api/src/test/scala/code/connector/RestConnector_vMar2019_frozen_meta_data b/obp-api/src/test/scala/code/connector/RestConnector_vMar2019_frozen_meta_data index 052cc5eccfb19a4753bf7521475cdf1597632e4d..6b4728bd6c1c939823c1204d59cd487161331f69 100644 GIT binary patch delta 1933 zcmaJ?ZBUd|6z0Hwz<#pJhRC`t%jfc?5RQXknwg5BdRQ zur+?PZ97+m83Pg6ZIN?zCT)gm$YM zBhab$$FM;e_RW8aqD7#lq(Z#B-Gq(>8tiEE$E$^Xykx=aA|y*_6E9pS@zva|_K~eA z-c-J1ZM9E8F+yA-7QO9{qXpB^-WiLd4kgOcgFFfO?DQLw06O8jfubeoN({la!FU`R zQt|R-(}3{o&5R}BY)3L!@y7Caf|guk#>P%P{=Q9z&ue8oGdEc*&5_^bZ3ACjUjjZU%Qpu+MetQ;my7kB`nHSk+Rl}W zl6eg8Qb~KYPb^+~Ivn3K%K6^j78$kX)KfD}EyYBTpZyTJU(26#)m#ix$u?K#Gvt zYbq*=H^1SbxFrp&O_6f!Z_wcOJF_U1hJe>kO0FHLk$I3{U8@>TkKTU_rO}lt>d*!$ ztp7RCVArcE47=aVHm-+wrpbgrOf{Q4xmCoaXIl7pZJAkXVl8IS;l-bWxbZ=p*i{e6 zdVc4(@yX$oWm9wA!%k5au1eCEO~vA;g4XR2AGfY}@1x;=t9jSoh;IvafNc6IoRz=@ z>65Y(+7z(U!|zM1Rs*S|hUBqmHlTs2vKUVb$x&>Ylyv0Wq`~f6YBXAuLY@{b5?~=r z2jBUDUZ8pX8Mp^EmKqvaoI=_0#wp>YbdPuk$?c&jiq6eRvs(t*V3xIaqA z3d7+|Xb^r1hZ$lR4ILpa5@tUkE+ytVO>D>xLAWDX$p)ifoG@IEhRuHesjMsx)=<;f z_X#i;h6Pn3RMNZ?Xd>Fh?XeWd^j@@TCS3El%dI`3H4Wy8{Z!S4Fu!@Q+7reoEQ@Sv zL5E8%Ow5B(d-tCuqP9a(x0FZmj^jy zcG2ZVf#t(#HPKhRC&}w_trlX0lcg|6ET+CPOi*rs0U}!OZ8#4ghat|j1d?8}!4 Of(-&_j3zjJ@= z(Y5sGT;KSEAA39qN~O90hyZph5E}56V+DL^z$Gnov%^tf=lP+rI_O3y2*>)i+5A!X zI*qbq#j=~Z{EtW*y^CeGEe&S!`lx9@?>FpApjO`G%~>^#{AG_IB=954?6XH$K>k*&4JB9_Ulo}i{=xWik<2hi$WQ$Si$bnu@+%+izPo@}o^{W92xeRngdC4dA%vt8CFy+p? zaDXms&ah+rC=0(Zmx5&t_~UsCv`{PHMf3HA4?xQ+JSO6m?_#i_%ZR=6y$n-J%8CU` z4_Qk7!@@{U0cTAN?rAnN-{oN8*-Lh6po_bU`iLsOU%Xq@ksn!6FHor!!p|LPD$&sL z-5SbLa5h<05H*z@!1=985I}ENl@Pw{RZ-Bzn(Z(In>P6Ht*d^~K_fO)Cs4$_ozeLA z+EC^*4~*Qm#-g5xskPhai0>Z{0I4HJ&-r{KeNHq;!irl;mfk<A{mGpe=Z?f%S3jUs zN;f=I>2lXKf3*Yuw=kmoyK>rzy`omx%^HKHyTU{7T)1>`$zr97LUjMTS?U2bcTa~< zgqL$=Nl9V(n{o(km|0O?RQd+GixRQEdkn>r@mY%QB5c`W+&St&fB zZ=>+F(1AJ=!`5c7-ZX+>4K}u4LML$ z^c^Zc%zYjQ5A_a`8?&myLt9!XtE9EbI>?riY!)z6fuuw~xS#<)iKgvddC;~J*!H#; zaQgwXbRq~2s_ia?ghH%0tzB%VDKg%hRSt#spjOgELY&H8nlTK<3jey#rby>)kVM}l zh=Ov>e-LjR4zCMUR(B>EWti&~XbH2)YYlEcsbmC{sL4J_g&Z0(qL_xyM#Fslzr~ZNe`4QoP~{A%{~zx0y(IS>ST{h_Gbmne3Qoe>q-%>ozOw|(kwtJ_EquB}=DVlj7Z;+cgnSuDoeuC3 TbNlc)d7!X{IMA`M3b^<;w-@Er diff --git a/obp-api/src/test/scala/code/kafka/KafkaTest.scala b/obp-api/src/test/scala/code/kafka/KafkaTest.scala index bc4075f2a..0f7da50c0 100644 --- a/obp-api/src/test/scala/code/kafka/KafkaTest.scala +++ b/obp-api/src/test/scala/code/kafka/KafkaTest.scala @@ -355,7 +355,8 @@ class KafkaTest extends KafkaSetup with ServerSetupWithTestData { val box = Connector.connector.vend.createCounterparty( outBound.counterparty.name, outBound.counterparty.description, - outBound.counterparty.createdByUserId, + outBound.counterparty.currency, + outBound.counterparty.createdByUserId, outBound.counterparty.thisBankId, outBound.counterparty.thisAccountId, outBound.counterparty.thisViewId, diff --git a/obp-api/src/test/scala/code/setup/LocalMappedConnectorTestSetup.scala b/obp-api/src/test/scala/code/setup/LocalMappedConnectorTestSetup.scala index 6f593629b..9f2a817e0 100644 --- a/obp-api/src/test/scala/code/setup/LocalMappedConnectorTestSetup.scala +++ b/obp-api/src/test/scala/code/setup/LocalMappedConnectorTestSetup.scala @@ -52,6 +52,7 @@ trait LocalMappedConnectorTestSetup extends TestConnectorSetupWithStandardPermis otherAccountSecondaryRoutingScheme ="IBAN", otherAccountSecondaryRoutingAddress ="DE89 3704 0044 0532 0130 00", description = "String", + currency = "String", bespoke = Nil ).openOrThrowException(attemptedToOpenAnEmptyBox) } diff --git a/obp-commons/src/main/scala/com/openbankproject/commons/dto/JsonsTransfer.scala b/obp-commons/src/main/scala/com/openbankproject/commons/dto/JsonsTransfer.scala index d04f7d09c..959d5eea5 100644 --- a/obp-commons/src/main/scala/com/openbankproject/commons/dto/JsonsTransfer.scala +++ b/obp-commons/src/main/scala/com/openbankproject/commons/dto/JsonsTransfer.scala @@ -482,7 +482,7 @@ case class OutBoundCreateChallenge(outboundAdapterCallContext: OutboundAdapterCa case class InBoundCreateChallenge(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: String) extends InBoundTrait[String] -case class OutBoundCreateCounterparty(outboundAdapterCallContext: OutboundAdapterCallContext, name: String, description: String, createdByUserId: String, thisBankId: String, thisAccountId: String, thisViewId: String, otherAccountRoutingScheme: String, otherAccountRoutingAddress: String, otherAccountSecondaryRoutingScheme: String, otherAccountSecondaryRoutingAddress: String, otherBankRoutingScheme: String, otherBankRoutingAddress: String, otherBranchRoutingScheme: String, otherBranchRoutingAddress: String, isBeneficiary: Boolean, bespoke: List[CounterpartyBespoke]) extends TopicTrait +case class OutBoundCreateCounterparty(outboundAdapterCallContext: OutboundAdapterCallContext, name: String, description: String, currency: String, createdByUserId: String, thisBankId: String, thisAccountId: String, thisViewId: String, otherAccountRoutingScheme: String, otherAccountRoutingAddress: String, otherAccountSecondaryRoutingScheme: String, otherAccountSecondaryRoutingAddress: String, otherBankRoutingScheme: String, otherBankRoutingAddress: String, otherBranchRoutingScheme: String, otherBranchRoutingAddress: String, isBeneficiary: Boolean, bespoke: List[CounterpartyBespoke]) extends TopicTrait case class InBoundCreateCounterparty(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: CounterpartyTraitCommons) extends InBoundTrait[CounterpartyTraitCommons] diff --git a/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModel.scala b/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModel.scala index 27bc4d440..99cd510c6 100644 --- a/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModel.scala +++ b/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModel.scala @@ -283,6 +283,7 @@ case class CounterpartyTraitCommons( createdByUserId :String, name :String, description :String, + currency: String, thisBankId :String, thisAccountId :String, thisViewId :String, diff --git a/obp-commons/src/main/scala/com/openbankproject/commons/model/CounterpartyModel.scala b/obp-commons/src/main/scala/com/openbankproject/commons/model/CounterpartyModel.scala index c42e81d7d..f8df619af 100644 --- a/obp-commons/src/main/scala/com/openbankproject/commons/model/CounterpartyModel.scala +++ b/obp-commons/src/main/scala/com/openbankproject/commons/model/CounterpartyModel.scala @@ -46,6 +46,7 @@ trait CounterpartyTrait { def otherBranchRoutingScheme: String def otherBranchRoutingAddress: String def isBeneficiary : Boolean + def currency: String def bespoke: List[CounterpartyBespoke] }