shad-go/ledger/model.go

24 lines
505 B
Go
Raw Normal View History

2022-03-31 11:19:47 +00:00
package ledger
import (
"context"
"errors"
)
type (
ID string
Money int64
)
var ErrNoMoney = errors.New("no money")
var ErrNegativeAmount = errors.New("negative amount")
2022-03-31 11:19:47 +00:00
type Ledger interface {
CreateAccount(ctx context.Context, id ID) error
GetBalance(ctx context.Context, id ID) (Money, error)
Deposit(ctx context.Context, id ID, amount Money) error
Withdraw(ctx context.Context, id ID, amount Money) error
Transfer(ctx context.Context, from, to ID, amount Money) error
2022-04-13 15:13:39 +00:00
Close() error
2022-03-31 11:19:47 +00:00
}