2024-11-15 13:49:37 -05:00
|
|
|
module Plaidable
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
class_methods do
|
2025-01-31 17:04:26 -05:00
|
|
|
def plaid_us_provider
|
2025-02-07 10:35:42 -05:00
|
|
|
Provider::Plaid.new(Rails.application.config.plaid, region: :us) if Rails.application.config.plaid
|
2024-11-15 13:49:37 -05:00
|
|
|
end
|
2025-01-31 12:13:58 -06:00
|
|
|
|
|
|
|
def plaid_eu_provider
|
2025-02-07 10:35:42 -05:00
|
|
|
Provider::Plaid.new(Rails.application.config.plaid_eu, region: :eu) if Rails.application.config.plaid_eu
|
2025-01-31 12:13:58 -06:00
|
|
|
end
|
|
|
|
|
2025-01-31 17:04:26 -05:00
|
|
|
def plaid_provider_for_region(region)
|
|
|
|
region.to_sym == :eu ? plaid_eu_provider : plaid_us_provider
|
2025-01-31 12:13:58 -06:00
|
|
|
end
|
2024-11-15 13:49:37 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
2025-01-31 17:04:26 -05:00
|
|
|
def eu?
|
|
|
|
raise "eu? is not implemented for #{self.class.name}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def plaid_provider
|
|
|
|
eu? ? self.class.plaid_eu_provider : self.class.plaid_us_provider
|
2024-11-15 13:49:37 -05:00
|
|
|
end
|
|
|
|
end
|