account

package
v0.0.0-...-fa6240a Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAccountAlreadyExists is an error when creating an account that already exists
	ErrAccountAlreadyExists = errors.New("account already exists")
	// ErrAccountNotFound is an error when retrieving an account that doesn't exists
	ErrAccountNotFound = errors.New("account not found")
	// ErrValidation is an account related validation error
	ErrValidation = errors.New("validation error")
)

List of account related errors

Functions

func NewHTTPHandler

func NewHTTPHandler(s Service, logger kitlog.Logger) http.Handler

NewHTTPHandler returns the account http handler

Types

type Account

type Account struct {
	AccountID AccountID         `json:"id"`
	Currency  currency.Currency `json:"currency"`
	Balance   decimal.Decimal   `json:"balance"`
}

Account is an external account. These accounts are usually debit accounts.

func (Account) Validate

func (ac Account) Validate() error

Validate validates the account

type AccountID

type AccountID string

AccountID is the account id

func (AccountID) Validate

func (accntID AccountID) Validate() error

Validate validates the account id

type Balance

type Balance struct {
	AccountID   AccountID
	TotalCredit decimal.Decimal
	TotalDebit  decimal.Decimal
	CurrentBal  decimal.Decimal
	Ts          *time.Time
}

Balance is an account balance

type Repository

type Repository interface {
	// CreateAccount creates an account
	CreateAccount(context.Context, Account) (AccountID, error)
	// GetAccount retrieves the account
	GetAccount(context.Context, AccountID) (*Account, error)
	// IsAccountExists returns true if the account exists
	IsAccountExists(context.Context, AccountID) (bool, error)
	// ListAccounts retrieves the list of accounts
	ListAccounts(context.Context) ([]*Account, error)
}

Repository is an account repository

type Service

type Service interface {
	// CreateAccount creates an account
	CreateAccount(context.Context, Account) error
	// GetAccount retrieives an account via AccountID
	GetAccount(context.Context, AccountID) (*Account, error)
	// ListAccounts retrieives the list of accounts
	ListAccounts(context.Context) ([]*Account, error)
}

Service is an account service

func NewLoggingService

func NewLoggingService(logger log.Logger, s Service) Service

NewLoggingService returns a logging service middleware

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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