diff --git a/obp-api/src/main/scala/code/api/berlin/group/v1_3/AccountInformationServiceAISApi.scala b/obp-api/src/main/scala/code/api/berlin/group/v1_3/AccountInformationServiceAISApi.scala index 148a33d99..2f1767209 100644 --- a/obp-api/src/main/scala/code/api/berlin/group/v1_3/AccountInformationServiceAISApi.scala +++ b/obp-api/src/main/scala/code/api/berlin/group/v1_3/AccountInformationServiceAISApi.scala @@ -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) } } } diff --git a/obp-api/src/main/scala/code/api/berlin/group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala b/obp-api/src/main/scala/code/api/berlin/group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala index 2ad548821..13aa39560 100644 --- a/obp-api/src/main/scala/code/api/berlin/group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala +++ b/obp-api/src/main/scala/code/api/berlin/group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala @@ -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")) ) ) diff --git a/obp-api/src/main/scala/code/api/util/BerlinGroupError.scala b/obp-api/src/main/scala/code/api/util/BerlinGroupError.scala index 23c85214a..c8095e407 100644 --- a/obp-api/src/main/scala/code/api/util/BerlinGroupError.scala +++ b/obp-api/src/main/scala/code/api/util/BerlinGroupError.scala @@ -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"