Implement Synth as an exchange rate provider #574

Merged
josefarias merged 6 commits from synth-provider into main 2024-03-27 23:16:00 +08:00
josefarias commented 2024-03-27 11:19:58 +08:00 (Migrated from github.com)

This PR is a pared down version of https://github.com/maybe-finance/maybe/pull/561, where we sketched out a multi-provider, multi-concept implementation. Please see the other PR for a detailed explanation.

This PR is a pared down version of https://github.com/maybe-finance/maybe/pull/561, where we sketched out a multi-provider, multi-concept implementation. Please see the other PR for a detailed explanation.
josefarias (Migrated from github.com) reviewed 2024-03-27 11:23:04 +08:00
@@ -0,0 +3,4 @@
def initialize(api_key = ENV["SYNTH_API_KEY"])
@api_key = api_key || ENV["SYNTH_API_KEY"]
end
josefarias (Migrated from github.com) commented 2024-03-27 11:23:04 +08:00

This looks like we're doubly guarding for the same thing. We're not. But it's an admittedly slightly premature guard.

When we ultimately pass in ENV["EXCHANGE_RATE_PROVIDER_API_KEY"] — that value might be nil.

If we want to both be able to instantiate this without any args (Provider::Synth.new) and also be able to pass in a possibly nil key, I think this would be the way to support that.

This looks like we're doubly guarding for the same thing. We're not. But it's an admittedly slightly premature guard. When we ultimately pass in `ENV["EXCHANGE_RATE_PROVIDER_API_KEY"]` — that value might be nil. If we want to both be able to instantiate this without any args (`Provider::Synth.new`) and also be able to pass in a possibly `nil` key, I think this would be the way to support that.
zachgoll (Migrated from github.com) approved these changes 2024-03-27 22:51:21 +08:00
zachgoll (Migrated from github.com) left a comment

This looks great and I think it's at a perfect starting level of abstraction. Thanks for the collab on this one!

This looks great and I think it's at a perfect starting level of abstraction. Thanks for the collab on this one!
Sign in to join this conversation.