// Package fio fetches Fio bank transactions via the JSON API or the // transparent-page HTML scraper, behind a common Client interface. package fio import ( "context" "net/http" "time" ) // Transaction is one incoming bank payment. Fields absent from the HTML scraper // (BankID, Currency, UserID, SenderAccount) are empty strings on that path. type Transaction struct { Date string Amount float64 Sender string Message string VS string KS string SS string UserID string // column7; empty on HTML path SenderAccount string // column2; empty on HTML path BankID string // column22; empty on HTML path Currency string // column14; empty on HTML path (assume CZK) } // Client fetches transactions for a date window. type Client interface { FetchTransactions(ctx context.Context, from, to time.Time) ([]Transaction, error) } // New returns an apiClient when token is non-empty, otherwise a transparentClient. // hc may be nil, in which case http.DefaultClient is used. func New(token, accountNum string, hc httpDoer) Client { if hc == nil { hc = http.DefaultClient } if token != "" { return &apiClient{token: token, hc: hc} } return &transparentClient{accountNum: accountNum, hc: hc} }