[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: importing accounts using custom label
From: |
gnunet |
Subject: |
[libeufin] branch master updated: importing accounts using custom label |
Date: |
Sat, 20 Jun 2020 23:57:07 +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 e61efb3 importing accounts using custom label
e61efb3 is described below
commit e61efb3a0f48d315ec2b4d2d162ab48b3e3b9052
Author: MS <ms@taler.net>
AuthorDate: Sat Jun 20 23:56:49 2020 +0200
importing accounts using custom label
---
cli/libeufin-cli-new | 53 ++++++++++++++++++++++
cli/setup-template.sh | 15 ------
nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 3 +-
.../kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt | 28 +++++++++++-
.../main/kotlin/tech/libeufin/nexus/server/JSON.kt | 5 ++
5 files changed, 87 insertions(+), 17 deletions(-)
diff --git a/cli/libeufin-cli-new b/cli/libeufin-cli-new
index cd3ae44..513d51f 100755
--- a/cli/libeufin-cli-new
+++ b/cli/libeufin-cli-new
@@ -138,6 +138,59 @@ def bootstrap_bank_connection(obj, connection_name,
nexus_user_id, nexus_passwor
return
print(resp.content.decode("utf-8"))
+@bank_connection.command(help="import one bank account, chosen from the
downloaded ones")
+@click.option("--connection-name", help="Connection ID", required=True)
+@click.option("--nexus-user-id", help="Nexus user ID", required=True)
+@click.option("--nexus-password", help="Nexus password", required=True)
+@click.option("--account-id", help="Name of the account to import",
required=True)
+@click.option("--local-name", help="Name to give to the imported account",
required=True)
+@click.argument("nexus-base-url")
+@click.pass_obj
+def import_bank_account(obj, connection_name, nexus_user_id, nexus_password,
nexus_base_url, account_id, local_name):
+ # FIXME/NOTE: the 'ebics' part will soon go away.
+ url = urljoin(nexus_base_url,
"/bank-connections/{}/ebics/accounts/import".format(connection_name))
+ print("going {}".format(url))
+ try:
+ resp = post(url, json=dict(accountId=account_id,
localName=local_name), auth = auth.HTTPBasicAuth(nexus_user_id, nexus_password))
+ except Exception as ee:
+ print(ee)
+ print("Could not reach nexus")
+ return
+ print(resp.content.decode("utf-8"))
+
+@bank_connection.command(help="download bank accounts in raw format WITHOUT
importing them")
+@click.option("--connection-name", help="Connection ID", required=True)
+@click.option("--nexus-user-id", help="Nexus user ID", required=True)
+@click.option("--nexus-password", help="Nexus password", required=True)
+@click.argument("nexus-base-url")
+@click.pass_obj
+def download_bank_accounts(obj, connection_name, nexus_user_id,
nexus_password, nexus_base_url):
+ # FIXME/NOTE: the 'ebics' part will soon go away.
+ url = urljoin(nexus_base_url,
"/bank-connections/{}/ebics/accounts/fetch".format(connection_name))
+ try:
+ resp = post(url, json=dict(), auth = auth.HTTPBasicAuth(nexus_user_id,
nexus_password))
+ except Exception:
+ print("Could not reach nexus")
+ return
+ print(resp.content.decode("utf-8"))
+
+
+@bank_connection.command(help="list raw bank account information locally
stored")
+@click.option("--connection-name", help="Connection ID", required=True)
+@click.option("--nexus-user-id", help="Nexus user ID", required=True)
+@click.option("--nexus-password", help="Nexus password", required=True)
+@click.argument("nexus-base-url")
+@click.pass_obj
+def list_bank_accounts(obj, connection_name, nexus_user_id, nexus_password,
nexus_base_url):
+ # FIXME/NOTE: the 'ebics' part will soon go away.
+ url = urljoin(nexus_base_url,
"/bank-connections/{}/ebics/accounts".format(connection_name))
+ try:
+ resp = get(url, json=dict(), auth = auth.HTTPBasicAuth(nexus_user_id,
nexus_password))
+ except Exception:
+ print("Could not reach nexus")
+ return
+ print(resp.content.decode("utf-8"))
+
@bank_connection.command(help="import related bank accounts of
'connection-name'")
@click.option("--connection-name", help="Connection ID", required=True)
@click.option("--nexus-user-id", help="Nexus user ID", required=True)
diff --git a/cli/setup-template.sh b/cli/setup-template.sh
index bd7c191..632032f 100755
--- a/cli/setup-template.sh
+++ b/cli/setup-template.sh
@@ -90,18 +90,3 @@ echo Bootstrapping the bank connection
--nexus-user-id $NEXUS_USER \
--nexus-password $NEXUS_PASSWORD \
$NEXUS_URL
-sleep 2
-
-# Fetching the bank accounts
-echo Fetching the bank accounts
-./libeufin-cli-new \
- bank-connection \
- import-bank-accounts \
- --connection-name $NEXUS_BANK_CONNECTION_NAME \
- --nexus-user-id $NEXUS_USER \
- --nexus-password $NEXUS_PASSWORD \
- $NEXUS_URL
-sleep 2
-
-echo User is setup, history can be requested, and \
- new payments can be prepared and submitted.
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index 043358a..cf79fc3 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -402,7 +402,8 @@ fun dbCreateTables(dbName: String) {
NexusBankMessagesTable,
FacadesTable,
TalerFacadeStateTable,
- NexusScheduledTasksTable
+ NexusScheduledTasksTable,
+ RawHTDResponsesTable
)
}
}
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 0493d21..9a8cabe 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
@@ -35,6 +35,7 @@ import io.ktor.application.call
import io.ktor.client.HttpClient
import io.ktor.http.ContentType
import io.ktor.http.HttpStatusCode
+import io.ktor.request.receive
import io.ktor.request.receiveOrNull
import io.ktor.response.respond
import io.ktor.response.respondText
@@ -449,7 +450,32 @@ fun Route.ebicsBankConnectionRoutes(client: HttpClient) {
}
call.respond(ret)
}
- post("/account/import") {
+ post("/accounts/import") {
+ val body = call.receive<ImportBankAccount>()
+ transaction {
+ val conn = requireBankConnection(call, "callid")
+ val hasXml = RawHTDResponseEntity.findById(conn.id.value) ?: throw
NexusError(
+ HttpStatusCode.NotFound, "Could not found raw bank account
data for connection '${conn.id.value}'"
+ )
+
XMLUtil.convertStringToJaxb<HTDResponseOrderData>(hasXml.htdResponse).value.partnerInfo.accountInfoList?.forEach
{
+ if (it.id == body.accountId) {
+ NexusBankAccountEntity.new(body.localName) {
+ iban =
it.accountNumberList?.filterIsInstance<EbicsTypes.GeneralAccountNumber>()
+ ?.find { it.international }?.value
+ ?: throw NexusError(HttpStatusCode.NotFound,
reason = "bank gave no IBAN")
+ bankCode =
it.bankCodeList?.filterIsInstance<EbicsTypes.GeneralBankCode>()
+ ?.find { it.international }?.value
+ ?: throw NexusError(
+ HttpStatusCode.NotFound,
+ reason = "bank gave no BIC"
+ )
+ defaultBankConnection = conn
+ highestSeenBankMessageId = 0
+ accountHolder = it.accountHolder ?: "NOT GIVEN"
+ }
+ }
+ }
+ }
call.respond(object {})
}
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
index d7318ba..1a3cdeb 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
@@ -318,4 +318,9 @@ data class CreateAccountTaskRequest(
val cronspec: String,
val type: String,
val params: JsonNode
+)
+
+data class ImportBankAccount(
+ val accountId: String,
+ val localName: String
)
\ No newline at end of file
--
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: importing accounts using custom label,
gnunet <=