account

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID            string    `json:"id"`
	CreatedAt     time.Time `json:"createdAt"`
	Description   string    `json:"description"`
	Balance       int64     `json:"balance"`
	Currency      string    `json:"currency"`
	LastUpdatedAt time.Time `json:"lastUpdatedAt"`
}

Account describes single user's bank account.

type BankAPI

type BankAPI interface {
	// GetUserInfo loads user accounts list.
	GetUserInfo(ctx context.Context) ([]mono.Account, error)
}

BankAPI abstracts bank API related to accounts information.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler handles /vN/account* and /vN/accounts* routes.

func NewHandler

func NewHandler(storage *Repository) *Handler

NewHandler returns new instance of Handler.

func (*Handler) BindRoutes

func (t *Handler) BindRoutes(router *gin.Engine)

BindRoutes bind gin routes to handler methods.

func (*Handler) GetAccounts

func (t *Handler) GetAccounts(c *gin.Context)

GetAccounts returns accounts list.

type Importer

type Importer struct {
	// contains filtered or unexported fields
}

Importer loads the latest account related data from bank for specified accountID and saves it to storage.

func NewImporter

func NewImporter(api BankAPI, accounts Storage) *Importer

NewImporter create new instance of Importer.

func (*Importer) Import

func (i *Importer) Import(ctx context.Context, accountID string) error

Import latest account related data from bank for specified accountID and save it to storage.

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository implements persistent storage layer for accounts in PostgreSQL.

func NewRepository

func NewRepository(pool *pgxpool.Pool) *Repository

NewRepository creates new instance of Repository.

func (*Repository) GetAll

func (s *Repository) GetAll(ctx context.Context) ([]Account, error)

GetAll accounts from database.

func (*Repository) Save

func (s *Repository) Save(ctx context.Context, account Account) error

Save account to db. If conflict (on ID) occurs - only "lastUpdatedAt" and "balance" fields would be updated.

type Storage

type Storage interface {
	// Save information about account.
	Save(ctx context.Context, account Account) error
}

Storage abstracts persistent storage for accounts.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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