libeufin

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

commit 8b29269fc25f38980264d3da395ebf2d6cc8c7cb
parent bf2d191a7efdac6003a5e848a992ceb08f0e12fe
Author: Antoine A <>
Date:   Mon, 22 Jul 2024 19:12:57 +0200

nexus: improve lazy config

Diffstat:
Mnexus/src/main/kotlin/tech/libeufin/nexus/Config.kt | 19++++++++++++-------
Mnexus/src/main/kotlin/tech/libeufin/nexus/cli/Testing.kt | 3+--
2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Config.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Config.kt @@ -40,8 +40,12 @@ class NexusSubmitConfig(config: TalerConfig) { val frequencyRaw = section.string("frequency").require() } -class NexusEbicsConfig(config: TalerConfig, val currency: String) { - private val sect = config.section("nexus-ebics") +class NexusEbicsConfig( + config: TalerConfig, + sect: TalerConfigSection, + val currency: String, + val accountType: AccountType +) { /** The bank base URL */ val hostBaseUrl = sect.string("host_base_url").require() /** The bank EBICS host ID */ @@ -63,10 +67,6 @@ class NexusEbicsConfig(config: TalerConfig, val currency: String) { "postfinance" to Dialect.postfinance, "gls" to Dialect.gls )).require() - val accountType = sect.map("account_type", "account type", mapOf( - "normal" to AccountType.normal, - "exchange" to AccountType.exchange - )).require() /** Path where we store the bank public keys */ val bankPublicKeysPath = sect.path("bank_public_keys_file").require() @@ -93,7 +93,12 @@ class NexusConfig internal constructor (private val cfg: TalerConfig) { /** The bank's currency */ val currency = sect.string("currency").require() - val ebics by lazy { NexusEbicsConfig(cfg, currency) } + val accountType = sect.map("account_type", "account type", mapOf( + "normal" to AccountType.normal, + "exchange" to AccountType.exchange + )).require() + + val ebics by lazy { NexusEbicsConfig(cfg, sect, currency, accountType) } val wireGatewayApiCfg = cfg.section("nexus-httpd-wire-gateway-api").apiConf() val revenueApiCfg = cfg.section("nexus-httpd-revenue-api").apiConf() diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/cli/Testing.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/cli/Testing.kt @@ -88,8 +88,7 @@ class FakeIncoming: CliktCommand("Genere a fake incoming payment") { ).convert { Payto.parse(it).expectIban() } override fun run() = cliCmd(logger, common.log) { - nexusConfig(common.config).withDb { db, nexusCgf -> - val cfg = nexusCgf.ebics + nexusConfig(common.config).withDb { db, cfg -> val subject = requireNotNull(payto.message ?: subject) { "Missing subject" } val amount = requireNotNull(payto.amount ?: amount) { "Missing amount" }