commit 52d80a4e5ceaec11b741a480d92b18b19e0e2795
parent bb01cf635a1bc206a4ffb583f550cd336a9f2500
Author: ms <ms@taler.net>
Date: Tue, 19 Oct 2021 10:52:15 +0200
endpoint to list public accounts
Diffstat:
3 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -116,6 +116,7 @@ object DemobankCustomersTable : LongIdTable() {
val username = text("username")
val passwordHash = text("passwordHash")
val isDebit = bool("isDebit").default(false)
+ val name = text("name").nullable()
}
class DemobankCustomerEntity(id: EntityID<Long>) : LongEntity(id) {
@@ -126,6 +127,7 @@ class DemobankCustomerEntity(id: EntityID<Long>) : LongEntity(id) {
var username by DemobankCustomersTable.username
var passwordHash by DemobankCustomersTable.passwordHash
var isDebit by DemobankCustomersTable.isDebit
+ var name by DemobankCustomersTable.name
}
/**
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
@@ -77,6 +77,19 @@ data class CustomerRegistration(
val password: String
)
+/**
+ * More detailed information about one customer. This type
+ * is mainly required along public histories and/or customer
+ * data unrelated to the Access API.
+ */
+data class CustomerInfo(
+ val username: String,
+ val name: String,
+ val balance: String,
+ val iban: String,
+ // more ..?
+)
+
data class CamtParams(
// name/label of the bank account to query.
val bankaccount: String,
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -1106,8 +1106,27 @@ val sandboxApp: Application.() -> Unit = {
// [...]
get("/public-accounts") {
- // List public accounts. Does not require any authentication.
- // XXX: New!
+ val ret = object {
+ val publicAccounts = mutableListOf<CustomerInfo>()
+ }
+ transaction {
+ DemobankCustomerEntity.find {
+ DemobankCustomersTable.isPublic eq true
+ }.forEach {
+ ret.publicAccounts.add(
+ CustomerInfo(
+ username = it.username,
+ balance = it.balance,
+ iban = "To Do",
+ name = it.name ?: throw internalServerError(
+ "Found name-less public account, username: ${it.username}"
+ )
+ )
+ )
+ }
+ }
+ call.respond(ret)
+ return@get
}
get("/public-accounts/{account_name}/history") {