wallet

package
v0.0.0-...-f18d551 Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Amount

type Amount struct {
	Amount float64 `json:"amount"`
}

type Balance

type Balance struct {
	Timestamp time.Time `json:"timestamp"`
	Balance   float64   `json:"balance"`
}

type Caller

type Caller struct {
	models.Caller
}

func NewCaller

func NewCaller(name string, entityID ksuid.KSUID) *Caller

func (*Caller) Credit

func (c *Caller) Credit(entityID ksuid.KSUID, amount float64) error

func (*Caller) Debit

func (c *Caller) Debit(entityID ksuid.KSUID, amount float64) error

type Reader

type Reader struct {
	models.Reader
}

func NewReader

func NewReader(name string) *Reader

func (*Reader) GetBalance

func (r *Reader) GetBalance(entityID ksuid.KSUID) (*Balance, error)

func (*Reader) GetTransactions

func (r *Reader) GetTransactions(entityID ksuid.KSUID) (*Transactions, error)

func (*Reader) GetWalletState

func (r *Reader) GetWalletState(entityID ksuid.KSUID) (*State, error)

type Server

type Server struct {
	domains.Server
}

func NewServer

func NewServer() *Server

type State

type State struct {
	Timestamp    time.Time     `json:"timestamp"`
	Balance      float64       `json:"balance"`
	Transactions []Transaction `json:"transactions"`
}

func FromJSON

func FromJSON(data []byte) (*State, error)

func (*State) ToJSON

func (s *State) ToJSON() ([]byte, error)

type Transaction

type Transaction struct {
	Timestamp      time.Time   `json:"timestamp"`
	SourceEntityID ksuid.KSUID `json:"source_entity_id"`
	Amount         float64     `json:"amount"`
}

func NewTransaction

func NewTransaction(sourceEntityID ksuid.KSUID, amount float64) Transaction

type Transactions

type Transactions struct {
	Timestamp    time.Time     `json:"timestamp"`
	Transactions []Transaction `json:"transactions"`
}

type Wallet

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

func NewWallet

func NewWallet(entityID ksuid.KSUID) *Wallet

func (*Wallet) Credit

func (w *Wallet) Credit(sourceEntityID ksuid.KSUID, amount float64) error

func (*Wallet) Debit

func (w *Wallet) Debit(sourceEntityID ksuid.KSUID, amount float64) error

type Writer

type Writer struct {
	models.Writer
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(entityID ksuid.KSUID) *Writer

Jump to

Keyboard shortcuts

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