diff options
author | Florian Dold <florian@dold.me> | 2021-08-07 13:09:17 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-08-07 13:09:17 +0200 |
commit | 266c074d4e9ed45a0a0f54904e3acde2b84417c7 (patch) | |
tree | 73e3d93580105908ae80231bffb13b2398dd4a50 /nexus/src/main/kotlin/tech/libeufin/nexus/server | |
parent | dfb37242f8f08511098e9ddef427b6bd8b89c61f (diff) | |
download | libeufin-266c074d4e9ed45a0a0f54904e3acde2b84417c7.tar.gz libeufin-266c074d4e9ed45a0a0f54904e3acde2b84417c7.tar.bz2 libeufin-266c074d4e9ed45a0a0f54904e3acde2b84417c7.zip |
deletion and listing of payment initiations
Diffstat (limited to 'nexus/src/main/kotlin/tech/libeufin/nexus/server')
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt index 97de0221..a3b17c43 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt @@ -418,11 +418,11 @@ fun serverMain(dbName: String, host: String, port: Int) { call.respond(object {}) return@post } - get("/bank-accounts/{accountid}/schedule") { + get("/bank-accounts/{accountId}/schedule") { requireSuperuser(call.request) val resp = jacksonObjectMapper().createObjectNode() val ops = jacksonObjectMapper().createObjectNode() - val accountId = ensureNonNull(call.parameters["accountid"]) + val accountId = ensureNonNull(call.parameters["accountId"]) resp.set<JsonNode>("schedule", ops) transaction { NexusBankAccountEntity.findByName(accountId) @@ -443,10 +443,10 @@ fun serverMain(dbName: String, host: String, port: Int) { return@get } - post("/bank-accounts/{accountid}/schedule") { + post("/bank-accounts/{accountId}/schedule") { requireSuperuser(call.request) val schedSpec = call.receive<CreateAccountTaskRequest>() - val accountId = ensureNonNull(call.parameters["accountid"]) + val accountId = ensureNonNull(call.parameters["accountId"]) transaction { authenticateRequest(call.request) NexusBankAccountEntity.findByName(accountId) @@ -635,6 +635,16 @@ fun serverMain(dbName: String, host: String, port: Int) { return@get } + delete("/bank-accounts/{accountId}/payment-initiations/{uuid}") { + requireSuperuser(call.request) + val uuid = ensureLong(call.parameters["uuid"]) + transaction { + val paymentInitiation = getPaymentInitiation(uuid) + paymentInitiation.delete() + } + call.respond(NexusMessage(message = "Payment initiation $uuid deleted")) + } + // Adds a new payment initiation. post("/bank-accounts/{accountid}/payment-initiations") { requireSuperuser(call.request) @@ -644,7 +654,7 @@ fun serverMain(dbName: String, host: String, port: Int) { authenticateRequest(call.request) val bankAccount = NexusBankAccountEntity.findByName(accountId) if (bankAccount == null) { - throw NexusError(HttpStatusCode.NotFound, "unknown bank account") + throw NexusError(HttpStatusCode.NotFound, "unknown bank account ($accountId)") } val amount = parseAmount(body.amount) val paymentEntity = addPaymentInitiation( |