From bb5cc68f3467046037f9ee426da3e3c88db7bbfa Mon Sep 17 00:00:00 2001 From: Martin Hansen Date: Mon, 11 Mar 2024 11:05:16 +0100 Subject: [PATCH] fix(Nordigen): bring back file override This commit brings back the ability to override the requisition file used by Nordigen. Allowing the user to have multiple req. files inside the same data directory. Fixes #69 --- .gitignore | 1 + config.go | 4 ++++ reader/nordigen/auth.go | 10 +++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 047ea49..ba7a4f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vscode +.cache *.csv *.env *.json diff --git a/config.go b/config.go index bca2ae7..51faabf 100644 --- a/config.go +++ b/config.go @@ -87,6 +87,10 @@ type Nordigen struct { // requisition process. The hook is executed with the following arguments: // RequisitionHook string `envconfig:"NORDIGEN_REQUISITION_HOOK"` + + // RequisitionFile overrides the file used to store the requisition. This + // file is placed inside the YNABBER_DATADIR. + RequisitionFile string `envconfig:"NORDIGEN_REQUISITION_FILE"` } // YNAB related settings diff --git a/reader/nordigen/auth.go b/reader/nordigen/auth.go index 9df6a18..c32d102 100644 --- a/reader/nordigen/auth.go +++ b/reader/nordigen/auth.go @@ -18,7 +18,15 @@ const RequisitionRedirect = "https://raw.githubusercontent.com/martinohansen/yna // requisitionStore returns a clean path to the requisition file func (r Reader) requisitionStore() string { - return path.Clean(fmt.Sprintf("%s/%s.json", r.Config.DataDir, r.Config.Nordigen.BankID)) + // Use BankID or RequisitionFile as filename + var file string + if r.Config.Nordigen.RequisitionFile == "" { + file = r.Config.Nordigen.BankID + } else { + file = r.Config.Nordigen.RequisitionFile + } + + return path.Clean(fmt.Sprintf("%s/%s.json", r.Config.DataDir, file)) } // Requisition tries to get requisition from disk, if it fails it will create a