2024-03-27 09:16:00 -06:00
|
|
|
# `Providable` serves as an extension point for integrating multiple providers.
|
|
|
|
# For an example of a multi-provider, multi-concept implementation,
|
|
|
|
# see: https://github.com/maybe-finance/maybe/pull/561
|
|
|
|
|
|
|
|
module Providable
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
class_methods do
|
2024-08-01 19:43:23 -04:00
|
|
|
def security_prices_provider
|
|
|
|
synth_provider
|
|
|
|
end
|
2024-07-08 09:04:59 -04:00
|
|
|
|
2024-10-30 18:08:19 -04:00
|
|
|
def security_info_provider
|
|
|
|
synth_provider
|
|
|
|
end
|
|
|
|
|
2024-08-01 19:43:23 -04:00
|
|
|
def exchange_rates_provider
|
|
|
|
synth_provider
|
2024-03-27 09:16:00 -06:00
|
|
|
end
|
2024-04-13 09:28:45 -04:00
|
|
|
|
|
|
|
def git_repository_provider
|
|
|
|
Provider::Github.new
|
|
|
|
end
|
2024-08-01 19:43:23 -04:00
|
|
|
|
2024-10-02 12:07:56 -04:00
|
|
|
def synth_provider
|
2024-12-13 17:22:27 -05:00
|
|
|
@synth_provider ||= begin
|
|
|
|
api_key = self_hosted? ? Setting.synth_api_key : ENV["SYNTH_API_KEY"]
|
|
|
|
api_key.present? ? Provider::Synth.new(api_key) : nil
|
|
|
|
end
|
2024-10-02 12:07:56 -04:00
|
|
|
end
|
2024-08-16 12:13:48 -04:00
|
|
|
|
2024-10-02 12:07:56 -04:00
|
|
|
private
|
2024-08-16 12:13:48 -04:00
|
|
|
def self_hosted?
|
|
|
|
Rails.application.config.app_mode.self_hosted?
|
2024-08-01 19:43:23 -04:00
|
|
|
end
|
2024-03-27 09:16:00 -06:00
|
|
|
end
|
|
|
|
end
|