ct

package
v0.0.0-...-882b9c2 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repo

type Repo interface {
	GetTransactions(ctx context.Context, acc string) ([]Transaction, error)
	InsertTransaction(ctx context.Context, tx Transaction) error
	NewAccount(ctx context.Context, acc string, level Restriction) error
	SetRestriction(ctx context.Context, acc string, level Restriction) error
}

type Restriction

type Restriction int
const (
	AllowRead Restriction = iota
	AllowCredit
	AllowDebit
)

type Service

type Service interface {
	Deposit(ctx context.Context, acc string, amount uint) (int, error)
	Withdraw(ctx context.Context, acc string, amount uint) (int, error)
	Balance(ctx context.Context, acc string) (int, error)
}

func NewService

func NewService(r Repo) Service

type Transaction

type Transaction interface {
	Account() string
	Number() uint
	Amount() uint
	Type() TransactionType
}

func CreditTx

func CreditTx(acc string, number uint, amount uint) Transaction

func DebitTx

func DebitTx(acc string, number uint, amount uint) Transaction

type TransactionType

type TransactionType int
const (
	Credit TransactionType = iota + 1
	Debit
)

Jump to

Keyboard shortcuts

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