wallet

package
v0.0.0-...-eecab09 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorCodeRepository = domainerrors.ErrorCodeApplication + domainerrors.ErrorCodeApplicationWallet + iota
	ErrorCodeValidateInput
	ErrorCodeCast
)

Variables

View Source
var (
	ErrValidation         = errors.New("validation failed")
	ErrCastToEntityFailed = errors.New("cast to entity failed")
)

Functions

This section is empty.

Types

type CreatedInput

type CreatedInput struct {
	Name        string       `json:"name"`
	Description string       `json:"description" validate:"omitempty"`
	Chain       entity.Chain `json:"chain"`
	UserID      string       `json:"userId" validate:"required,alphanum,len=20"`
}

func (*CreatedInput) ToEntity

func (c *CreatedInput) ToEntity() *entity.Wallet

func (*CreatedInput) Validate

func (c *CreatedInput) Validate() error

type DeletedInput

type DeletedInput struct {
	ID string `json:"id" validate:"required,alphanum,len=20"`
}

func (*DeletedInput) Validate

func (i *DeletedInput) Validate() error

type DetailGotInput

type DetailGotInput struct {
	ID string `json:"id" validate:"required,alphanum,len=20"`
}

func (*DetailGotInput) Validate

func (i *DetailGotInput) Validate() error

type IService

type IService interface {
	// Command
	CreateWallet(ctx context.Context, walletInfo *CreatedInput) (*Output, error)
	UpdateWallet(ctx context.Context, walletInfo *UpdatedInput) (*Output, error)
	DeleteWallet(ctx context.Context, walletInfo *DeletedInput) (*Output, error)
	// // Query
	GetWalletList(ctx context.Context, walletInfo *ListGotInput) (*OutputList, error)
	GetWalletDetail(ctx context.Context, walletInfo *DetailGotInput) (*Output, error)
}

type ListGotInput

type ListGotInput struct {
	Limit      int      `json:"limit"`
	Offset     int      `json:"offset"`
	FilterName string   `json:"filterName" validate:"omitempty,oneof=name"`
	SortFields []string `json:"sortFields" validate:"dive,oneof=id name updated_at created_at"`
	Dir        string   `json:"dir" validate:"oneof=asc desc"`
}

func (*ListGotInput) ToEntity

func (i *ListGotInput) ToEntity() *entity.Role

func (*ListGotInput) ToSearchQuery

func (i *ListGotInput) ToSearchQuery() *domain.SearchQuery

func (*ListGotInput) Validate

func (i *ListGotInput) Validate() error

type Output

type Output struct {
	ID          string       `json:"id"`
	Name        string       `json:"name"`
	Description string       `json:"description"`
	Chain       entity.Chain `json:"chain"`
	UserID      string       `json:"userId"`
	CreatedAt   time.Time    `json:"createdAt"`
	UpdatedAt   time.Time    `json:"updatedAt"`
	DeletedAt   time.Time    `json:"deletedAt"`
}

func NewOutput

func NewOutput(e *entity.Wallet) *Output

type OutputList

type OutputList struct {
	Offset int64    `json:"offset"`
	Limit  int64    `json:"limit"`
	Total  int64    `json:"total"`
	Items  []Output `json:"items"`
}

func NewListOutput

func NewListOutput(e *domain.List) *OutputList

type ServiceImpl

type ServiceImpl struct {
	TransactionRepo domain.ITransactionRepo
	WalletRepo      repository.WalletRepository
	UserRepo        repository.UserRepository
	EventProducer   event.Producer
	// contains filtered or unexported fields
}

ServiceImpl -.

func NewServiceImpl

func NewServiceImpl(walletRepo repository.WalletRepository, userRepo repository.UserRepository, transactionRepo domain.ITransactionRepo, eventProducer event.Producer, l pwlogger.Interface) *ServiceImpl

NewServiceImpl -.

func (*ServiceImpl) CreateWallet

func (u *ServiceImpl) CreateWallet(ctx context.Context, walletInfo *CreatedInput) (*Output, error)

CreateWallet creates a wallet.

func (*ServiceImpl) DeleteWallet

func (u *ServiceImpl) DeleteWallet(ctx context.Context, walletInfo *DeletedInput) (*Output, error)

DeleteWallet deletes wallet.

func (*ServiceImpl) GetWalletDetail

func (u *ServiceImpl) GetWalletDetail(ctx context.Context, walletInfo *DetailGotInput) (*Output, error)

GetWalletDetail gets wallet detail.

func (*ServiceImpl) GetWalletList

func (u *ServiceImpl) GetWalletList(ctx context.Context, walletInfo *ListGotInput) (*OutputList, error)

GetWalletList gets wallet list.

func (*ServiceImpl) UpdateWallet

func (u *ServiceImpl) UpdateWallet(ctx context.Context, walletInfo *UpdatedInput) (*Output, error)

UpdateWallet updates wallet.

type UpdatedInput

type UpdatedInput struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

func (*UpdatedInput) ToEntity

func (c *UpdatedInput) ToEntity() *entity.Role

func (*UpdatedInput) Validate

func (c *UpdatedInput) Validate() error

Jump to

Keyboard shortcuts

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