entity

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnprocessableEntity = errors.New("unprocessable entity")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	ID              uuid.UUID
	AccountType     AccountType
	CustomerName    string
	DocumentNumber  string
	Email           string
	PasswordEncoded Password
	PhoneNumber     string
	Status          AccountStatus
	CreatedAt       time.Time
	UpdatedAt       time.Time
	Wallet          Wallet
}

func NewAccount

func NewAccount(t AccountType, name, doc, email, pass, phone string) Account

func (*Account) Deposit

func (a *Account) Deposit(v Money) (*Transaction, error)

func (*Account) Transfer

func (a *Account) Transfer(payee *Account, v Money) (*TransferOutput, error)

type AccountStatus

type AccountStatus string
const (
	AccountStatusActive   AccountStatus = "ACTIVE"
	AccountStatusCanceled AccountStatus = "CANCELED"
)

type AccountType

type AccountType string
const (
	Personal AccountType = "PERSONAL"
	Seller   AccountType = "SELLER"
)

type Money

type Money int64
const (
	Cent     Money = 1
	Real     Money = 100 * Cent
	MilReais Money = 1000 * Real
)

func (Money) Absolute

func (m Money) Absolute() Money

func (Money) String

func (m Money) String() string

type Password

type Password string

func (*Password) Compare

func (p *Password) Compare(input string) error

func (*Password) Ok

func (p *Password) Ok() error

type ResumeAccount

type ResumeAccount struct {
	ID              uuid.UUID
	AccountType     AccountType
	Email           string
	Status          AccountStatus
	PasswordEncoded Password
}

func (*ResumeAccount) JsonRawMessage

func (a *ResumeAccount) JsonRawMessage() json.RawMessage

func (*ResumeAccount) ValidatePassword

func (a *ResumeAccount) ValidatePassword(pass string) error

type Transaction

type Transaction struct {
	ID              uuid.UUID
	CorrelatedID    uuid.NullUUID
	AccountID       uuid.UUID
	TransactionType TransactionType
	Timestamp       time.Time
	Amount          Money
	SnapshotID      uuid.NullUUID
}

type TransactionError

type TransactionError struct {
	Message         string
	AccountID       uuid.UUID
	TransactionType TransactionType
	Amount          Money
}

func NewDepositError

func NewDepositError(msg string, accountID uuid.UUID, amount Money) *TransactionError

func NewTransferError

func NewTransferError(msg string, accountID uuid.UUID, amount Money) TransactionError

func (TransactionError) Error

func (t TransactionError) Error() string

type TransactionType

type TransactionType string
const (
	Deposit       TransactionType = "DEPOSIT"
	TransferPayer TransactionType = "TRANSFER_PAYER"
	TransferPayee TransactionType = "TRANSFER_PAYEE"
	Snapshot      TransactionType = "SNAPSHOT"
)

type TransferOutput

type TransferOutput struct {
	Payer        *Transaction
	Payee        *Transaction
	CorrelatedID uuid.UUID
}

type Wallet

type Wallet []*Transaction

func (*Wallet) Balance

func (w *Wallet) Balance() Money

func (*Wallet) Snapshot

func (w *Wallet) Snapshot(accountID uuid.UUID) *Transaction

Jump to

Keyboard shortcuts

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