mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 15:47:01 +00:00
commit
a81e3a1589
@ -103,6 +103,7 @@ payments_enabled=true
|
||||
#transaction requests are replacing simple payments starting from 1.4.0
|
||||
transactionRequests_enabled=true
|
||||
transactionRequests_connector=mapped
|
||||
transactionRequests_supported_types=SANDBOX_TAN,INTRABANK
|
||||
|
||||
|
||||
# For video conference meetings (createMeeting)
|
||||
|
||||
@ -1194,8 +1194,11 @@ trait APIMethods200 {
|
||||
toAccountId <- tryo(AccountId(transBodyJson.to.account_id))
|
||||
toAccount <- BankAccount(toBankId, toAccountId) ?~! {ErrorMessages.CounterpartyNotFound}
|
||||
// Prevent default value for transaction request type (at least).
|
||||
// Consider: Add valid list of Transaction Request Types to Props "transactionRequests_supported_types" and use that below
|
||||
isValidTransactionRequestType <- tryo(assert(transactionRequestType.value != "TRANSACTION_REQUEST_TYPE")) ?~! s"${ErrorMessages.InvalidTransactionRequestType} : Invalid value is: '${transactionRequestType.value}' Valid values are: ${TransactionRequests.CHALLENGE_SANDBOX_TAN}"
|
||||
// Get Transaction Request Types from Props "transactionRequests_supported_types". Default is empty string
|
||||
validTransactionRequestTypes <- tryo{Props.get("transactionRequests_supported_types", "")}
|
||||
// Use a list instead of a string to avoid partial matches
|
||||
validTransactionRequestTypesList <- tryo{validTransactionRequestTypes.split(",")}
|
||||
isValidTransactionRequestType <- tryo(assert(transactionRequestType.value != "TRANSACTION_REQUEST_TYPE" && validTransactionRequestTypesList.contains(transactionRequestType.value))) ?~! s"${ErrorMessages.InvalidTransactionRequestType} : Invalid value is: '${transactionRequestType.value}' Valid values are: ${validTransactionRequestTypes}"
|
||||
transferCurrencyEqual <- tryo(assert(transBodyJson.value.currency == fromAccount.currency)) ?~! {"Transfer body currency and holder account currency must be the same."}
|
||||
createdTransactionRequest <- Connector.connector.vend.createTransactionRequestv200(u, fromAccount, toAccount, transactionRequestType, transBody)
|
||||
} yield {
|
||||
|
||||
@ -3,9 +3,11 @@ package code.api.v2_1_0
|
||||
import java.text.SimpleDateFormat
|
||||
import code.api.util.ApiRole._
|
||||
import code.api.util.ErrorMessages
|
||||
import code.api.v2_1_0.JSONFactory210
|
||||
import code.model._
|
||||
|
||||
import net.liftweb.http.Req
|
||||
import net.liftweb.json.Extraction
|
||||
import net.liftweb.json.JsonAST.JValue
|
||||
import net.liftweb.util.Props
|
||||
|
||||
@ -71,7 +73,7 @@ trait APIMethods210 {
|
||||
|
||||
|
||||
lazy val sandboxDataImport: PartialFunction[Req, Box[User] => Box[JsonResponse]] = {
|
||||
//import data into the sandbox
|
||||
// Import data into the sandbox
|
||||
case "sandbox" :: "data-import" :: Nil JsonPost json -> _ => {
|
||||
user =>
|
||||
for {
|
||||
@ -86,6 +88,50 @@ trait APIMethods210 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
val getTransactionRequestTypesIsPublic = Props.getBool("apiOptions.getTransactionRequestTypesIsPublic", true)
|
||||
|
||||
resourceDocs += ResourceDoc(
|
||||
getTransactionRequestTypesSupportedByBank,
|
||||
apiVersion,
|
||||
"getTransactionRequestTypesSupportedByBank",
|
||||
"GET",
|
||||
"/banks/BANK_ID/transaction-request-types",
|
||||
"Get the Transaction Request Types supported by the bank",
|
||||
s"""Get the list of the Transaction Request Types supported by the bank.
|
||||
|
|
||||
|${authenticationRequiredMessage(!getTransactionRequestTypesIsPublic)}
|
||||
|""",
|
||||
emptyObjectJson,
|
||||
emptyObjectJson,
|
||||
emptyObjectJson :: Nil,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
List(apiTagBank, apiTagTransactionRequest))
|
||||
|
||||
|
||||
lazy val getTransactionRequestTypesSupportedByBank: PartialFunction[Req, Box[User] => Box[JsonResponse]] = {
|
||||
// Get transaction request types supported by the bank
|
||||
case "banks" :: BankId(bankId) :: "transaction-request-types" :: Nil JsonGet _ => {
|
||||
user =>
|
||||
for {
|
||||
u <- if(getTransactionRequestTypesIsPublic)
|
||||
Box(Some(1))
|
||||
else
|
||||
user ?~! ErrorMessages.UserNotLoggedIn
|
||||
bank <- Bank(bankId) ?~! {ErrorMessages.BankNotFound}
|
||||
// Get Transaction Request Types from Props "transactionRequests_supported_types". Default is empty string
|
||||
transactionRequestTypes <- tryo(Props.get("transactionRequests_supported_types", ""))
|
||||
} yield {
|
||||
// Format the data as json
|
||||
val json = JSONFactory210.createTransactionRequestTypeJSON(transactionRequestTypes.split(",").toList)
|
||||
// Return
|
||||
successJsonResponse(Extraction.decompose(json))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -31,5 +31,17 @@ Berlin 13359, Germany
|
||||
*/
|
||||
package code.api.v2_1_0
|
||||
|
||||
case class TransactionRequestTypeJSON(transaction_request_type: String)
|
||||
case class TransactionRequestTypesJSON(transaction_request_types: List[TransactionRequestTypeJSON])
|
||||
|
||||
object JSONFactory210{
|
||||
def createTransactionRequestTypeJSON(transactionRequestType : String ) : TransactionRequestTypeJSON = {
|
||||
new TransactionRequestTypeJSON(
|
||||
transactionRequestType
|
||||
)
|
||||
}
|
||||
|
||||
def createTransactionRequestTypeJSON(transactionRequestTypes : List[String]) : TransactionRequestTypesJSON = {
|
||||
TransactionRequestTypesJSON(transactionRequestTypes.map(createTransactionRequestTypeJSON))
|
||||
}
|
||||
}
|
||||
@ -181,7 +181,8 @@ object OBPAPI2_1_0 extends OBPRestHelper with APIMethods130 with APIMethods140 w
|
||||
Implementations2_0_0.elasticSearchMetrics,
|
||||
Implementations2_0_0.getCustomers,
|
||||
// New in 2.1.0
|
||||
Implementations2_1_0.sandboxDataImport
|
||||
Implementations2_1_0.sandboxDataImport,
|
||||
Implementations2_1_0.getTransactionRequestTypesSupportedByBank
|
||||
)
|
||||
|
||||
routes.foreach(route => {
|
||||
|
||||
@ -294,7 +294,9 @@ object LocalMappedConnector extends Connector with Loggable {
|
||||
|
||||
override def getTransactionRequestTypesImpl(fromAccount : BankAccount) : Box[List[TransactionRequestType]] = {
|
||||
//TODO: write logic / data access
|
||||
Full(List(TransactionRequestType("SANDBOX_TAN")))
|
||||
// Get Transaction Request Types from Props "transactionRequests_supported_types". Default is empty string
|
||||
val validTransactionRequestTypes = Props.get("transactionRequests_supported_types", "").split(",").map(x => TransactionRequestType(x)).toList
|
||||
Full(validTransactionRequestTypes)
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user