core

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidRate indicates that an invalid exchange rate was provided
	ErrInvalidRate = errors.New("invalid exchange rate")

	// ErrUnsupportedCurrencyPair indicates that the currency pair is not supported
	ErrUnsupportedCurrencyPair = errors.New("unsupported currency pair")

	// ErrProviderUnavailable indicates that the rate provider is not available
	ErrProviderUnavailable = errors.New("rate provider unavailable")

	// ErrRateNotFound indicates that the requested rate was not found
	ErrRateNotFound = errors.New("exchange rate not found")

	// ErrInvalidAmount indicates that an invalid amount was provided
	ErrInvalidAmount = errors.New("invalid amount")
)

Common errors for exchange operations

Functions

func IsProviderError

func IsProviderError(err error) bool

IsProviderError checks if an error is a ProviderError

Types

type ConversionRequest

type ConversionRequest struct {
	From   string  `json:"from"`
	To     string  `json:"to"`
	Amount float64 `json:"amount"`
}

ConversionRequest represents a request to convert an amount between currencies

type ConversionResult

type ConversionResult struct {
	FromAmount float64 `json:"from_amount"`
	ToAmount   float64 `json:"to_amount"`
	Rate       float64 `json:"rate"`
	Source     string  `json:"source"`
}

ConversionResult represents the result of a currency conversion

type ProviderError

type ProviderError struct {
	Provider string
	Err      error
}

ProviderError represents an error from a rate provider

func (*ProviderError) Error

func (e *ProviderError) Error() string

func (*ProviderError) Unwrap

func (e *ProviderError) Unwrap() error

type Rate

type Rate struct {
	From      string    `json:"from"`
	To        string    `json:"to"`
	Value     float64   `json:"value"`
	Source    string    `json:"source"`
	Timestamp time.Time `json:"timestamp"`
}

Rate represents an exchange rate between two currencies

type RateInfo

type RateInfo struct {
	Rate
	IsStale bool          `json:"is_stale"`
	TTL     time.Duration `json:"ttl"`
}

RateInfo contains additional metadata about a rate

Jump to

Keyboard shortcuts

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