mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 14:46:49 +00:00
feature/bookingStatus parameter in GET Transactions List
This commit is contained in:
parent
7330abde8c
commit
c6ca8afcc9
@ -10,6 +10,7 @@ import code.api.util.APIUtil.{passesPsd2Aisp, _}
|
||||
import code.api.util.ApiTag._
|
||||
import code.api.util.ErrorMessages._
|
||||
import code.api.util.NewStyle.HttpCode
|
||||
import code.api.util.NewStyle.function.extractQueryParams
|
||||
import code.api.util._
|
||||
import code.api.util.newstyle.ViewNewStyle
|
||||
import code.consent.{ConsentStatus, Consents}
|
||||
@ -25,6 +26,7 @@ import com.openbankproject.commons.model.enums.{ChallengeType, StrongCustomerAut
|
||||
import net.liftweb
|
||||
import net.liftweb.common.{Empty, Full}
|
||||
import net.liftweb.http.js.JE.JsRaw
|
||||
import net.liftweb.http.provider.HTTPParam
|
||||
import net.liftweb.http.rest.RestHelper
|
||||
import net.liftweb.json
|
||||
import net.liftweb.json._
|
||||
@ -894,7 +896,7 @@ of the "Read Transaction List" call within the _links subfield.
|
||||
"/accounts/ACCOUNT_ID/transactions",
|
||||
"Read transaction list of an account",
|
||||
s"""${mockedDataText(false)}
|
||||
Read transaction reports or transaction lists of a given account ddressed by "account-id",
|
||||
Read transaction reports or transaction lists of a given account dressed by "account-id",
|
||||
depending on the steering parameter "bookingStatus" together with balances.
|
||||
For a given account, additional parameters are e.g. the attributes "dateFrom" and "dateTo".
|
||||
The ASPSP might add balance information, if transaction lists without balances are not supported. """,
|
||||
@ -974,11 +976,18 @@ The ASPSP might add balance information, if transaction lists without balances a
|
||||
params <- Future { createQueriesByHttpParams(callContext.get.requestHeaders)} map {
|
||||
x => fullBoxOrException(x ~> APIFailureNewStyle(UnknownError, 400, callContext.map(_.toLight)))
|
||||
} map { unboxFull(_) }
|
||||
bookingStatus = APIUtil.getHttpRequestUrlParam(cc.url, "bookingStatus")
|
||||
_ <- Helper.booleanToFuture(s"$InvalidUrlParameters bookingStatus parameter must take two one of those values : booked, pending or both!", 400, callContext) {
|
||||
bookingStatus match {
|
||||
case "booked" | "pending" | "both" => true
|
||||
case _ => false
|
||||
}
|
||||
}
|
||||
(transactions, callContext) <-bankAccount.getModeratedTransactionsFuture(bank, Full(u), view, callContext, params) map {
|
||||
x => fullBoxOrException(x ~> APIFailureNewStyle(UnknownError, 400, callContext.map(_.toLight)))
|
||||
} map { unboxFull(_) }
|
||||
} yield {
|
||||
(JSONFactory_BERLIN_GROUP_1_3.createTransactionsJson(bankAccount, transactions), callContext)
|
||||
(JSONFactory_BERLIN_GROUP_1_3.createTransactionsJson(bankAccount, transactions, bookingStatus), callContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -553,7 +553,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
|
||||
// )
|
||||
// }
|
||||
|
||||
def createTransactionsJson(bankAccount: BankAccount, transactions: List[ModeratedTransaction], transactionRequests: List[TransactionRequest] = Nil) : TransactionsJsonV13 = {
|
||||
def createTransactionsJson(bankAccount: BankAccount, transactions: List[ModeratedTransaction], bookingStatus: String, transactionRequests: List[TransactionRequest] = Nil) : TransactionsJsonV13 = {
|
||||
val accountId = bankAccount.accountId.value
|
||||
val (iban: String, bban: String) = getIbanAndBban(bankAccount)
|
||||
|
||||
@ -570,8 +570,8 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
|
||||
TransactionsJsonV13(
|
||||
account,
|
||||
TransactionsV13Transactions(
|
||||
booked = if(bookedTransactions.isEmpty) None else Some(bookedTransactions),
|
||||
pending = if(pendingTransactions.isEmpty) None else Some(pendingTransactions),
|
||||
booked = if(bookingStatus == "booked" || bookingStatus == "both") Some(bookedTransactions) else None,
|
||||
pending = if(bookingStatus == "pending" || bookingStatus == "both") Some(pendingTransactions) else None,
|
||||
_links = TransactionsV13TransactionsLinks(LinkHrefJson(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/accounts/$accountId"))
|
||||
)
|
||||
)
|
||||
|
||||
@ -76,6 +76,8 @@ object BerlinGroupError {
|
||||
|
||||
case "401" if message.contains("OBP-20060") => "ROLE_INVALID"
|
||||
|
||||
case "400" if message.contains("OBP-10034") => "PARAMETER_NOT_CONSISTENT"
|
||||
|
||||
case "400" if message.contains("OBP-35018") => "CONSENT_UNKNOWN"
|
||||
case "400" if message.contains("OBP-35001") => "CONSENT_UNKNOWN"
|
||||
case "403" if message.contains("OBP-35001") => "CONSENT_UNKNOWN"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user