Skip to content

Conversation

antoniosavolare
Copy link

@antoniosavolare antoniosavolare commented Jul 11, 2025

This implementation retrieves daily exchange rates from the Czech National Bank and maps them to the required structure.

  • The XML parsing uses CultureInfo("cs-CZ") to handle Czech decimal formats.
  • The source currency (CZK) is fixed as per CNB convention.
  • Only exchange rates explicitly provided by the source are returned, as per the requirement.
  • TryParse is deliberately avoided: since the feed format is stable and controlled, parsing failures would signal an upstream change worth surfacing early.
  • The solution is structured synchronously except for the HTTP call, and the XML parsing is kept simple and inline to stay within the time constraints (no extra mapping classes used).

Architecture improvements:

  • Introduced IExchangeRateProvider interface.
  • Registered dependencies via Startup.cs using Dependency Injection.
  • Structured logging (without console output for production readiness).
  • Folder structure reorganized into Interfaces, Models, and Services for clarity and maintainability.

Tests:

  • Added unit tests for both CnbXmlParser and ExchangeRateProvider to ensure correctness of XML parsing and integration logic.

Possible extension:
Depending on how critical real-time data is, the solution could be extended with a caching layer (e.g., in-memory) with a configurable TTL. This would reduce external calls while maintaining acceptable freshness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant