domain

package
v0.0.0-...-aafb35e Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccountNotFound = errors.New("account not found")

	ErrAccountOriginNotFound = errors.New("account origin not found")

	ErrAccountDestinationNotFound = errors.New("account destination not found")

	ErrInsufficientBalance = errors.New("origin account does not have sufficient balance")
)
View Source
var (
	ErrRecipeNotFound = errors.New("recipe not found")
)

Functions

func IsValidUUID

func IsValidUUID(uuid string) bool

func NewUUID

func NewUUID() string

Types

type Account

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

func NewAccount

func NewAccount(ID AccountID, name, CPF string, balance Money, createdAt time.Time) Account

func NewAccountBalance

func NewAccountBalance(balance Money) Account

func (Account) Balance

func (a Account) Balance() Money

func (Account) CPF

func (a Account) CPF() string

func (Account) CreatedAt

func (a Account) CreatedAt() time.Time

func (*Account) Deposit

func (a *Account) Deposit(amount Money)

func (Account) ID

func (a Account) ID() AccountID

func (Account) Name

func (a Account) Name() string

func (*Account) Withdraw

func (a *Account) Withdraw(amount Money) error

type AccountID

type AccountID string

func (AccountID) String

func (a AccountID) String() string

type AccountRepository

type AccountRepository interface {
	Create(context.Context, Account) (Account, error)
	UpdateBalance(context.Context, AccountID, Money) error
	FindAll(context.Context) ([]Account, error)
	FindByID(context.Context, AccountID) (Account, error)
	FindBalance(context.Context, AccountID) (Account, error)
}

type Money

type Money int64

func (Money) Float64

func (m Money) Float64() float64

func (Money) Int64

func (m Money) Int64() int64

type Recipe

type Recipe struct {
	ID           RecipeID  `json:"id"`
	Name         string    `json:"name"`
	Tags         []string  `json:"tags"`
	Ingredients  []string  `json:"ingredients"`
	Instructions []string  `json:"instructions"`
	PublishedAt  time.Time `json:"publishedAt"`
}

func NewRecipe

func NewRecipe(ID RecipeID, name string, tags []string, ingredients []string, instructions []string, publishedAt time.Time) Recipe

type RecipeID

type RecipeID string

func (RecipeID) String

func (r RecipeID) String() string

type RecipeRepository

type RecipeRepository interface {
	Create(context.Context, Recipe) (Recipe, error)
	Update(context.Context, RecipeID, Recipe) (Recipe, error)
	FindAll(context.Context) ([]Recipe, error)
	FindByID(context.Context, RecipeID) (Recipe, error)
	Delete(context.Context, RecipeID) error
}

type Transfer

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

func NewTransfer

func NewTransfer(
	ID TransferID,
	accountOriginID AccountID,
	accountDestinationID AccountID,
	amount Money,
	createdAt time.Time,
) Transfer

func (Transfer) AccountDestinationID

func (t Transfer) AccountDestinationID() AccountID

func (Transfer) AccountOriginID

func (t Transfer) AccountOriginID() AccountID

func (Transfer) Amount

func (t Transfer) Amount() Money

func (Transfer) CreatedAt

func (t Transfer) CreatedAt() time.Time

func (Transfer) ID

func (t Transfer) ID() TransferID

type TransferID

type TransferID string

func (TransferID) String

func (t TransferID) String() string

type TransferRepository

type TransferRepository interface {
	Create(context.Context, Transfer) (Transfer, error)
	FindAll(context.Context) ([]Transfer, error)
	WithTransaction(context.Context, func(context.Context) error) error
}

Jump to

Keyboard shortcuts

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