web

package
v0.8.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2021 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, driver Driver)

Register adds a driver with the given name to the registry. Enables a call with Connect and the same driver name

func Search(query string) []string

func Statement

func Statement(connector Connector, start, end time.Time, accountIDs []string, parser model.TransactionParser, prompt prompter.Prompter) ([]ledger.Transaction, error)

Statement downloads and returns transactions from a connector for the given time period

func Validate

func Validate(account Account) error

Validate checks account for bad values

Types

type Account

type Account interface {
	model.Account
}

Account is a web connect enabled account

func UnmarshalAccount

func UnmarshalAccount(b []byte) (Account, error)

UnmarshalAccount attempts to unmarshal the given bytes into a known Web Connect account type

type Action

type Action chromedp.Action

Action performs a browser action, like clicking on a page or emulating a device

type Browser

type Browser interface {
	// Run calls each action in order, stopping on the first error
	Run(ctx context.Context, actions ...Action) error
	// Download registers an asynchronous handler for any detected file downloads.
	// Ensure this is registered before Run is called.
	Download(downloader Downloader)
	// DownloadErr returns an error if one has occurred during a download. Always returns the first error.
	DownloadErr() error
}

Browser manages a browser window, runs actions against it, and handles download requests

func NewBrowser

func NewBrowser(ctx context.Context, config BrowserConfig) (Browser, error)

NewBrowser creates an instance of Browser with the given config options, bound to the provided context Canceling the context closes the browser entirely

type BrowserConfig

type BrowserConfig struct {
	Debug      bool
	NoHeadless bool
	Record     bool
	Device     chromedp.Device
	Logger     *zap.Logger
}

BrowserConfig passes options for a new browser constructor

type Connector

type Connector interface {
	model.Institution
	CredConnector
	Requestor
}

Connector downloads statements from an institution's website

func Connect

func Connect(connector CredConnector) (Connector, error)

Connect creates a Connector with the given driver name and credentials

type ConnectorValidator added in v0.8.4

type ConnectorValidator interface {
	Validate(accountID string) error
}

ConnectorValidator performs validation on an account / credential pair, returns any errors

type CredConnector

type CredConnector interface {
	// Driver is the name of the driver
	Driver() string
}

CredConnector is used by a Driver to create a full Connector

type DownloadRequest

type DownloadRequest struct {
	Cookies   []*http.Cookie
	URL       string
	UserAgent string
}

DownloadRequest contains a download request's details to help reconstruct your own download HTTP request

func (*DownloadRequest) Fetch

func (d *DownloadRequest) Fetch(ctx context.Context) ([]byte, error)

Fetch downloads the file with the given download request details and returns the response body as bytes

func (*DownloadRequest) HTTPRequest

func (d *DownloadRequest) HTTPRequest(ctx context.Context) (*http.Request, error)

HTTPRequest creates an *http.Request from this download's details

type Downloader

type Downloader func(context.Context, DownloadRequest) error

Downloader receives a download request and processes it synchronously

type Driver

type Driver func(CredConnector) (Connector, error)

type PasswordConnector

type PasswordConnector interface {
	CredConnector

	Username() string
	Password() redactor.String
	SetPassword(redactor.String)
}

PasswordConnector contains credentials for user/pass authentication

type Requestor

type Requestor interface {
	// Statement downloads transactions with browser between the start and end times
	Statement(start, end time.Time, accountID string, browser Browser, prompt prompter.Prompter) (*ofxgo.Response, error)
}

Requestor downloads statements from an institution's website

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL