currency

package
v0.0.0-...-58f0064 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCurrencyNotFound = errors.New("currency not found")

ErrCurrencyNotFound is returned when a currency is not found in the database.

Functions

This section is empty.

Types

type CreateReq

type CreateReq struct {
	Code         string          `json:"code"`
	ExchangeRate decimal.Decimal `json:"exchangeRate"`
}

CreateReq represents a request for creating a currency.

func (*CreateReq) Validate

func (r *CreateReq) Validate() error

type Currency

type Currency struct {
	ID           string          `json:"id"`
	Code         string          `json:"code"`
	ExchangeRate decimal.Decimal `json:"exchangeRate"`
	CreatedAt    time.Time       `json:"createdAt"`
	UpdatedAt    time.Time       `json:"updatedAt"`
	// contains filtered or unexported fields
}

Currency represents a currency and its exchange rate. The Code is the ISO 4217 currency code.

Base currency is LAK.

type ExchangeRateReq

type ExchangeRateReq struct {
	ID           string          `param:"id"`
	ExchangeRate decimal.Decimal `json:"exchangeRate"`
}

ExchangeRateReq represents a request to update an exchange rate.

func (*ExchangeRateReq) Validate

func (r *ExchangeRateReq) Validate() error

type ListCurrenciesResult

type ListCurrenciesResult struct {
	Currencies    []*Currency `json:"currencies"`
	NextPageToken string      `json:"nextPageToken"`
}

type Query

type Query struct {
	ID            string    `json:"id" param:"id" query:"id"`
	Code          string    `json:"code"  query:"code"`
	PageToken     string    `json:"pageToken"  query:"pageToken"`
	PageSize      uint64    `json:"pageSize"  query:"pageSize"`
	CreatedAfter  time.Time `json:"createdAfter"  query:"createdAfter"`
	CreatedBefore time.Time `json:"createdBefore"  query:"createdBefore"`
}

func (*Query) ToSql

func (q *Query) ToSql() (string, []any, error)

type Service

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

func NewService

func NewService(_ context.Context, db *sql.DB, zlog *zap.Logger) (*Service, error)

func (*Service) CreateCurrency

func (s *Service) CreateCurrency(ctx context.Context, in *CreateReq) (*Currency, error)

func (*Service) GetCurrencyByCode

func (s *Service) GetCurrencyByCode(ctx context.Context, code string) (*Currency, error)

func (*Service) GetCurrencyByID

func (s *Service) GetCurrencyByID(ctx context.Context, id string) (*Currency, error)

func (*Service) ListCurrencies

func (s *Service) ListCurrencies(ctx context.Context, in *Query) (*ListCurrenciesResult, error)

func (*Service) UpdateExchangeRate

func (s *Service) UpdateExchangeRate(ctx context.Context, in *ExchangeRateReq) (*Currency, error)

Jump to

Keyboard shortcuts

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