Documentation
¶
Index ¶
- Constants
- Variables
- func IsChecking(s string) bool
- func IsLocalhostTestURL(urlStr string) bool
- func IsSavings(s string) bool
- func LedgerAccountName(a Account) string
- func New(url string, config Config) (ofxgo.Client, error)
- func NewLocalClient(url string, client *ofxgo.BasicClient) (ofxgo.Client, error)
- func ReadOFX(r io.Reader) ([]ledger.Transaction, error)
- func Transactions(account Account, start, end time.Time) ([]ledger.Transaction, error)
- func Verify(account Account) error
- type Account
- func NewCheckingAccount(id, bankID, description string, institution Institution) Account
- func NewCreditCard(id, description string, institution Institution) Account
- func NewSavingsAccount(id, bankID, description string, institution Institution) Account
- func UnmarshalBuiltinAccount(b []byte) (Account, error)
- type AccountStore
- func (s *AccountStore) Add(account Account) error
- func (s *AccountStore) Find(id string) (account Account, found bool)
- func (s *AccountStore) FindLedger(format *LedgerAccountFormat) (account Account, found bool)
- func (s *AccountStore) Iterate(f func(Account) (keepGoing bool)) bool
- func (s *AccountStore) MarshalJSON() ([]byte, error)
- func (s *AccountStore) MarshalWithPassword() ([]byte, error)
- func (s *AccountStore) Remove(id string) error
- func (s *AccountStore) UnmarshalJSON(b []byte) error
- func (s *AccountStore) Update(id string, account Account) error
- type Bank
- type Checking
- type Config
- type CreditCard
- func (b CreditCard) Description() string
- func (b CreditCard) ID() string
- func (b CreditCard) Institution() Institution
- func (b CreditCard) MarshalJSON() ([]byte, error)
- func (b CreditCard) MarshalWithPassword() ([]byte, error)
- func (cc *CreditCard) Statement(start, end time.Time) (ofxgo.Request, error)
- func (b *CreditCard) UnmarshalJSON(buf []byte) error
- type Institution
- type LedgerAccountFormat
- type LocalClient
- func (l *LocalClient) MarshalRequest(r *ofxgo.Request) (io.Reader, error)
- func (l *LocalClient) RawRequest(url string, r io.Reader) (*http.Response, error)
- func (l *LocalClient) Request(r *ofxgo.Request) (*ofxgo.Response, error)
- func (l *LocalClient) RequestNoParse(r *ofxgo.Request) (*http.Response, error)
- type Password
- type PasswordMarshaler
- type Savings
Constants ¶
const ( // RedactSuffixLength the number of characters that remain unredacted at the end of a string RedactSuffixLength = 4 // Ledger account types AssetAccount = "assets" LiabilityAccount = "liabilities" ExpenseAccount = "expenses" RevenueAccount = "revenues" )
const (
// Uncategorized is used as the default account2 on an imported transaction
Uncategorized = "uncategorized"
)
Variables ¶
var ( // ErrAuthFailed is returned whenever a signon request fails with an authentication problem ErrAuthFailed = errors.New("Username or password is incorrect") )
Functions ¶
func IsChecking ¶ added in v0.3.0
IsChecking returns true if the given account type is a checking account
func IsLocalhostTestURL ¶ added in v0.5.0
IsLocalhostTestURL returns true if this is a valid URL and starts with http://localhost
func IsSavings ¶ added in v0.3.0
IsSavings returns true if the given account type is a savings account
func LedgerAccountName ¶
LedgerAccountName returns a suitable account name for a ledger file
func NewLocalClient ¶ added in v0.5.0
NewLocalClient returns a new LocalClient for the given URL and basic client
func ReadOFX ¶ added in v0.5.0
func ReadOFX(r io.Reader) ([]ledger.Transaction, error)
ReadOFX reads r and parses it for an OFX file's transactions
func Transactions ¶
Transactions downloads and returns transactions from a bank or credit card account for the given time period, ending today
Types ¶
type Account ¶
type Account interface {
ID() string
Description() string
Institution() Institution
Statement(start, end time.Time) (ofxgo.Request, error)
}
Account identifies an account at a financial institution
func NewCheckingAccount ¶
func NewCheckingAccount(id, bankID, description string, institution Institution) Account
NewCheckingAccount creates an account from checking details
func NewCreditCard ¶
func NewCreditCard(id, description string, institution Institution) Account
NewCreditCard creates an account from credit card details
func NewSavingsAccount ¶
func NewSavingsAccount(id, bankID, description string, institution Institution) Account
NewSavingsAccount creates an account from savings details
func UnmarshalBuiltinAccount ¶ added in v0.3.0
type AccountStore ¶ added in v0.3.0
type AccountStore struct {
// contains filtered or unexported fields
}
AccountStore enables manipulation of accounts in memory
func NewAccountStore ¶ added in v0.3.0
func NewAccountStore(accounts []Account) (*AccountStore, error)
NewAccountStore creates an account store from the given accounts, must not contain duplicate account IDs
func NewAccountStoreFromReader ¶ added in v0.3.0
func NewAccountStoreFromReader(r io.Reader) (*AccountStore, error)
NewAccountStoreFromReader returns a new account store loaded from the provided JSON-encoded reader
func (*AccountStore) Add ¶ added in v0.3.0
func (s *AccountStore) Add(account Account) error
Add pushes a new account into the store, fails if the account ID is already in use
func (*AccountStore) Find ¶ added in v0.3.0
func (s *AccountStore) Find(id string) (account Account, found bool)
Find returns the account with the given ID if it exists, otherwise found is false
func (*AccountStore) FindLedger ¶ added in v0.4.0
func (s *AccountStore) FindLedger(format *LedgerAccountFormat) (account Account, found bool)
FindLedger returns the account with the given ledger account string if it exists, otherwise found is false
func (*AccountStore) Iterate ¶ added in v0.3.0
func (s *AccountStore) Iterate(f func(Account) (keepGoing bool)) bool
Iterate ranges over the accounts in the store, running f on each one until it returns false Returns the last return value from f
func (*AccountStore) MarshalJSON ¶ added in v0.3.0
func (s *AccountStore) MarshalJSON() ([]byte, error)
MarshalJSON marshals into a sorted list of accounts
func (*AccountStore) MarshalWithPassword ¶ added in v0.3.0
func (s *AccountStore) MarshalWithPassword() ([]byte, error)
MarshalWithPassword marshals into a sorted list of accounts with their passwords. Only use this when persisting the accounts, never pass this back through an API call
func (*AccountStore) Remove ¶ added in v0.3.0
func (s *AccountStore) Remove(id string) error
Remove deletes the account from the store by ID
func (*AccountStore) UnmarshalJSON ¶ added in v0.3.0
func (s *AccountStore) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals from a list of accounts
type Bank ¶
Bank is an Account plus the Bank's routing number or 'Bank ID'. Common interface for Savings and Checking
type Checking ¶
type Checking struct {
// contains filtered or unexported fields
}
Checking represents a checking bank account
func (Checking) MarshalJSON ¶ added in v0.3.0
MarshalJSON marshals a checking account
func (Checking) MarshalWithPassword ¶ added in v0.3.0
MarshalWithPassword marshals a checking account and includes the password
func (*Checking) UnmarshalJSON ¶ added in v0.3.0
type Config ¶
type Config struct {
AppID string
AppVersion string
ClientID string `json:",omitempty"`
OFXVersion string
NoIndent bool `json:",omitempty"`
}
Config contains financial institution connection details
type CreditCard ¶
type CreditCard struct {
// contains filtered or unexported fields
}
CreditCard represents a credit card account
func (CreditCard) Description ¶
func (b CreditCard) Description() string
func (CreditCard) Institution ¶
func (b CreditCard) Institution() Institution
func (CreditCard) MarshalJSON ¶ added in v0.3.0
func (CreditCard) MarshalWithPassword ¶ added in v0.3.0
func (*CreditCard) UnmarshalJSON ¶ added in v0.3.0
type Institution ¶
type Institution interface {
Description() string
FID() string
Org() string
URL() string
Username() string
Password() *Password
Config() Config
}
Institution represents the connection and identification details for a financial institution
func NewInstitution ¶
func NewInstitution( description, fid, org, url, username, password string, config Config, ) Institution
NewInstitution creates an institution
type LedgerAccountFormat ¶ added in v0.4.0
type LedgerAccountFormat struct {
AccountType string
Institution string
AccountID string
Remaining string
}
LedgerAccountFormat represents an account's structured name for a ledger account format
func LedgerFormat ¶ added in v0.4.0
func LedgerFormat(a Account) *LedgerAccountFormat
LedgerFormat parses the account and returns a ledger account format
func ParseLedgerFormat ¶ added in v0.4.0
func ParseLedgerFormat(account string) (*LedgerAccountFormat, error)
ParseLedgerFormat parses the given account string as a ledger account
func (*LedgerAccountFormat) String ¶ added in v0.4.0
func (l *LedgerAccountFormat) String() string
type LocalClient ¶ added in v0.5.0
LocalClient enables insecure requests on localhost, provided that no passwords are involved
func (*LocalClient) MarshalRequest ¶ added in v0.5.0
MarshalRequest implement the requestMarshaler interface to handle the special empty password case
func (*LocalClient) RawRequest ¶ added in v0.5.0
RawRequest runs a raw request for the given URL and reader against localhost. Errors if the host isn't for localhost OR a password field is included.
func (*LocalClient) RequestNoParse ¶ added in v0.5.0
RequestNoParse runs a raw request by marshalling the given request, returns the raw response
type Password ¶ added in v0.3.0
type Password struct {
// contains filtered or unexported fields
}
Password is a string that makes it hard to expose the underlying string outside this package Only JSON-serializes to 'null'
func NewPassword ¶ added in v0.3.0
NewPassword returns a password set to s
func (*Password) IsEmpty ¶ added in v0.3.0
IsEmpty returns true if the internal password string is not set
func (*Password) MarshalJSON ¶ added in v0.3.0
MarshalJSON returns JSON 'null' to prevent serialization within a struct
func (*Password) UnmarshalJSON ¶ added in v0.3.0
UnmarshalJSON deserializes b into a password
type PasswordMarshaler ¶ added in v0.3.0
PasswordMarshaler includes a password in it's marshaled output of MarshalWithPassword
type Savings ¶
type Savings struct {
// contains filtered or unexported fields
}
Savings represents a savings bank account
func (Savings) MarshalJSON ¶ added in v0.3.0
MarshalJSON marshals a savings account
func (Savings) MarshalWithPassword ¶ added in v0.3.0
MarshalWithPassword marshals a savings account and includes the password