gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: payto / amount parsers (untested)


From: gnunet
Subject: [libeufin] branch master updated: payto / amount parsers (untested)
Date: Wed, 08 Apr 2020 18:53:50 +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 d11290f  payto / amount parsers (untested)
d11290f is described below

commit d11290fa475eb5bde452be09850738c6320feff3
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Apr 8 18:53:25 2020 +0200

    payto / amount parsers (untested)
---
 nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt | 34 +++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
index bc18142..c2d2472 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
@@ -3,6 +3,7 @@ package tech.libeufin.nexus
 import io.ktor.application.call
 import io.ktor.http.ContentType
 import io.ktor.http.HttpStatusCode
+import io.ktor.request.receive
 import io.ktor.response.respond
 import io.ktor.response.respondText
 import io.ktor.routing.Route
@@ -13,7 +14,9 @@ import org.jetbrains.exposed.sql.*
 import org.jetbrains.exposed.sql.transactions.transaction
 import org.joda.time.DateTime
 import org.joda.time.format.DateTimeFormat
+import tech.libeufin.util.Amount
 import tech.libeufin.util.CryptoUtil
+import java.util.*
 import kotlin.math.abs
 
 class Taler(app: Route) {
@@ -69,8 +72,33 @@ class Taler(app: Route) {
         val row_id: Long
     )
 
+    /** Helper data structures. */
+    data class Payto(
+        val name: String,
+        val iban: String,
+        val bic: String?
+    )
+    data class AmountWithCurrency(
+        val currency: String,
+        val amount: Amount
+    )
+
     /** Helper functions */
 
+    fun parsePayto(paytoUri: String): Payto {
+        val match = 
Regex("payto://.*/([A-Z0-9]+)/([A-Z0-9]+)?\\?name=(\\w+)").find(paytoUri) ?: 
throw
+                NexusError(HttpStatusCode.BadRequest, "invalid payto URI 
($paytoUri)")
+        val (iban, bic, name) = match.destructured
+        return Payto(name, iban, bic)
+    }
+
+    fun parseAmount(amount: String): AmountWithCurrency {
+        val match = 
Regex("([A-Z][A-Z][A-Z]):([0-9]+(\\.[0-9]+)?)").find(amount) ?: throw
+                NexusError(HttpStatusCode.BadRequest, "invalid payto URI 
($amount)")
+        val (currency, number) = match.destructured
+        return AmountWithCurrency(currency, Amount(number))
+    }
+
     private fun <T : Entity<Long>> SizedIterable<T>.orderTaler(delta: Int): 
List<T> {
         return if (delta < 0) {
             this.sortedByDescending { it.id }
@@ -122,7 +150,11 @@ class Taler(app: Route) {
 
     /** attaches Taler endpoints to the main Web server */
     init {
-        app.post("/taler/transfer") {
+        app.post("/taler/admin/add-incoming") {
+            val addIncomingData = call.receive<TalerAdminAddIncoming>()
+            /** Decompose amount and payto fields.  */
+
+
             call.respond(HttpStatusCode.OK, NexusErrorJson("Not implemented"))
             return@post
         }

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



reply via email to

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