abstract providers behind a common interface
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
20
accountProviders.go
Normal file
20
accountProviders.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"deadbeef.codes/steven/ynab-portfolio-monitor/bitcoin"
|
||||
"deadbeef.codes/steven/ynab-portfolio-monitor/questrade"
|
||||
)
|
||||
|
||||
// AccountProvider is the base set of requirements to be implemented for any integration
|
||||
type AccountProvider interface {
|
||||
Name() string // Returns the name of the provider
|
||||
Configure() error // Configures the provider for first use - if an error is returned the provider is not used
|
||||
GetBalances() ([]int, []string, error) // A slice of balances, and an index mapped slice of ynab account IDs this provider handles is returned
|
||||
}
|
||||
|
||||
// Instantiate all providers for configuration
|
||||
// If configuration for a provider does not exist, it will be pruned during init()
|
||||
var allProviders []AccountProvider = []AccountProvider{
|
||||
&questrade.Provider{},
|
||||
&bitcoin.Provider{},
|
||||
}
|
Reference in New Issue
Block a user