currency

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	USD = Currency{
		Code:   UsdCode,
		Name:   "US Dollar",
		Symbol: UsdSymbol,
	}
	EUR = Currency{
		Code:   EurCode,
		Name:   "Euro",
		Symbol: EurSymbol,
	}
	TRY = Currency{
		Code:   TryCode,
		Name:   "Turkish Lira",
		Symbol: TrySymbol,
	}
	GBP = Currency{
		Code:   GbpCode,
		Name:   "British Pound",
		Symbol: GbpSymbol,
	}
	RUB = Currency{
		Code:   RubCode,
		Name:   "Russian Ruble",
		Symbol: RubSymbol,
	}
	JPY = Currency{
		Code:   JpyCode,
		Name:   "Japanese Yen",
		Symbol: JpySymbol,
	}
	CNY = Currency{
		Code:   CnyCode,
		Name:   "Chinese Yuan",
		Symbol: CnySymbol,
	}
	SOM = Currency{
		Code:   SomCode,
		Name:   "Som",
		Symbol: SomSymbol,
	}
	AUD = Currency{
		Code:   AudCode,
		Name:   "Australian Dollar",
		Symbol: AudSymbol,
	}
	CAD = Currency{
		Code:   CadCode,
		Name:   "Canadian Dollar",
		Symbol: CadSymbol,
	}
	CHF = Currency{
		Code:   ChfCode,
		Name:   "Swiss Franc",
		Symbol: ChfSymbol,
	}
)

Functions

This section is empty.

Types

type Code

type Code string
const (
	UsdCode Code = "USD"
	EurCode Code = "EUR"
	GbpCode Code = "GBP"
	AudCode Code = "AUD"
	CadCode Code = "CAD"
	ChfCode Code = "CHF"
	CnyCode Code = "CNY"
	JpyCode Code = "JPY"
	RubCode Code = "RUB"
	TryCode Code = "TRY"
	SomCode Code = "SOM"
)

func NewCode

func NewCode(value string) (Code, error)

func (Code) IsValid

func (s Code) IsValid() bool

type CreateDTO

type CreateDTO struct {
	Code   string `validate:"required"`
	Name   string `validate:"required"`
	Symbol string `validate:"required"`
}

func (*CreateDTO) Ok

func (p *CreateDTO) Ok(l ut.Translator) (map[string]string, bool)

func (*CreateDTO) ToEntity

func (p *CreateDTO) ToEntity() (*Currency, error)

type CreatedEvent

type CreatedEvent struct {
	Sender  user.User
	Session session.Session
	Data    CreateDTO
	Result  Currency
}

func NewCreatedEvent

func NewCreatedEvent(ctx context.Context, data CreateDTO) (*CreatedEvent, error)

type Currency

type Currency struct {
	Code   Code
	Name   string
	Symbol Symbol
}

func (*Currency) Ok

func (p *Currency) Ok(l ut.Translator) (map[string]string, bool)

type DeletedEvent

type DeletedEvent struct {
	Sender  user.User
	Session session.Session
	Result  Currency
}

func NewDeletedEvent

func NewDeletedEvent(ctx context.Context) (*DeletedEvent, error)

type Repository

type Repository interface {
	Count(ctx context.Context) (uint, error)
	GetAll(ctx context.Context) ([]*Currency, error)
	GetPaginated(ctx context.Context, limit, offset int, sortBy []string) ([]*Currency, error)
	GetByID(ctx context.Context, id uint) (*Currency, error)
	CreateOrUpdate(ctx context.Context, currency *Currency) error
	Create(ctx context.Context, currency *Currency) error
	Update(ctx context.Context, payment *Currency) error
	Delete(ctx context.Context, id uint) error
}

type Symbol

type Symbol string
const (
	UsdSymbol Symbol = "$"
	EurSymbol Symbol = "€"
	GbpSymbol Symbol = "£"
	AudSymbol Symbol = "A$"
	CadSymbol Symbol = "C$"
	ChfSymbol Symbol = "CHF"
	CnySymbol Symbol = "¥"
	JpySymbol Symbol = "¥"
	RubSymbol Symbol = "₽"
	TrySymbol Symbol = "₺"
	SomSymbol Symbol = "S"
)

func NewSymbol

func NewSymbol(value string) (Symbol, error)

func (Symbol) IsValid

func (s Symbol) IsValid() bool

type UpdateDTO

type UpdateDTO struct {
	Code   string `validate:"len=3"`
	Name   string
	Symbol string
}

func (*UpdateDTO) Ok

func (p *UpdateDTO) Ok(l ut.Translator) (map[string]string, bool)

func (*UpdateDTO) ToEntity

func (p *UpdateDTO) ToEntity() (*Currency, error)

type UpdatedEvent

type UpdatedEvent struct {
	Sender  user.User
	Session session.Session
	Data    UpdateDTO
	Result  Currency
}

func NewUpdatedEvent

func NewUpdatedEvent(ctx context.Context, data UpdateDTO) (*UpdatedEvent, error)

Jump to

Keyboard shortcuts

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