gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libeufin] branch master updated: fix /admin/customers/:id


From: gnunet
Subject: [GNUnet-SVN] [libeufin] branch master updated: fix /admin/customers/:id response
Date: Fri, 27 Sep 2019 00:44:45 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 263dab1  fix /admin/customers/:id response
263dab1 is described below

commit 263dab137d88848195188a8fa263e37e1afd9ac9
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri Sep 27 00:38:51 2019 +0200

    fix /admin/customers/:id response
---
 src/main/kotlin/Main.kt               | 37 ++++++++++++++++++++++++-----------
 src/main/kotlin/tech/libeufin/JSON.kt |  1 +
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt
index 7b98666..c36849d 100644
--- a/src/main/kotlin/Main.kt
+++ b/src/main/kotlin/Main.kt
@@ -34,15 +34,9 @@ import tech.libeufin.messages.HEVResponseDataType
 import javax.xml.bind.JAXBElement
 import io.ktor.features.*
 import io.netty.handler.codec.http.HttpContent
-import org.jetbrains.exposed.sql.Query
-import org.jetbrains.exposed.sql.insert
-import org.jetbrains.exposed.sql.insertAndGetId
-import org.jetbrains.exposed.sql.select
+import org.jetbrains.exposed.sql.*
 import org.jetbrains.exposed.sql.transactions.transaction
-import tech.libeufin.tech.libeufin.BankCustomer
-import tech.libeufin.tech.libeufin.BankCustomers
-import tech.libeufin.tech.libeufin.createSubscriber
-import tech.libeufin.tech.libeufin.dbCreateTables
+import tech.libeufin.tech.libeufin.*
 import java.lang.NumberFormatException
 import java.text.*
 
@@ -105,7 +99,8 @@ fun main() {
             get("/admin/customers/{id}") {
 
                 var id = -1
-                var result = -1
+                var tmp: CustomerInfo? = null
+                var result: ResultRow? = null
 
                 try {
                     id = call.parameters["id"]!!.toInt()
@@ -116,12 +111,32 @@ fun main() {
                         SandboxError(e.message.toString())
                     )
                 }
+
                 transaction {
-                    val result = BankCustomers.select{BankCustomers.id eq 1}
+                    val singleton = BankCustomers.select { BankCustomers.id eq 
id }
+                    result = singleton.firstOrNull()
+
+                    if (null != result)
+                        tmp = CustomerInfo(
+                            result?.get(BankCustomers.name) as String,
+                            customerEbicsInfo = CustomerEbicsInfo(
+                                
result?.get(BankCustomers.ebicsSubscriber)?.value as Int
+                        )
+                    )
+
                 }
+
+                if (null == result) {
+                    call.respond(
+                        HttpStatusCode.NotFound,
+                        SandboxError("id $id not found")
+                    )
+                    return@get
+                }
+
                 call.respond(
                     HttpStatusCode.OK,
-                    CustomerInfo(customerEbicsInfo = CustomerEbicsInfo(0))
+                    tmp as CustomerInfo
                 )
             }
 
diff --git a/src/main/kotlin/tech/libeufin/JSON.kt 
b/src/main/kotlin/tech/libeufin/JSON.kt
index ba4c964..2b36b7d 100644
--- a/src/main/kotlin/tech/libeufin/JSON.kt
+++ b/src/main/kotlin/tech/libeufin/JSON.kt
@@ -23,6 +23,7 @@ data class CustomerResponse (
  * Response for GET /admin/customers/:id
  */
 data class CustomerInfo (
+    val name: String,
     val customerEbicsInfo: CustomerEbicsInfo
 )
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]