Add Frankfurter v2 provider (frankfurter_v2 driver)#39
Open
anousss007 wants to merge 1 commit into
Open
Conversation
The bundled frankfurter driver targets the v1 API (GET /latest?from=&to= returning {rates:{CODE:rate}}). The v2 API uses GET /v2/rates?base="es= and returns a list of rows shaped {date, base, quote, rate}, so it is not reachable by swapping the base URL alone. v2 also covers a much larger currency set than the ECB-only v1 (e.g. AED, MAD).
Add a FrankfurterV2Provider that maps the v2 rows back into the quote => rate shape before building Rates, registered as a new 'frankfurter_v2' driver (no API key, base_url configurable via FRANKFURTER_V2_BASE_URL). Includes unit tests, the manager dataset entry, a config block and a README section.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The bundled
frankfurterdriver targets the v1 API (GET /latest?from=&to=returning{ "rates": { "CODE": rate } }). The v2 API is shaped differently:GET /v2/rates?base=EUR"es=USD,AED[{ "date": ..., "base": ..., "quote": ..., "rate": ... }]So v2 can't be reached by swapping
FRANKFURTER_BASE_URLalone (hitting/v2/latest?from=...returns a 404). v2 also covers a much larger currency set than the ECB-only v1 — for exampleAEDandMAD, which don't come back from the v1latestcall — and that's the main reason to support it.What this adds
FrankfurterV2Provider— calls/rateswithbase/quotesand maps the v2 rows back into thequote => rateshape before buildingRates.frankfurter_v2driver inExchangeRateManager(no API key; base URL configurable viaFRANKFURTER_V2_BASE_URL, defaulting tohttps://api.frankfurter.dev/v2).READMEsection, unit tests, and the manager "can instantiate all drivers" dataset entry.It's kept as a separate driver (
frankfurter_v2) rather than changingfrankfurter, so it's fully non-breaking. Happy to instead fold it into the existing driver behind aversionoption if you'd prefer that shape.Small note: the provider parses the response date with
!Y-m-d, so theretrievedAtdate can't roll over when the instance is converted to theEurope/Amsterdamtimezone (independent of the runner's local time/zone).Follows up on the discussion about adding v2 support.