libeufin

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

commit 089a03b96a074731b058a5d5576837203a48386a
parent e732d76b2ea1f6095186a1b5b84926573d620f8b
Author: Marcello Stanisci <ms@taler.net>
Date:   Fri,  8 May 2020 18:26:08 +0200

add GET /bank-accounts, fix GET /user.

Diffstat:
Mnexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt | 6++++++
Mnexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 27++++++++++++++++++---------
2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt @@ -95,6 +95,12 @@ data class NexusUser( val transports: MutableList<Any> = mutableListOf() ) +/** is "UserResponse" in the API spec */ +data class UserResponse( + val username: String, + val superuser: Boolean +) + /** Instructs the nexus to CREATE a new user */ data class User( val username: String, diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -133,17 +133,14 @@ fun main() { */ get("/user") { val userId = authenticateRequest(call.request.headers["Authorization"]) - val bankAccounts = BankAccounts() - getBankAccountsFromNexusUserId(userId).forEach { - bankAccounts.accounts.add( - BankAccount( - holder = it.accountHolder, - iban = it.iban, - bic = it.bankCode, - account = it.id.value - ) + val ret = transaction { + NexusUserEntity.findById(userId) + UserResponse( + username = userId, + superuser = userId.equals("admin") ) } + call.respond(HttpStatusCode.OK, ret) return@get } /** @@ -172,6 +169,18 @@ fun main() { * Shows the bank accounts belonging to the requesting user. */ get("/bank-accounts") { + val userId = authenticateRequest(call.request.headers["Authorization"]) + val bankAccounts = BankAccounts() + getBankAccountsFromNexusUserId(userId).forEach { + bankAccounts.accounts.add( + BankAccount( + holder = it.accountHolder, + iban = it.iban, + bic = it.bankCode, + account = it.id.value + ) + ) + } return@get } /**