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 = 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 ¶
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 ¶
ProviderError represents an error from a rate provider
func (*ProviderError) Error ¶
func (e *ProviderError) Error() string
func (*ProviderError) Unwrap ¶
func (e *ProviderError) Unwrap() error
Click to show internal directories.
Click to hide internal directories.