Skip to content

Commit 3d4fe0e

Browse files
authored
Merge pull request #2768 from hongwei1/feature/obp-trading-v7-integration
Feature: OBP Trading v7.0.0 Integration - 17 Endpoints (P1-P4 Complete)
2 parents c6b29f1 + fc2a566 commit 3d4fe0e

11 files changed

Lines changed: 2457 additions & 562 deletions

File tree

.postman.json

Lines changed: 0 additions & 446 deletions
This file was deleted.

.postman_environment.json

Lines changed: 0 additions & 30 deletions
This file was deleted.

.postman_simple.json

Lines changed: 0 additions & 83 deletions
This file was deleted.

obp-api/src/main/scala/code/api/util/ApiTag.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ object ApiTag {
103103
val apiTagSystem = ResourceDocTag("System")
104104
val apiTagCache = ResourceDocTag("Cache")
105105
val apiTagLogCache = ResourceDocTag("Log-Cache")
106+
val apiTagTrading = ResourceDocTag("Trading")
107+
val apiTagMarket = ResourceDocTag("Market")
106108

107109
val apiTagApiCollection = ResourceDocTag("Api-Collection")
108110

obp-api/src/main/scala/code/api/util/ErrorMessages.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,27 @@ object ErrorMessages {
850850
val MethodRoutingNotFoundByMethodRoutingId = "OBP-70002: MethodRouting not found. Please specify a valid value for method_routing_id."
851851
val MethodRoutingAlreadyExistsError = "OBP-70003: Method Routing is already exists."
852852

853+
// Trading Exceptions (OBP-71XXX)
854+
val OfferNotFound = "OBP-71001: Trading offer not found."
855+
val InvalidOfferType = "OBP-71002: Invalid offer type. Must be 'BUY' or 'SELL'."
856+
val InvalidTradingAmount = "OBP-71003: Invalid amount. Must be a positive number."
857+
val CreateTradingOfferError = "OBP-71005: Could not create trading offer."
858+
859+
// Market Trading Exceptions (OBP-72XXX)
860+
val OrderNotFound = "OBP-72001: Market order not found."
861+
val InvalidOrderSide = "OBP-72002: Invalid order side. Must be 'BUY' or 'SELL'."
862+
val TradeNotFound = "OBP-72003: Market trade not found."
863+
val InvalidMatchParameters = "OBP-72004: Invalid match parameters."
864+
val SettlementFailed = "OBP-72005: Settlement request failed."
865+
val WithdrawalFailed = "OBP-72006: Withdrawal request failed."
866+
867+
// TCC Payment Authorization Exceptions (OBP-73XXX)
868+
val PaymentAuthNotFound = "OBP-73001: Payment authorization not found."
869+
val InvalidPaymentAuthState = "OBP-73002: Invalid payment authorization state transition."
870+
val PaymentAuthAlreadyCaptured = "OBP-73003: Payment authorization has already been captured."
871+
val PaymentAuthAlreadyReleased = "OBP-73004: Payment authorization has already been released."
872+
val CreatePaymentAuthError = "OBP-73005: Could not create payment authorization."
873+
853874
// Cascade Deletion Exceptions (OBP-8XXXX)
854875
val CouldNotDeleteCascade = "OBP-80001: Could not delete cascade."
855876
val CannotDeleteCascadePersonalEntity = "OBP-80002: Cannot delete cascade for personal entities (hasPersonalEntity=true). Please delete the records and definition separately."

obp-api/src/main/scala/code/api/util/NewStyle.scala

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4569,6 +4569,237 @@ object NewStyle extends MdcLoggable{
45694569
) map {
45704570
i => (unboxFullOrFail(i._1, callContext, s"$DeleteCounterpartyLimitError"), i._2)
45714571
}
4572+
4573+
// Trading Methods
4574+
def createTradingOffer(
4575+
bankId: BankId,
4576+
accountId: AccountId,
4577+
offerType: String,
4578+
assetCode: String,
4579+
assetAmount: BigDecimal,
4580+
priceCurrency: String,
4581+
priceAmount: BigDecimal,
4582+
settlementAccountId: String,
4583+
callContext: Option[CallContext]
4584+
): OBPReturnType[com.openbankproject.commons.model.TradingOffer] = {
4585+
Connector.connector.vend.createTradingOffer(
4586+
bankId, accountId, offerType, assetCode, assetAmount,
4587+
priceCurrency, priceAmount, settlementAccountId, callContext
4588+
) map {
4589+
i => (unboxFullOrFail(i._1, callContext, s"$OfferNotFound"), i._2)
4590+
}
4591+
}
4592+
4593+
def getTradingOffer(
4594+
offerId: String,
4595+
callContext: Option[CallContext]
4596+
): OBPReturnType[com.openbankproject.commons.model.TradingOffer] = {
4597+
Connector.connector.vend.getTradingOffer(offerId, callContext) map {
4598+
i => (unboxFullOrFail(i._1, callContext, s"$OfferNotFound"), i._2)
4599+
}
4600+
}
4601+
4602+
def cancelTradingOffer(
4603+
offerId: String,
4604+
callContext: Option[CallContext]
4605+
): OBPReturnType[com.openbankproject.commons.model.TradingOffer] = {
4606+
Connector.connector.vend.cancelTradingOffer(offerId, callContext) map {
4607+
i => (unboxFullOrFail(i._1, callContext, s"$OfferNotFound"), i._2)
4608+
}
4609+
}
4610+
4611+
def updateTradingOffer(
4612+
offerId: String,
4613+
priceAmount: Option[BigDecimal],
4614+
expiryDatetime: Option[Date],
4615+
minimumFill: Option[BigDecimal],
4616+
callContext: Option[CallContext]
4617+
): OBPReturnType[com.openbankproject.commons.model.TradingOffer] = {
4618+
Connector.connector.vend.updateTradingOffer(offerId, priceAmount, expiryDatetime, minimumFill, callContext) map {
4619+
i => (unboxFullOrFail(i._1, callContext, s"$OfferNotFound"), i._2)
4620+
}
4621+
}
4622+
4623+
def getTradingOffers(
4624+
bankId: BankId,
4625+
accountId: AccountId,
4626+
status: Option[String],
4627+
offerType: Option[String],
4628+
callContext: Option[CallContext]
4629+
): OBPReturnType[List[com.openbankproject.commons.model.TradingOffer]] = {
4630+
Connector.connector.vend.getTradingOffers(bankId, accountId, status, offerType, callContext) map {
4631+
i => (unboxFullOrFail(i._1, callContext, s"$BankAccountNotFound"), i._2)
4632+
}
4633+
}
4634+
4635+
// Market Methods
4636+
def createMarketOrder(
4637+
bankId: BankId,
4638+
accountId: AccountId,
4639+
side: String,
4640+
price: BigDecimal,
4641+
quantity: BigDecimal,
4642+
settlementAccountId: String,
4643+
callContext: Option[CallContext]
4644+
): OBPReturnType[com.openbankproject.commons.model.MarketOrder] = {
4645+
Connector.connector.vend.createMarketOrder(
4646+
bankId, accountId, side, price, quantity, settlementAccountId, callContext
4647+
) map {
4648+
i => (unboxFullOrFail(i._1, callContext, s"$OrderNotFound"), i._2)
4649+
}
4650+
}
4651+
4652+
def getMarketOrder(
4653+
bankId: BankId,
4654+
accountId: AccountId,
4655+
orderId: String,
4656+
callContext: Option[CallContext]
4657+
): OBPReturnType[com.openbankproject.commons.model.MarketOrder] = {
4658+
Connector.connector.vend.getMarketOrder(bankId, accountId, orderId, callContext) map {
4659+
i => (unboxFullOrFail(i._1, callContext, s"$OrderNotFound"), i._2)
4660+
}
4661+
}
4662+
4663+
def cancelMarketOrder(
4664+
bankId: BankId,
4665+
accountId: AccountId,
4666+
orderId: String,
4667+
callContext: Option[CallContext]
4668+
): OBPReturnType[com.openbankproject.commons.model.MarketOrder] = {
4669+
Connector.connector.vend.cancelMarketOrder(bankId, accountId, orderId, callContext) map {
4670+
i => (unboxFullOrFail(i._1, callContext, s"$OrderNotFound"), i._2)
4671+
}
4672+
}
4673+
4674+
def createMarketMatch(
4675+
bankId: BankId,
4676+
accountId: AccountId,
4677+
orderId: String,
4678+
counterOrderId: String,
4679+
amount: BigDecimal,
4680+
price: BigDecimal,
4681+
callContext: Option[CallContext]
4682+
): OBPReturnType[com.openbankproject.commons.model.MarketMatch] = {
4683+
Connector.connector.vend.createMarketMatch(
4684+
bankId, accountId, orderId, counterOrderId, amount, price, callContext
4685+
) map {
4686+
i => (unboxFullOrFail(i._1, callContext, s"$InvalidMatchParameters"), i._2)
4687+
}
4688+
}
4689+
4690+
def getMarketTrade(
4691+
bankId: BankId,
4692+
accountId: AccountId,
4693+
tradeId: String,
4694+
callContext: Option[CallContext]
4695+
): OBPReturnType[com.openbankproject.commons.model.MarketTrade] = {
4696+
Connector.connector.vend.getMarketTrade(bankId, accountId, tradeId, callContext) map {
4697+
i => (unboxFullOrFail(i._1, callContext, s"$TradeNotFound"), i._2)
4698+
}
4699+
}
4700+
4701+
def requestSettlement(
4702+
bankId: BankId,
4703+
accountId: AccountId,
4704+
tradeId: String,
4705+
step: Option[String],
4706+
callContext: Option[CallContext]
4707+
): OBPReturnType[com.openbankproject.commons.model.Settlement] = {
4708+
Connector.connector.vend.requestSettlement(bankId, accountId, tradeId, step, callContext) map {
4709+
i => (unboxFullOrFail(i._1, callContext, s"$SettlementFailed"), i._2)
4710+
}
4711+
}
4712+
4713+
def notifyDeposit(
4714+
bankId: BankId,
4715+
accountId: AccountId,
4716+
txHash: String,
4717+
from: String,
4718+
to: String,
4719+
amount: BigDecimal,
4720+
confirmations: Int,
4721+
requiredConfirmations: Int,
4722+
callContext: Option[CallContext]
4723+
): OBPReturnType[com.openbankproject.commons.model.Deposit] = {
4724+
Connector.connector.vend.notifyDeposit(
4725+
bankId, accountId, txHash, from, to, amount, confirmations, requiredConfirmations, callContext
4726+
) map {
4727+
i => (unboxFullOrFail(i._1, callContext, s"$InvalidTradingAmount"), i._2)
4728+
}
4729+
}
4730+
4731+
def requestWithdrawal(
4732+
bankId: BankId,
4733+
accountId: AccountId,
4734+
settlementAccountId: String,
4735+
amount: BigDecimal,
4736+
address: String,
4737+
requiredConfirmations: Int,
4738+
callContext: Option[CallContext]
4739+
): OBPReturnType[com.openbankproject.commons.model.Withdrawal] = {
4740+
Connector.connector.vend.requestWithdrawal(
4741+
bankId, accountId, settlementAccountId, amount, address, requiredConfirmations, callContext
4742+
) map {
4743+
i => (unboxFullOrFail(i._1, callContext, s"$WithdrawalFailed"), i._2)
4744+
}
4745+
}
4746+
4747+
// TCC Payment Authorization NewStyle Wrappers
4748+
def createPaymentAuth(
4749+
bankId: BankId,
4750+
accountId: AccountId,
4751+
tradeId: String,
4752+
buyerAccountId: String,
4753+
sellerAccountId: String,
4754+
amountFiat: BigDecimal,
4755+
currency: String,
4756+
callContext: Option[CallContext]
4757+
): OBPReturnType[com.openbankproject.commons.model.PaymentAuth] = {
4758+
Connector.connector.vend.createPaymentAuth(
4759+
bankId, accountId, tradeId, buyerAccountId, sellerAccountId, amountFiat, currency, callContext
4760+
) map {
4761+
i => (unboxFullOrFail(i._1, callContext, s"$CreatePaymentAuthError"), i._2)
4762+
}
4763+
}
4764+
4765+
def capturePaymentAuth(
4766+
bankId: BankId,
4767+
accountId: AccountId,
4768+
authId: String,
4769+
callContext: Option[CallContext]
4770+
): OBPReturnType[com.openbankproject.commons.model.PaymentAuth] = {
4771+
Connector.connector.vend.capturePaymentAuth(
4772+
bankId, accountId, authId, callContext
4773+
) map {
4774+
i => (unboxFullOrFail(i._1, callContext, s"$InvalidPaymentAuthState"), i._2)
4775+
}
4776+
}
4777+
4778+
def releasePaymentAuth(
4779+
bankId: BankId,
4780+
accountId: AccountId,
4781+
authId: String,
4782+
callContext: Option[CallContext]
4783+
): OBPReturnType[com.openbankproject.commons.model.PaymentAuth] = {
4784+
Connector.connector.vend.releasePaymentAuth(
4785+
bankId, accountId, authId, callContext
4786+
) map {
4787+
i => (unboxFullOrFail(i._1, callContext, s"$InvalidPaymentAuthState"), i._2)
4788+
}
4789+
}
4790+
4791+
def getPaymentAuth(
4792+
bankId: BankId,
4793+
accountId: AccountId,
4794+
authId: String,
4795+
callContext: Option[CallContext]
4796+
): OBPReturnType[com.openbankproject.commons.model.PaymentAuth] = {
4797+
Connector.connector.vend.getPaymentAuth(
4798+
bankId, accountId, authId, callContext
4799+
) map {
4800+
i => (unboxFullOrFail(i._1, callContext, s"$PaymentAuthNotFound"), i._2)
4801+
}
4802+
}
45724803
}
45734804

45744805
}

0 commit comments

Comments
 (0)