commit ae7897d8bd68640e2bb327bbb8448b3b443fed3a
parent d446014185a11b5554e01e2628383e14f613985e
Author: MS <ms@taler.net>
Date: Fri, 4 Dec 2020 13:24:28 +0100
abstract over Camt type
Diffstat:
3 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/integration-tests/tests.py b/integration-tests/tests.py
@@ -379,10 +379,10 @@ def test_sandbox_camt():
json=payment_instruction
)
)
- resp = assertResponse(
+
+ assertResponse(
post(
- f"{S}/admin/payments/camt/53",
- data="GB33BUKB20201555555555"
+ f"{S}/admin/payments/camt",
+ json=dict(iban="GB33BUKB20201555555555", type=53)
)
)
- print(resp.text)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
@@ -77,6 +77,11 @@ data class DateRange(
val endDate: Long
)
+data class CamtParams(
+ val iban: String,
+ val type: Int
+)
+
data class BankAccountStatements(
var bankAccountStatements: MutableList<BankAccountStatement> = mutableListOf()
)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -235,10 +235,11 @@ fun serverMain(dbName: String) {
call.respondText("Hello, this is Sandbox\n", ContentType.Text.Plain)
}
// only reason for a post is to hide the iban (to some degree.)
- post("/admin/payments/camt/53") {
- val iban = call.receiveText()
- val history = historyForAccount(iban)
- val camt53 = buildCamtString(53, iban, history)
+ post("/admin/payments/camt") {
+ val body = call.receive<CamtParams>()
+ val history = historyForAccount(body.iban)
+ SandboxAssert(body.type == 53, "Only Camt.053 is implemented")
+ val camt53 = buildCamtString(body.type, body.iban, history)
call.respondText(camt53, ContentType.Text.Xml, HttpStatusCode.OK)
return@post
}