libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit c8ee59217de3af90dae76baf5563e9b77a99d623
parent a6be569fb2f008766e02bd62ce82a4f44025f05b
Author: MS <ms@taler.net>
Date:   Wed, 15 Nov 2023 15:52:33 +0100

nexus: adding --debug to read from STDIN

Diffstat:
Mnexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt | 11++++++++---
Mnexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt | 10++++++----
2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt @@ -482,6 +482,12 @@ class EbicsFetch: CliktCommand("Fetches bank records. Defaults to camt.054 noti " latest document is always until the current time." ) + private val debug by option( + help = "Reads one ISO20022 document from STDIN and prints " + + "the parsing results. It does not affect the database." + ).flag(default = false) + + /** * This function collects the main steps of fetching banking records. * In this current version, it does not implement long polling, instead @@ -515,10 +521,9 @@ class EbicsFetch: CliktCommand("Fetches bank records. Defaults to camt.054 noti if (onlyStatements) whichDoc = SupportedDocument.CAMT_053 if (onlyLogs) whichDoc = SupportedDocument.PAIN_002_LOGS - // If STDIN has data, we run in debug mode: parse, print, and return. - val maybeStdin = generateSequence(::readLine).joinToString("\n") - if (maybeStdin.isNotEmpty()) { + if (debug) { logger.debug("Reading from STDIN, running in debug mode. Not involving the database.") + val maybeStdin = generateSequence(::readLine).joinToString("\n") when(whichDoc) { SupportedDocument.CAMT_054 -> { val incoming = findIncomingTxInNotification(maybeStdin, cfg.currency) diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt @@ -229,6 +229,9 @@ class EbicsSubmit : CliktCommand("Submits any initiated payment found in the dat "ignoring the 'frequency' configuration value" ).flag(default = false) + private val debug by option( + help = "Reads the pain.001 document from STDIN and submits it to the bank" + ).flag(default = false) /** * Submits any initiated payment that was not submitted * so far and -- according to the configuration -- returns @@ -259,10 +262,9 @@ class EbicsSubmit : CliktCommand("Submits any initiated payment found in the dat clientPrivateKeysFile = clientKeys, httpClient = HttpClient() ) - // If STDIN has data, we run in debug mode: submit and return. - val maybeStdin = generateSequence(::readLine).joinToString("\n") - if (maybeStdin.isNotEmpty()) { - logger.info("Submitting STDIN to the bank") + if (debug) { + logger.info("Running in debug mode, submitting STDIN to the bank") + val maybeStdin = generateSequence(::readLine).joinToString("\n") doOrFail { runBlocking { submitPain001(