Skip to content

Commit

Permalink
fix(Nordigen): bring back file override
Browse files Browse the repository at this point in the history
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
  • Loading branch information
martinohansen committed Mar 11, 2024
1 parent b2d89b4 commit bb5cc68
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode
.cache
*.csv
*.env
*.json
4 changes: 4 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ type Nordigen struct {
// requisition process. The hook is executed with the following arguments:
// <status> <link>
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
Expand Down
10 changes: 9 additions & 1 deletion reader/nordigen/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bb5cc68

Please sign in to comment.