Implement CNB exchange rate provider #788
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This implementation fetches exchange rate data from the Czech National Bank's public XML API. The data is parsed and filtered to return rates only for the requested currencies. I chose the CNB's official XML endpoint because it's free, reliable, and maintained by the Czech government. The API updates daily and provides all major currency pairs against CZK.
I used a static HttpClient instance to prevent socket exhaustion through connection reuse. I also added a 10-second timeout since the default 100-second wait is excessive for a simple API call.
Future Improvements
Since CNB rates only update once per day, adding a cache layer would reduce unnecessary API calls. Other potential improvements include async/await for better scalability.