Documentation ¶
Overview ¶
Package bank defines an interface for connecting and fetching data from online banks. This package is designed with the hope that many different bank back-ends can conform to the interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrBadPwd must be used when the password does not match the specifications or is incorrect. ErrBadPwd error = errors.New("invalid password") // ErrBadLoginPwd must be used when the login OR password does not match the // specifications or are incorrect. ErrBadLoginPwd error = errors.New("invalid login or password") // ErrNotLoggedIn is returned when the user is not authenticated. ErrNotLoggedIn error = errors.New("not logged in") )
Functions ¶
Types ¶
type Account ¶
type Account struct { ID string Name string Type AccountType Balance money.Money }
An Account is a financial account maintained by a bank.
type AccountType ¶
type AccountType int
AccountType is the type of an account. For instance, it can be a stock account.
const ( AccountChecking AccountType = iota AccountSavings AccountStocks )
type Bank ¶
type Bank interface { // Login connects to the bank. Credentials may have been given when // instancing the bank. Questions like 2FA code may be asked through the // prompt channel (this method will block until it gets an answer). Login(username, pwd []byte, ctx context.Context, q chan<- string, a <-chan string) error // Logout disconnects from the bank. It may returns ErrNotLoggedIn if the // user is already disconnected. Logout() error // Accounts returns the user's accounts. Accounts() ([]*Account, error) // Transactions returns the list of transactions of a specified account that // occured after a defined time. Transactions(account *Account, debitUpTo time.Time) ([]*Transaction, error) }
A Bank is the main interface or connecting and fetching data from online banks.
type NewBank ¶
type NewBank func() Bank
NewBank is the function that returns an instance of a Bank. Multiple accounts in the same bank can thus be handled properly.
type Transaction ¶
type Transaction struct { ID string Pending bool DateDebit time.Time DateDone time.Time RawName string Name string Card string Type TransactionType Category string Value money.Money }
A Transaction is a record of money that has moved in or out an account.
type TransactionType ¶
type TransactionType int
const ( TransactionNone TransactionType = iota TransactionCard TransactionTrsf TransactionTrsfSEPA TransactionDDebitSEPA TransactionTrsfINST TransactionCredit )
type UnrecognizedError ¶
type UnrecognizedError string
An UnrecognizedError is an unhandled error returned by the bank.
func (UnrecognizedError) Error ¶
func (e UnrecognizedError) Error() string
Click to show internal directories.
Click to hide internal directories.