libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit e13dde4e98108276635880fa414571bd5b72f49e
parent 225bc67cbecee0f031bf3dfb4d1288235d0720da
Author: ms <ms@taler.net>
Date:   Tue, 11 Jan 2022 14:02:28 +0100

Extend history API.

Diffstat:
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 23++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -1279,6 +1279,27 @@ val sandboxApp: Application.() -> Unit = { }) return@get } + get("/accounts/{account_name}/transactions/{tId}") { + val demobank = ensureDemobank(call) + val bankAccount = getBankAccountFromLabel( + call.getUriComponent("account_name"), + demobank + ) + val authOk: Boolean = bankAccount.isPublic || (!WITH_AUTH) + if (!authOk && (call.request.basicAuth() != bankAccount.owner)) throw forbidden( + "Cannot access bank account ${bankAccount.label}" + ) + // Flow here == Right on the bank account. + val tId = call.parameters["tId"] ?: throw badRequest("URI didn't contain the transaction ID") + val tx: BankAccountTransactionEntity? = transaction { + BankAccountTransactionEntity.find { + BankAccountTransactionsTable.accountServicerReference eq tId + }.firstOrNull() + } + if (tx == null) throw notFound("Transaction $tId wasn't found") + call.respond(getHistoryElementFromTransactionRow(tx)) + return@get + } get("/accounts/{account_name}/transactions") { val demobank = ensureDemobank(call) val bankAccount = getBankAccountFromLabel( @@ -1321,7 +1342,7 @@ val sandboxApp: Application.() -> Unit = { } } } - call.respond(ret) + call.respond(object {val transactions = ret}) return@get } get("/public-accounts") {