currencies

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rate

type Rate struct {
	Base      accounts.Currency `gorm:"primaryKey"`
	Target    accounts.Currency `gorm:"primaryKey"`
	YearMonth string            `gorm:"primaryKey"`
	Rate      float64
}

type Service

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

Service represents currencies service.

func NewService

func NewService(db Store) *Service

NewService initializes new currencies service.

func (*Service) GetRate

func (s *Service) GetRate(base, target accounts.Currency, month string) float64

GetRate provides the conversion rate for requested currencies in specified month.

func (*Service) SetRate

func (s *Service) SetRate(base, target accounts.Currency, month string, rate float64) error

SetRate sets the conversion rate for requested currencies in specified month.

type Store

type Store interface {
	// SetRate saves conversion rate into the DB.
	SetRate(base, target accounts.Currency, month string, rate float64) error
	// GetRate retrieves conversion rate from the DB.
	GetRate(base, target accounts.Currency, month string) (*Rate, error)
}

Store is an interface for currencies DB API.

func NewGormStore

func NewGormStore(db *gorm.DB) Store

Jump to

Keyboard shortcuts

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