1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 13:19:39 +02:00

Fetch exchange rates in bulk from synth (#1069)

* Fetch exchnage rates in bulk

* Handle paginated response

* Rename method and improve tests

* Change argument names

* Use standard date format
This commit is contained in:
Tony Vincent 2024-08-09 16:57:33 +02:00 committed by GitHub
parent f315370512
commit 6fa40e0fa2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 297 additions and 11 deletions

View file

@ -16,6 +16,17 @@ class Provider::SynthTest < ActiveSupport::TestCase
end
end
test "fetches paginated exchange_rate historical data" do
VCR.use_cassette("synth/exchange_rate_historical") do
response = @synth.fetch_exchange_rates(
from: "USD", to: "GBP", start_date: Date.parse("01.01.2024"), end_date: Date.parse("31.07.2024")
)
assert 213, response.rates.size # 213 days between 01.01.2024 and 31.07.2024
assert_equal [ :date, :rate ], response.rates.first.keys
end
end
test "retries then provides failed response" do
@client = mock
Faraday.stubs(:new).returns(@client)