msigut / CNB.Exchange

CNB.cz daily Exchange Rates .NET Standard 2.0 Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CNB.Exchange

CNB.cz .NET Standard 2.0 Library (netstandard2.0). By ČNB

Supports

  • Dependency injection by IHttpClientFactory
  • CurrencyCode as enum (Generator project included)
  • direct query for exchange-rate by ExchangeRateCode

Dependency injection

More in CNB.Tests project, file: TestFixture.cs and BasicTest.cs.

// DI configuration
services.AddHttpClient();
services.AddScoped<CnbClient>();

// in constructor
_cnb = test.Services.GetRequiredService<CnbClient>();

Using

// return decimal value of Exchange rate for EUR
await _cnb.ExchangeRateCode(CurrencyCode.EUR);

// return all Exchange rates
await _cnb.ExchangeRateAll();

// return all Bank codes
await _cnb.BankCodeAll();

ExchangeRate.cs contains:

  • Country - country name (in Czech)
  • CurrencyName - currency name (in Czech)
  • Amount - currency amount (example: 1, 100)
  • Code - currency code (as string; example: EUR, USD, ...)
  • Rate - exchange rate (as decimal; example: 25.877)
  • CurrencyCode - code (as nullable enum; example: CurrencyCode.EUR, CurrencyCode.GBR, ...)

BankCode.cs contains:

  • Code - bank code
  • Name - bank name (in Czech)
  • BIC - BIC (SWIFT)
  • CERTIS - CERTIS

About

CNB.cz daily Exchange Rates .NET Standard 2.0 Library

License:MIT License


Languages

Language:C# 84.8%Language:PowerShell 15.2%