[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: fetching accounts, store raw data into
From: |
gnunet |
Subject: |
[libeufin] branch master updated: fetching accounts, store raw data into database |
Date: |
Fri, 19 Jun 2020 16:12:00 +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 3cb4756 fetching accounts, store raw data into database
3cb4756 is described below
commit 3cb47562212364162a82c83fd73074573d9f883e
Author: MS <ms@taler.net>
AuthorDate: Fri Jun 19 16:11:38 2020 +0200
fetching accounts, store raw data into database
---
nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 18 +++++++++-
.../kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt | 40 ++++++++++++++++++++++
2 files changed, 57 insertions(+), 1 deletion(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index fd12235..043358a 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -30,6 +30,7 @@ import org.jetbrains.exposed.sql.StdOutSqlLogger
import org.jetbrains.exposed.sql.addLogger
import org.jetbrains.exposed.sql.transactions.TransactionManager
import org.jetbrains.exposed.sql.transactions.transaction
+import tech.libeufin.nexus.NexusBankAccountsTable.entityId
import tech.libeufin.util.EbicsInitState
import tech.libeufin.util.amount
import java.sql.Connection
@@ -209,6 +210,22 @@ class PaymentInitiationEntity(id: EntityID<Long>) :
LongEntity(id) {
var confirmationTransaction by NexusBankTransactionEntity
optionalReferencedOn PaymentInitiationsTable.confirmationTransaction
}
+/**
+ * This table associates a bank connection with the raw XML response
+ * coming from a HTD message. The main purpose here is to store (possibly
+ * temporarily) the bank accounts belonging to one subscriber, in order
+ * to allow this latter to import them using more meaningful labels.
+ */
+object RawHTDResponsesTable : IdTable<String>() {
+ // the bank-connection that was used to download this data.
+ override val id = text("id").entityId()
+ val htdResponse = text("htdResponse")
+}
+class RawHTDResponseEntity(id: EntityID<String>) : Entity<String>(id) {
+ companion object : EntityClass<String,
RawHTDResponseEntity>(RawHTDResponsesTable)
+ var htdResponse by RawHTDResponsesTable.htdResponse
+}
+
/**
* This table holds triples of <iban, bic, holder name>.
* FIXME(dold): Allow other account and bank identifications than IBAN and BIC
@@ -234,7 +251,6 @@ object NexusBankAccountsTable : IdTable<String>() {
class NexusBankAccountEntity(id: EntityID<String>) : Entity<String>(id) {
companion object : EntityClass<String,
NexusBankAccountEntity>(NexusBankAccountsTable)
-
var accountHolder by NexusBankAccountsTable.accountHolder
var iban by NexusBankAccountsTable.iban
var bankCode by NexusBankAccountsTable.bankCode
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
index 8418ace..9309f8e 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
@@ -39,6 +39,7 @@ import io.ktor.request.receiveOrNull
import io.ktor.response.respond
import io.ktor.response.respondText
import io.ktor.routing.Route
+import io.ktor.routing.get
import io.ktor.routing.post
import org.jetbrains.exposed.sql.statements.api.ExposedBlob
import org.jetbrains.exposed.sql.transactions.transaction
@@ -388,6 +389,45 @@ fun Route.ebicsBankConnectionRoutes(client: HttpClient) {
}
call.respond(object {})
}
+ post("/accounts/fetch") {
+ val res = transaction {
+ 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 subscriberDetails =
getEbicsSubscriberDetails(conn.id.value)
+ val connid = conn.id.value
+ }
+ }
+ val response = doEbicsDownloadTransaction(
+ client, res.subscriberDetails, "HTD", EbicsStandardOrderParams()
+ )
+ when (response) {
+ is EbicsDownloadBankErrorResult -> {
+ throw NexusError(
+ HttpStatusCode.BadGateway,
+ response.returnCode.errorCode
+ )
+ }
+ is EbicsDownloadSuccessResult -> {
+ transaction {
+ RawHTDResponseEntity.new(res.connid) {
+ htdResponse =
response.orderData.toString(Charsets.UTF_8)
+ }
+ }
+ }
+ }
+ call.respond(object {})
+ }
+ get("/accounts") {
+ val ret = BankAccounts()
+ call.respond(object {})
+ }
+ post("/account/import") {
+ call.respond(object {})
+ }
/**
* Directly import accounts. Used for testing.
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: fetching accounts, store raw data into database,
gnunet <=