From f23ba0cc186099898dbbca0bca44bd6130312f95 Mon Sep 17 00:00:00 2001 From: MS Date: Thu, 22 Dec 2022 15:48:51 +0100 Subject: Circuit API: GET /config. --- .../kotlin/tech/libeufin/sandbox/CircuitApi.kt | 32 ++++++++++++++++++++++ .../src/main/kotlin/tech/libeufin/sandbox/Main.kt | 6 +++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 sandbox/src/main/kotlin/tech/libeufin/sandbox/CircuitApi.kt (limited to 'sandbox/src/main/kotlin/tech') 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") { -- cgit v1.2.3