entity

package
v0.0.0-...-ac81adf Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCreateTransfer = errors.New("error creating transfer")

	ErrUnauthorizedTransfer = errors.New("unauthorized transfer")
)
View Source
var (
	ErrUserInsufficientBalance = errors.New("user does not have sufficient balance")

	ErrNotFoundUser = errors.New("not found user")

	ErrUpdateUserWallet = errors.New("error updating the value of the wallet")

	ErrCreateUser = errors.New("error creating user")

	ErrFindUserByID = errors.New("error fetching user by ID")
)

Functions

This section is empty.

Types

type Transfer

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

Transfer define the transfer entity

func NewTransfer

func NewTransfer(
	ID vo.Uuid,
	payerID vo.Uuid,
	payeeID vo.Uuid,
	value vo.Money,
	createdAt time.Time,
) Transfer

NewTransfer creates new transfer

func (Transfer) CreatedAt

func (t Transfer) CreatedAt() time.Time

CreatedAt returns the createdAt property

func (Transfer) ID

func (t Transfer) ID() vo.Uuid

ID returns the id property

func (Transfer) Payee

func (t Transfer) Payee() vo.Uuid

Payee returns the payee property

func (Transfer) Payer

func (t Transfer) Payer() vo.Uuid

Payer returns the payer property

func (Transfer) Value

func (t Transfer) Value() vo.Money

Value returns the value property

type TransferRepositoryCreator

type TransferRepositoryCreator interface {
	Create(context.Context, Transfer) error
	WithTransaction(context.Context, func(context.Context) error) error
}

TransferRepositoryCreator defines the operation of creating a transfer entity

type User

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

User defines the user entity

func NewCommonUser

func NewCommonUser(
	ID vo.Uuid,
	fullName vo.FullName,
	email vo.Email,
	password vo.Password,
	document vo.Document,
	wallet *vo.Wallet,
	createdAt time.Time,
) User

NewCommonUser creates new common user

func NewMerchantUser

func NewMerchantUser(
	ID vo.Uuid,
	fullName vo.FullName,
	email vo.Email,
	password vo.Password,
	document vo.Document,
	wallet *vo.Wallet,
	createdAt time.Time,
) User

NewMerchant creates new merchant user

func NewUser

func NewUser(
	ID vo.Uuid,
	fullName vo.FullName,
	email vo.Email,
	password vo.Password,
	document vo.Document,
	wallet *vo.Wallet,
	typeUser vo.TypeUser,
	createdAt time.Time,
) (User, error)

NewUser is a factory for users

func (User) CanTransfer

func (u User) CanTransfer() error

CanTransfer returns whether it is possible to transfer

func (User) CreatedAt

func (u User) CreatedAt() time.Time

CreatedAt returns the createdAt property

func (User) Deposit

func (u User) Deposit(money vo.Money)

Deposit add value of money of wallet

func (User) Document

func (u User) Document() vo.Document

Document returns the document property

func (User) Email

func (u User) Email() vo.Email

Email returns the email property

func (User) FullName

func (u User) FullName() vo.FullName

FullName returns the fullName property

func (User) ID

func (u User) ID() vo.Uuid

ID returns the id property

func (User) Password

func (u User) Password() vo.Password

Password returns the password property

func (User) Roles

func (u User) Roles() vo.Roles

Roles returns the roles property

func (User) TypeUser

func (u User) TypeUser() vo.TypeUser

TypeUser returns the typeUser property

func (User) Wallet

func (u User) Wallet() *vo.Wallet

Wallet returns the wallet property

func (User) Withdraw

func (u User) Withdraw(money vo.Money) error

Withdraw remove value of money of wallet

type UserRepositoryCreator

type UserRepositoryCreator interface {
	Create(context.Context, User) (User, error)
}

UserRepositoryCreator defines the operation of creating a transfer entity

type UserRepositoryFinder

type UserRepositoryFinder interface {
	FindByID(context.Context, vo.Uuid) (User, error)
}

UserRepositoryFinder defines the search operation for a user entity

type UserRepositoryUpdater

type UserRepositoryUpdater interface {
	UpdateWallet(context.Context, vo.Uuid, vo.Money) error
}

UserRepositoryUpdater defines the update operation of a user entity wallet

Jump to

Keyboard shortcuts

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