storage

package
v0.0.0-...-26a0867 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package storage is a directory of usecase storage implementations.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotEnoughBalance = errors.New("not enough balance")

ErrNotEnoughBalance error represents when the account does not have enough balance.

View Source
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.

Jump to

Keyboard shortcuts

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