gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: HTD message to new API.


From: gnunet
Subject: [libeufin] branch master updated: HTD message to new API.
Date: Thu, 14 May 2020 19:12:15 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new a47fe83  HTD message to new API.
a47fe83 is described below

commit a47fe8380d8048a3629b385d9e336e80eecd9885
Author: MS <address@hidden>
AuthorDate: Thu May 14 19:10:54 2020 +0200

    HTD message to new API.
    
    Organize the HTD message type into the ../send{MSG} style.
---
 integration-tests/test-ebics-new.py               | 20 ++++++-----
 nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 42 ++++++++++++++++++++++-
 2 files changed, 53 insertions(+), 9 deletions(-)

diff --git a/integration-tests/test-ebics-new.py 
b/integration-tests/test-ebics-new.py
index 0eb440b..106f64e 100755
--- a/integration-tests/test-ebics-new.py
+++ b/integration-tests/test-ebics-new.py
@@ -222,19 +222,19 @@ assertResponse(
     )
 )
 
-nexus.terminate()
-sandbox.terminate()
-exit(44)
-
-#2.b
+#2.b, download keys from the bank (HPB)
 assertResponse(
     post(
-        "http://localhost:5001/ebics/subscribers/{}/sync".format(USERNAME),
-        json=dict()
+        "http://localhost:5001/bank-transports/syncHPB";,
+        json=dict(
+          type="ebics",
+          name="my-ebics"
+        ),
+        headers=dict(Authorization=USER_AUTHORIZATION_HEADER)
     )
 )
 
-#2.c
+#2.c, fetch bank account information
 assertResponse(
     post(
         
"http://localhost:5001/ebics/subscribers/{}/fetch-accounts".format(USERNAME),
@@ -242,6 +242,10 @@ assertResponse(
     )
 )
 
+nexus.terminate()
+sandbox.terminate()
+exit(44)
+
 #3
 assertResponse(
     post(
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 43db3b2..d267450 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) {

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]