bankapi

package module
v0.0.0-...-f60b94f Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2020 License: GPL-3.0 Imports: 29 Imported by: 0

README

bank_api

An API to query banking data. Reads from an AWS S3 stored sqlite3 database, deploys as a AWS Lambda function.

Why S3 + Sqlite3?

I wanted to have a fully serverless relational database. No continuous running costs (aside from S3 storage).

Running a database server on Lambda is currently impossible. The closest thing would be AWS Aurora Serverless, but I thought the operational overhead would be overkill for this application. Additionally I believe the costs were still far greater than S3 + sqlite3.

DynamoDB could potentially have worked since it has the ability to scale down to 0, however takes additional time to warm up/cool down and this was not fast enough to select 1000s of rows at once.

It turned out that S3 + sqlite3 was easy and relatively fast, and works fine for this use case.

Documentation

Index

Constants

View Source
const SpaceshipBaseUrl = "https://api.spaceshipinvest.com.au"

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthResponse

type AuthResponse struct {
	AuthToken    string   `json:"auth_token"`
	RefreshToken string   `json:"refresh_token"`
	Scopes       []string `json:"scopes"`
}

type BankAPI

type BankAPI struct {
	DS     datastore.DataStore
	Router *mux.Router
}

func NewBankAPI

func NewBankAPI() *BankAPI

func (*BankAPI) AccountsHandler

func (b *BankAPI) AccountsHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) ApnsGetTokens

func (b *BankAPI) ApnsGetTokens(usernameHash string) ([]string, error)

func (*BankAPI) ApnsHandler

func (b *BankAPI) ApnsHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) ApnsReceivedHandler

func (b *BankAPI) ApnsReceivedHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) ApnsRegister

func (b *BankAPI) ApnsRegister(usernameHash string, deviceToken string) ([]string, error)

func (*BankAPI) ApnsRegisterHandler

func (b *BankAPI) ApnsRegisterHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) ApnsSendNotification

func (b *BankAPI) ApnsSendNotification(apnsRequest models.ApnsRequest) ([]models.ApnsResponse, error)

func (*BankAPI) ApnsTokensHandler

func (b *BankAPI) ApnsTokensHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) AppendProjections

func (b *BankAPI) AppendProjections(timeseries []models.TimeseriesBalance, expectedTransactions []models.ExpectedTransaction) ([]models.TimeseriesBalance, error)

func (*BankAPI) Authenticate

func (b *BankAPI) Authenticate(username string, password string) (bool, string, error)

func (*BankAPI) AuthenticateHandler

func (b *BankAPI) AuthenticateHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) BankFetchHandler

func (b *BankAPI) BankFetchHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) BankHandler

func (b *BankAPI) BankHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) CacheTestHandler

func (b *BankAPI) CacheTestHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) CategoryAddHandler

func (b *BankAPI) CategoryAddHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) CategoryGetHandler

func (b *BankAPI) CategoryGetHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) Close

func (b *BankAPI) Close() error

func (*BankAPI) CredentialsHandler

func (b *BankAPI) CredentialsHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) CredentialsUpdateHandler

func (b *BankAPI) CredentialsUpdateHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) ExclusionGetHandler

func (b *BankAPI) ExclusionGetHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) GetAccounts

func (b *BankAPI) GetAccounts(usernameHash string, spaceshipCredentials models.Credential) (models.BankResponse, error)

func (*BankAPI) GetBankData

func (b *BankAPI) GetBankData(usernameHash string, includeCategories bool) (models.BankResponse, error)

func (*BankAPI) GetBankDataWithVoyager

func (b *BankAPI) GetBankDataWithVoyager(usernameHash string, spaceshipCredentials models.Credential, includeCategories bool) (models.BankResponse, error)

func (*BankAPI) GetCredentials

func (b *BankAPI) GetCredentials(usernameHash string, password string) (models.CredentialsResponse, error)

func (*BankAPI) GetCredentialsSpaceship

func (b *BankAPI) GetCredentialsSpaceship(usernameHash string, password string) (models.Credential, error)

func (*BankAPI) GetDS

func (b *BankAPI) GetDS() (datastore.DataStore, error)

func (*BankAPI) GetNextSprintStartDate

func (b *BankAPI) GetNextSprintStartDate(now time.Time) time.Time

func (*BankAPI) GetSprints

func (b *BankAPI) GetSprints(usernameHash string, excludeCategories []string) ([]models.Sprint, error)

func (*BankAPI) GetTransactions

func (b *BankAPI) GetTransactions(usernameHash string, includeCategories bool) (models.BankResponse, error)

func (*BankAPI) GetTransactionsByAccount

func (b *BankAPI) GetTransactionsByAccount(transactions []models.Transaction) map[int][]models.Transaction

func (*BankAPI) GetVoyagerAccount

func (b *BankAPI) GetVoyagerAccount(credentials models.Credential, account chan models.Account, voyagerErr chan error)

func (*BankAPI) GetVoyagerData

func (b *BankAPI) GetVoyagerData(credentials models.Credential, voyager chan map[time.Time]float64, voyagerErr chan error)

func (*BankAPI) InvocationsHandler

func (b *BankAPI) InvocationsHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) PingHandler

func (b *BankAPI) PingHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) ProjectionsHandler

func (b *BankAPI) ProjectionsHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) Register

func (b *BankAPI) Register(username string) (string, error)

func (*BankAPI) RegisterHandler

func (b *BankAPI) RegisterHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) SetCredentials

func (b *BankAPI) SetCredentials(usernameHash string, password string, credentialsPatch models.CredentialsResponse) (models.CredentialsResponse, error)

func (*BankAPI) SprintsHandler

func (b *BankAPI) SprintsHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) Timeseries

func (b *BankAPI) Timeseries(usernameHash string, spaceshipCredentials models.Credential) (models.TimeseriesResponse, error)

func (*BankAPI) TimeseriesCategories

func (b *BankAPI) TimeseriesCategories(usernameHash string) (models.TimeseriesResponse, error)

func (*BankAPI) TimeseriesCategoriesHandler

func (b *BankAPI) TimeseriesCategoriesHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) TimeseriesHandler

func (b *BankAPI) TimeseriesHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) TrackingHandler

func (b *BankAPI) TrackingHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) TransactionPatchHandler

func (b *BankAPI) TransactionPatchHandler(w http.ResponseWriter, r *http.Request)

func (*BankAPI) TransactionsHandler

func (b *BankAPI) TransactionsHandler(w http.ResponseWriter, r *http.Request)

type Credential

type Credential struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type GraphResponse

type GraphResponse struct {
	GraphData []GraphTimeseriesBalance `json:"graph_data"`
}

type GraphTimeseriesBalance

type GraphTimeseriesBalance struct {
	Date    string `json:"date"`
	Balance string `json:"balance"`
}

type IntercomHashes

type IntercomHashes struct {
	Android string `json:"android"`
	IOS     string `json:"ios"`
	Web     string `json:"web"`
}

type LoginResponse

type LoginResponse struct {
	Auth           AuthResponse   `json:"auth"`
	IntercomHashes IntercomHashes `json:"intercom_hashes"`
}

type StoredCredentials

type StoredCredentials struct {
	Ing         Credential `json:"ing"`
	Anz         Credential `json:"anz"`
	Cba         Credential `json:"cba"`
	Spaceship   Credential `json:"spaceship"`
	VirginMoney Credential `json:"virginmoney"`
}

Jump to

Keyboard shortcuts

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