Documentation ¶
Index ¶
- Constants
- Variables
- type AccountEntity
- type PaymentEntity
- type Service
- func (s Service) AccountsList(ctx context.Context, offset, limit int64) ([]AccountEntity, error)
- func (s Service) AllPaymentsList(ctx context.Context, offset, limit int64) ([]PaymentEntity, error)
- func (s Service) CreateAccount(ctx context.Context, name entity.AccountName) (entity.AccountName, error)
- func (s Service) Deposit(ctx context.Context, name entity.AccountName, amount float64) (float64, error)
- func (s Service) PaymentsList(ctx context.Context, name entity.AccountName, offset, limit int64) ([]PaymentEntity, error)
- func (s Service) Transfer(ctx context.Context, from entity.AccountName, to entity.AccountName, ...) (*PaymentEntity, error)
- type Services
Constants ¶
View Source
const ( PaymentDirectionIncoming = "incoming" PaymentDirectionOutgoing = "outgoing" )
Variables ¶
View Source
var ( ErrInService = errors.New("internal service error") ErrCreateAccountInvalidName = errors.New("invalid name format") ErrCreateAccount = errors.New("create account error") ErrCreateAccountDuplicate = errors.New("create account error: duplicate name") ErrDepositNotFound = errors.New("account not found") ErrDepositAmountError = errors.New("error in amount value") ErrTransferFromNotFound = errors.New("from account not found") ErrTransferToNotFound = errors.New("to account not found") ErrTransferAmountError = errors.New("error in amount value") ErrTransferNoMoneyError = errors.New("no enough money") ErrTransferSelfToSelfError = errors.New("disable transfer to self account") ErrPaymentsListNotFound = errors.New("account not found") ErrPaymentsListOffsetLimitError = errors.New("error in offset, limit params") ErrAccountsListOffsetLimitError = errors.New("error in offset, limit params") )
Functions ¶
This section is empty.
Types ¶
type AccountEntity ¶
type AccountEntity struct { Id entity.AccountName `json:"id"` Balance float64 `json:"balance"` Currency string `json:"currency"` }
AccountEntity using for service response
type PaymentEntity ¶
type PaymentEntity struct { Account entity.AccountName `json:"account"` ToAccount entity.AccountName `json:"to_account"` Amount float64 `json:"amount"` Direction string `json:"direction"` }
PaymentEntity using for service response
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (Service) AccountsList ¶
func (Service) AllPaymentsList ¶
func (Service) CreateAccount ¶
func (s Service) CreateAccount(ctx context.Context, name entity.AccountName) (entity.AccountName, error)
func (Service) PaymentsList ¶
func (s Service) PaymentsList(ctx context.Context, name entity.AccountName, offset, limit int64) ([]PaymentEntity, error)
func (Service) Transfer ¶
func (s Service) Transfer(ctx context.Context, from entity.AccountName, to entity.AccountName, amount float64) (*PaymentEntity, error)
type Services ¶
type Services interface { // CreateAccount - create new wallet account with name CreateAccount(ctx context.Context, name entity.AccountName) error // Deposit - deposit amount of currency to the wallet account. Deposit(ctx context.Context, name entity.AccountName, amount float64) error // Transfer - send amount of currency between two wallet accounts. Transfer(ctx context.Context, from entity.AccountName, to entity.AccountName, amount float64) error // PaymentsList - list of payments of the account. // if set offset and limit > 0 returns slice // if limit =-1 returns all payments PaymentsList(ctx context.Context, name entity.AccountName, offset, limit int64) ([]entity.Payment, error) // AllPaymentsList - list of all payments // if set offset and limit > 0 returns slice // if limit =-1 returns all payments AllPaymentsList(ctx context.Context, offset, limit int64) ([]entity.Payment, error) // AccountsList - List of all registered accounts // if set offset and limit > 0 returns slice // if limit =-1 returns all accounts AccountsList(ctx context.Context, offset, limit int64) ([]entity.Account, error) }
Click to show internal directories.
Click to hide internal directories.