commit a58a9c2258d547a280b961436eb330a63230fa1e
parent 170fd3491c331b70605a08b4aaa452d01ef732c3
Author: Florian Dold <florian.dold@gmail.com>
Date: Tue, 9 Jun 2020 12:55:31 +0530
ebics/fetch-c52
Diffstat:
2 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
@@ -210,17 +210,19 @@ suspend fun fetchEbicsC5x(
val orderParamsJson = EbicsStandardOrderParamsJson(
EbicsDateRangeJson(start, end)
)
- /** More types C52/C54 .. forthcoming */
- if (historyType != "C53") throw NexusError(
- HttpStatusCode.InternalServerError,
- "Ebics query tried on unknown message $historyType"
- )
val response = doEbicsDownloadTransaction(
client,
subscriberDetails,
historyType,
orderParamsJson.toOrderParams()
)
+ when (historyType) {
+ "C52" -> {}
+ "C53" -> {}
+ else -> {
+ throw NexusError(HttpStatusCode.BadRequest, "history type '$historyType' not supported")
+ }
+ }
when (response) {
is EbicsDownloadSuccessResult -> {
response.orderData.unzipWithLambda {
@@ -237,7 +239,7 @@ suspend fun fetchEbicsC5x(
if (oldMsg == null) {
NexusBankMessageEntity.new {
this.bankConnection = conn
- this.code = "C53"
+ this.code = historyType
this.messageId = msgId
this.message = ExposedBlob(it.second.toByteArray(Charsets.UTF_8))
}
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -964,6 +964,28 @@ fun serverMain(dbName: String) {
call.respond(object {})
}
+ post("/bank-connections/{connid}/ebics/fetch-c52") {
+ val paramsJson = if (call.request.hasBody()) {
+ call.receive<EbicsDateRangeJson>()
+ } else {
+ null
+ }
+ val ret = transaction {
+ val user = authenticateRequest(call.request)
+ val conn = requireBankConnection(call, "connid")
+ if (conn.type != "ebics") {
+ throw NexusError(HttpStatusCode.BadRequest, "bank connection is not of type 'ebics'")
+ }
+ object {
+ val subscriber = getEbicsSubscriberDetails(user.id.value, conn.id.value)
+ val connId = conn.id.value
+ }
+
+ }
+ fetchEbicsC5x("C52", client, ret.connId, paramsJson?.start, paramsJson?.end, ret.subscriber)
+ call.respond(object {})
+ }
+
post("/bank-connections/{connid}/ebics/send-ini") {
val subscriber = transaction {
val user = authenticateRequest(call.request)