diff --git a/src/main/scala/code/api/v3_0_0/APIMethods300.scala b/src/main/scala/code/api/v3_0_0/APIMethods300.scala index 7b9b6c364..2beae5917 100644 --- a/src/main/scala/code/api/v3_0_0/APIMethods300.scala +++ b/src/main/scala/code/api/v3_0_0/APIMethods300.scala @@ -445,6 +445,56 @@ trait APIMethods300 { } } + + resourceDocs += ResourceDoc( + getFirehoseTransactionsForBankAccount, + implementedInApiVersion, + "getFirehoseTransactionsForBankAccount", + "GET", + "/banks/BANK_ID/firehose/accounts/ACCOUNT_ID/views/VIEW_ID/transactions", + "Get Firehose Transactions for Account (Firehose)", + s""" + |Get firehose transactions for Account. + | + |${authenticationRequiredMessage(true)} + | + |""".stripMargin, + emptyObjectJson, + transactionsJsonV300, + List(UserNotLoggedIn, FirehoseViewsNotAllowedOnThisInstance, UserHasMissingRoles, UnknownError), + Catalogs(Core, PSD2, OBWG), + List(apiTagAccount, apiTagFirehoseData)) + + lazy val getFirehoseTransactionsForBankAccount : OBPEndpoint = { + //get private accounts for all banks + case "banks" :: BankId(bankId):: "firehose" :: "accounts" :: AccountId(accountId) :: "views" :: ViewId(viewId) :: "transactions" :: Nil JsonGet json => { + cc => + val res = + for { + (user, callContext) <- extractCallContext(UserNotLoggedIn, cc) + u <- unboxFullAndWrapIntoFuture{ user } + _ <- Helper.booleanToFuture(failMsg = FirehoseViewsNotAllowedOnThisInstance +" or " + UserHasMissingRoles + CanUseFirehoseAtAnyBank ) { + MapperViews.canUseFirehose(u) + } + bankAccount <- Future { BankAccount(bankId, accountId, callContext) } map { + x => fullBoxOrException(x ?~! BankAccountNotFound) + } map { unboxFull(_) } + view <- Views.views.vend.viewFuture(viewId, BankIdAccountId(bankAccount.bankId, bankAccount.accountId)) map { + x => fullBoxOrException(x ?~! ViewNotFound) + } map { unboxFull(_) } + } yield { + for { + //Note: error handling and messages for getTransactionParams are in the sub method + params <- getTransactionParams(json) + transactions <- bankAccount.getModeratedTransactions(user, view, params: _*)(callContext) + } yield { + (createTransactionsJson(transactions), callContext) + } + } + res map { fullBoxOrException(_) } map { unboxFull(_) } + } + } + resourceDocs += ResourceDoc( getCoreTransactionsForBankAccount, implementedInApiVersion, diff --git a/src/main/scala/code/api/v3_0_0/OBPAPI3_0_0.scala b/src/main/scala/code/api/v3_0_0/OBPAPI3_0_0.scala index d68e1ab6d..2d28005d0 100644 --- a/src/main/scala/code/api/v3_0_0/OBPAPI3_0_0.scala +++ b/src/main/scala/code/api/v3_0_0/OBPAPI3_0_0.scala @@ -264,6 +264,7 @@ object OBPAPI3_0_0 extends OBPRestHelper with APIMethods130 with APIMethods140 w Implementations3_0_0.getEntitlementRequestsForCurrentUser :: Implementations3_0_0.getFirehoseAccountsAtOneBank :: Implementations3_0_0.getEntitlementsForCurrentUser :: + Implementations3_0_0.getFirehoseTransactionsForBankAccount :: Nil