Merge pull request #919 from hongwei1/develop

#724 added getFirehoseTransactions
This commit is contained in:
Simon Redfern 2018-02-12 04:53:27 -05:00 committed by GitHub
commit cd694b3416
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 0 deletions

View File

@ -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,

View File

@ -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