Table of Contents

FixerRateProvider Class

Definition

Namespace
Bodu.Financial.ExchangeRates
Assembly
Bodu.Financial.ExchangeRates.Fixer.dll
Package
Bodu.Financial.ExchangeRates.Fixer 0.7.1
Source
FixerRateProvider.cs

Serves Fixer (fixer.io) exchange rates as ExchangeRate values, implementing the Bodu.Financial provider contracts over the Fixer time-series and historical JSON REST endpoints.

public sealed class FixerRateProvider : PairWebRateProvider<FixerSeriesInfo>, IDatedRateProvider, IRateProvider, IPairRateLoader, IHistoricalRateProvider, IDisposable
Inheritance
FixerRateProvider
Implements
Inherited Members
Extension Methods

Examples

using var fixer = new FixerRateProvider(new FixerRateProviderOptions { ApiKey = "…" });
await fixer.LoadPairAsync("EUR", "USD", new DateOnly(2023, 1, 1), new DateOnly(2023, 1, 31));

RateLookupResult usd = fixer.GetRate("EUR", "USD", new DateOnly(2023, 1, 3));

Remarks

The provider derives from PairWebRateProvider<TSeries>, which supplies the per-pair coverage tracking, single-flight coalescing, fetch-and-accumulate orchestration, and diagnostic logging shared by every pair-based web source; this type contributes only the Fixer identity and exception text. A pair is fetched by denominating the response against the source currency and requesting the destination currency as the quote symbol. Use LoadPairAsync(string, string, DateOnly, DateOnly, CancellationToken) to warm a pair's in-memory store.

Plan limits. Fixer's free plan is locked to a EUR base and to the latest and single-date endpoints; changing the base currency and the time-series endpoint require a paid plan. A request the account's plan does not permit surfaces as a fetch failure rather than being pre-empted, so a caller on the free plan should request pairs whose source currency is EUR (or map non-EUR sources through the inverse-lookup fallback).

HttpClient ownership. The constructor that takes only options builds and owns an HttpClient configured with the options' UserAgent and HttpTimeout, disposing it with the provider. The constructor that takes an HttpClient uses the caller-supplied client as-is; this is the path the dependency-injection package uses.

Constructors

FixerRateProvider(FixerRateProviderOptions, ILogger?, TimeProvider?)

Initializes a new instance of the FixerRateProvider class backed by an HttpClient the provider creates and owns, configured from the supplied options.

public FixerRateProvider(FixerRateProviderOptions options, ILogger? logger = null, TimeProvider? timeProvider = null)

Parameters

options FixerRateProviderOptions

The provider options.

logger ILogger

The logger that records downloads and on-demand network fetches. null selects a no-op logger.

timeProvider TimeProvider

The time source used to resolve the current instant for the undated lookup surface. null selects System.

Exceptions

ArgumentNullException

Thrown when options is null.

ArgumentException

Thrown when options fails validation.

FixerRateProvider(HttpClient, FixerRateProviderOptions, ILogger?, TimeProvider?)

Initializes a new instance of the FixerRateProvider class backed by the Fixer endpoints, queried with the caller-supplied HTTP client. The caller owns the client's configuration and lifetime.

public FixerRateProvider(HttpClient httpClient, FixerRateProviderOptions options, ILogger? logger = null, TimeProvider? timeProvider = null)

Parameters

httpClient HttpClient

The HTTP client used to issue requests.

options FixerRateProviderOptions

The provider options.

logger ILogger

The logger that records downloads and on-demand network fetches. null selects a no-op logger.

timeProvider TimeProvider

The time source used to resolve the current instant for the undated lookup surface. null selects System.

Exceptions

ArgumentNullException

Thrown when httpClient or options is null.

ArgumentException

Thrown when options fails validation.

Fields

ProviderName

The provider identifier stamped on every rate this provider produces.

public const string ProviderName = "Fixer"

Field Value

string

Properties

ProviderId

Gets the provider identifier stamped on every rate this provider produces.

protected override string ProviderId { get; }

Property Value

string

The provider identifier.

Methods

FormatRateNotFound(string, string, DateOnly)

Formats the message for the KeyNotFoundException thrown when a single-rate lookup fails. Derived types may override to use a feed-specific resource string.

protected override string FormatRateNotFound(string fromIsoCode, string toIsoCode, DateOnly date)

Parameters

fromIsoCode string

The source-currency ISO code.

toIsoCode string

The destination-currency ISO code.

date DateOnly

The requested date.

Returns

string

The exception message.

Applies to

ProductVersions
.NET8, 10