summaryrefslogtreecommitdiff
path: root/sandbox/src/main/kotlin/tech
diff options
context:
space:
mode:
authorMS <ms@taler.net>2022-12-22 15:48:51 +0100
committerMS <ms@taler.net>2022-12-22 15:48:51 +0100
commitf23ba0cc186099898dbbca0bca44bd6130312f95 (patch)
tree0d5c1cf68400ed1a22c1814312c076a596420cdc /sandbox/src/main/kotlin/tech
parente6ee5db0b3de1ffe2a3aebbdb46023610005aaa8 (diff)
downloadlibeufin-f23ba0cc186099898dbbca0bca44bd6130312f95.tar.gz
libeufin-f23ba0cc186099898dbbca0bca44bd6130312f95.tar.bz2
libeufin-f23ba0cc186099898dbbca0bca44bd6130312f95.zip
Circuit API: GET /config.
Diffstat (limited to 'sandbox/src/main/kotlin/tech')
-rw-r--r--sandbox/src/main/kotlin/tech/libeufin/sandbox/CircuitApi.kt32
-rw-r--r--sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt6
2 files changed, 37 insertions, 1 deletions
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/CircuitApi.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/CircuitApi.kt
new file mode 100644
index 00000000..0becab7b
--- /dev/null
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/CircuitApi.kt
@@ -0,0 +1,32 @@
+package tech.libeufin.sandbox
+
+import io.ktor.application.*
+import io.ktor.response.*
+import io.ktor.routing.*
+
+// CIRCUIT API TYPES
+
+// Configuration response:
+class ConfigResp(
+ val name: String = "circuit",
+ val version: String = SANDBOX_VERSION,
+ val ratios_and_fees: RatioAndFees
+)
+
+// After fixing #7527, the values held by this
+// type must be read from the configuration.
+class RatioAndFees(
+ val buy_at_ratio: Float = 1F,
+ val sell_at_ratio: Float = 0.05F,
+ val buy_in_fee: Float = 0F,
+ val sell_out_fee: Float = 0F
+)
+
+fun circuitApi(circuitRoute: Route) {
+ circuitRoute.get("/config") {
+ call.respond(ConfigResp(
+ ratios_and_fees = RatioAndFees()
+ ))
+ return@get
+ }
+} \ No newline at end of file
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 447aa0b5..1bf9f73d 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -66,6 +66,7 @@ import javax.xml.bind.JAXBContext
import kotlin.system.exitProcess
val logger: Logger = LoggerFactory.getLogger("tech.libeufin.sandbox")
+const val SANDBOX_VERSION = "0:0:0"
const val SANDBOX_DB_ENV_VAR_NAME = "LIBEUFIN_SANDBOX_DB_CONNECTION"
private val adminPassword: String? = System.getenv("LIBEUFIN_SANDBOX_ADMIN_PASSWORD")
var WITH_AUTH = true // Needed by helpers too, hence not making it private.
@@ -1136,7 +1137,7 @@ val sandboxApp: Application.() -> Unit = {
val demobank = ensureDemobank(call)
call.respond(SandboxConfig(
name = "taler-bank-integration",
- version = "0:0:0",
+ version = SANDBOX_VERSION,
currency = demobank.currency
))
return@get
@@ -1204,6 +1205,9 @@ val sandboxApp: Application.() -> Unit = {
return@get
}
}
+ route("/circuit-api") {
+ circuitApi(this)
+ }
// Talk to Web UI.
route("/access-api") {
post("/accounts/{account_name}/transactions") {