converter

package
v0.0.0-...-7043ee9 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntPow

func IntPow[T ~int | ~int16 | ~int32 | ~int64](n T, m T) T

func ParseRat

func ParseRat(s string) (*big.Rat, error)

Types

type Converter

type Converter struct {
	Client         *http.Client
	TimeToLive     time.Duration
	Endpoint       *url.URL
	BaseCurrency   string
	AppID          string
	CacheDirectory string
	// contains filtered or unexported fields
}

func (*Converter) ConvertTo

func (c *Converter) ConvertTo(ctx context.Context, currency string, qty *big.Rat) (*big.Rat, error)

func (*Converter) Update

func (c *Converter) Update(ctx context.Context) error

func (*Converter) Validate

func (c *Converter) Validate() error

type Data

type Data struct {
	Disclaimer string                 `json:"disclaimer,omitempty"`
	License    string                 `json:"license,omitempty"`
	Timestamp  int                    `json:"timestamp,omitempty"`
	Base       string                 `json:"base,omitempty"`
	Rates      map[string]json.Number `json:"rates,omitempty"`
}

func (*Data) Load

func (d *Data) Load(filename string) error

func (*Data) Save

func (d *Data) Save(filename string) error

func (*Data) Time

func (d *Data) Time() time.Time

type NoExchangeRateError

type NoExchangeRateError struct {
	BaseCurrency string
	Currency     string
}

func (NoExchangeRateError) Error

func (e NoExchangeRateError) Error() string

Jump to

Keyboard shortcuts

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