summaryrefslogtreecommitdiff
path: root/nexus/src/main
diff options
context:
space:
mode:
authorMS <ms@taler.net>2020-05-14 19:10:54 +0200
committerMS <ms@taler.net>2020-05-14 19:10:54 +0200
commita47fe8380d8048a3629b385d9e336e80eecd9885 (patch)
treeec9dd7ad508fb841ee20d84e9dd015f2bd48b1d1 /nexus/src/main
parent84f63adc02b66873a228e8432ace448a23509760 (diff)
downloadlibeufin-a47fe8380d8048a3629b385d9e336e80eecd9885.tar.gz
libeufin-a47fe8380d8048a3629b385d9e336e80eecd9885.tar.bz2
libeufin-a47fe8380d8048a3629b385d9e336e80eecd9885.zip
HTD message to new API.
Organize the HTD message type into the ../send{MSG} style.
Diffstat (limited to 'nexus/src/main')
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt42
1 files changed, 41 insertions, 1 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 43db3b26..d2674501 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -52,6 +52,7 @@ import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.slf4j.event.Level
import tech.libeufin.util.*
+import tech.libeufin.util.ebics_h004.HTDResponseOrderData
import java.text.DateFormat
import java.util.zip.InflaterInputStream
import javax.crypto.EncryptedPrivateKeyInfo
@@ -105,6 +106,45 @@ suspend fun handleEbicsSendMSG(
}
return response
}
+ "HTD" -> {
+ val response = doEbicsDownloadTransaction(
+ httpClient, subscriber, "HTD", EbicsStandardOrderParams()
+ )
+ when (response) {
+ is EbicsDownloadBankErrorResult -> {
+ throw NexusError(
+ HttpStatusCode.BadGateway,
+ response.returnCode.errorCode
+ )
+ }
+ is EbicsDownloadSuccessResult -> {
+ val payload = XMLUtil.convertStringToJaxb<HTDResponseOrderData>(
+ response.orderData.toString(Charsets.UTF_8)
+ )
+ if (sync) {
+ transaction {
+ payload.value.partnerInfo.accountInfoList?.forEach {
+ val bankAccount = BankAccountEntity.new(id = it.id) {
+ accountHolder = it.accountHolder ?: "NOT-GIVEN"
+ iban = extractFirstIban(it.accountNumberList)
+ ?: throw NexusError(HttpStatusCode.NotFound, reason = "bank gave no IBAN")
+ bankCode = extractFirstBic(it.bankCodeList) ?: throw NexusError(
+ HttpStatusCode.NotFound,
+ reason = "bank gave no BIC"
+ )
+ }
+ BankAccountMapEntity.new {
+ ebicsSubscriber = getEbicsTransport(userId, transportId)
+ this.nexusUser = nexusUser
+ this.bankAccount = bankAccount
+ }
+ }
+ }
+ }
+ response.orderData.toString(Charsets.UTF_8)
+ }
+ }
+ }
"HEV" -> {
val request = makeEbicsHEVRequest(subscriber)
httpClient.postToBank(subscriber.ebicsUrl, request)
@@ -529,7 +569,7 @@ fun main() {
* Sends the bank a message "MSG" according to the transport
* "transportName". DOES alterate DB tables.
*/
- post("/bank-transports/{transportName}/sync{MSG}") {
+ post("/bank-transports/sync{MSG}") {
val userId = authenticateRequest(call.request.headers["Authorization"])
val body = call.receive<Transport>()
when (body.type) {