Documentation ¶
Overview ¶
Package account provides the use-case of users accounts and it manipulations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidAccount is returned when from account is equal to account, or account is empty ErrInvalidAccount = errors.New("invalid account") // ErrInvalidSum is returned when the sum to send is less or equal 0 ErrInvalidSum = errors.New("invalid sum for send") // ErrUnexpectedError is returned when some unexpected error: like transaction can't be started or committed ErrUnexpectedError = errors.New("unexpected error") // ErrAccountNotFound is returned when account not found ErrAccountNotFound = errors.New("account not found") // ErrInSaving is returned when we can't save data to storage ErrInSaving = errors.New("cant save updated data") )
Functions ¶
func MakeHandler ¶
MakeHandler returns a handler for the account service.
func NewLoggerService ¶
NewLoggerService returns a new instance of the Service with logging.
Types ¶
type Account ¶
type Account struct { ID string `json:"id"` Balance decimal.Decimal `json:"balance"` Currency string `json:"currency"` }
Account is a model of user's account
type Service ¶
type Service interface { // Send - transfer money from one account to another. Send(from coins.AccountID, to coins.AccountID, sum decimal.Decimal) error // Get - returns a list of all accounts in system. Get() ([]*Account, error) // Add - add new account Add(account *Account) error }
Service is the interface that provides the basic Account method.
func NewService ¶
func NewService(accounts coins.AccountRepository, payments coins.PaymentRepository, txs transactions.ITransactionBegin) Service
NewService returns a new instance of the default Service.
Click to show internal directories.
Click to hide internal directories.