account

package
v0.0.0-...-f0f3bdc Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitAccounts

func InitAccounts(s cqrs.EventStore)

Types

type Account

type Account struct {
	cqrs.Aggregate
	Id      string
	Balance int
}

func GetAccount

func GetAccount(id string, store cqrs.EventStore) Account

func MakeAccount

func MakeAccount(balance int, store cqrs.EventStore) Account

func (*Account) Credit

func (account *Account) Credit(amount int) string

func (*Account) Debit

func (account *Account) Debit(amount int) string

func (*Account) HandleCredit

func (account *Account) HandleCredit(event AccountCredited)

func (*Account) HandleDebit

func (account *Account) HandleDebit(event AccountDebited)

func (*Account) HandleNewAccount

func (account *Account) HandleNewAccount(event AccountCreated)

type AccountCreated

type AccountCreated struct {
	AccountId string `json:"account_id"`
	Balance   int    `json:"balance"`
}

type AccountCredited

type AccountCredited struct {
	AccountId     string `json:"account_id"`
	TransactionId string `json:"transaction_id"`
	Amount        int    `json:"amount"`
}

type AccountDebited

type AccountDebited struct {
	AccountId     string `json:"account_id"`
	TransactionId string `json:"transaction_id"`
	Amount        int    `json:"amount"`
}

type AccountRepository

type AccountRepository struct {
	// contains filtered or unexported fields
}

func NewAccountSummaryRepository

func NewAccountSummaryRepository(url string) *AccountRepository

func (*AccountRepository) Get

func (r *AccountRepository) Get(id string) Summary

type Command

type Command interface {
	Execute() (interface{}, error)
}

type CreateAccountCommand

type CreateAccountCommand struct {
	OpeningBalance int `json:"opening_balance"`
}

func (*CreateAccountCommand) Execute

func (command *CreateAccountCommand) Execute() (interface{}, error)

type CreditAccountCommand

type CreditAccountCommand struct {
	AccountId string `json:"account_id"`
	Amount    int    `json:"amount"`
}

func (*CreditAccountCommand) Execute

func (command *CreditAccountCommand) Execute() (interface{}, error)

type DebitAccountCommand

type DebitAccountCommand struct {
	AccountId string `json:"account_id"`
	Amount    int    `json:"amount"`
}

func (*DebitAccountCommand) Execute

func (command *DebitAccountCommand) Execute() (interface{}, error)

type Summary

type Summary struct {
	Id      string
	Balance int
}

Jump to

Keyboard shortcuts

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