Documentation
¶
Overview ¶
Package storage is a directory of usecase storage implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotEnoughBalance = errors.New("not enough balance")
ErrNotEnoughBalance error represents when the account does not have enough balance.
var ErrNotFound = errors.New("not found")
ErrNotFound is an error to sql.ErrNoRows indicating that there was/were row(s) found.
Functions ¶
This section is empty.
Types ¶
type BankAccount ¶
type BankAccount struct {
// contains filtered or unexported fields
}
BankAccount represents a BankAccount repository.
func NewBankAccount ¶
func NewBankAccount(storage *sqluct.Storage) *BankAccount
NewBankAccount returns instance of BankAccount.
func (*BankAccount) BalanceCheck ¶
func (r *BankAccount) BalanceCheck(ctx context.Context, accountState model.BankAccountState, amount model.Cents) (*model.BankAccount, error)
BalanceCheck checks whether the account has enough balance or not from a storage.
Returns the bank account detail when ever the account has enough balance, otherwise error.
func (*BankAccount) BalanceUpdate ¶
func (r *BankAccount) BalanceUpdate(ctx context.Context, accountID model.BankAccountID, amount model.Cents) error
BalanceUpdate updates the account balance from a storage.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction represents a Transaction repository.
func NewTransaction ¶
func NewTransaction(storage *sqluct.Storage) *Transaction
NewTransaction returns instance of Transaction.
func (Transaction) Add ¶
func (r Transaction) Add(ctx context.Context, transactionStates []model.TransactionState) error
Add adds transaction to the storage.