Documentation
¶
Overview ¶
Package exchangerate is the library behind the exchangerate command line: the HTTP client, request shaping, and the typed data models for the ExchangeRate-API open tier at open.er-api.com.
No API key required. The client sets a real User-Agent, paces requests, and retries transient failures (429 and 5xx) with exponential backoff.
Index ¶
Constants ¶
const Host = "open.er-api.com"
Host is the site this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to open.er-api.com over HTTP.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable parameters for the Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
type Conversion ¶
type Conversion struct {
From string `kit:"id" json:"from"`
To string `json:"to"`
Amount float64 `json:"amount"`
Result float64 `json:"result"`
Rate float64 `json:"rate"`
UpdatedAt string `json:"updated_at"` // time_last_update_utc verbatim
}
Conversion is the result of converting an amount from one currency to another.
type Domain ¶
type Domain struct{}
Domain is the exchangerate driver.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.
type Rate ¶
type Rate struct {
Rank int `json:"rank"`
Currency string `kit:"id" json:"currency"` // ISO 4217 code, e.g. "EUR"
Rate float64 `json:"rate"` // units of Currency per 1 unit of base
Base string `json:"base"` // the base currency, e.g. "USD"
}
Rate is one currency's exchange rate against a base currency.