libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 891efae8b0e67edc11b8634f75b4d6acd4e45c5e
parent 2fb1201fdfb84e2c60311e55998a4ec58d4cf1dd
Author: Florian Dold <florian.dold@gmail.com>
Date:   Sun, 24 May 2020 16:19:02 +0530

differentiate connection type

Diffstat:
Mnexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 38++++++++++++++++++++------------------
1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -592,29 +592,31 @@ fun serverMain() { val user = authenticateRequest(call.request) when (body) { is CreateBankConnectionFromBackupRequestJson -> { - createEbicsBankConnectionFromBackup(body.name, user, body.passphrase, body.data) + val type = body.data.get("type") + if (type == null || !type.isTextual()) { + throw NexusError(HttpStatusCode.BadRequest, "backup needs type") + } + when (type.textValue()) { + "ebics" -> { + createEbicsBankConnectionFromBackup(body.name, user, body.passphrase, body.data) + } + else -> { + throw NexusError(HttpStatusCode.BadRequest, "backup type not supported") + } + } } is CreateBankConnectionFromNewRequestJson -> { - createEbicsBankConnection(body.name, user, body.data) + when (body.type) { + "ebics" -> { + createEbicsBankConnection(body.name, user, body.data) + } + else -> { + throw NexusError(HttpStatusCode.BadRequest, "connection type not supported") + } + } } } } -// val bankConnectionName = body.name -// val bankConnectionType = body.get("type").textValue() -// transaction { -// val user = authenticateRequest(call.request) -// when (bankConnectionType) { -// "ebics" -> { -// createEbicsBankConnection(bankConnectionName, user, body) -// } -// else -> { -// throw NexusError( -// HttpStatusCode.BadRequest, -// "Invalid bank connection type '${bankConnectionType}'" -// ) -// } -// } -// } call.respond(object {}) }