mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-02 20:15:22 +02:00
parent
4bf72506d5
commit
53f4b32c33
19 changed files with 91 additions and 86 deletions
|
@ -2,22 +2,25 @@ module Plaidable
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
def plaid_provider
|
||||
Provider::Plaid.new if Rails.application.config.plaid
|
||||
def plaid_us_provider
|
||||
Provider::Plaid.new(Rails.application.config.plaid, :us) if Rails.application.config.plaid
|
||||
end
|
||||
|
||||
def plaid_eu_provider
|
||||
Provider::Plaid.new if Rails.application.config.plaid_eu
|
||||
Provider::Plaid.new(Rails.application.config.plaid_eu, :eu) if Rails.application.config.plaid_eu
|
||||
end
|
||||
|
||||
def plaid_provider_for(plaid_item)
|
||||
return nil unless plaid_item
|
||||
plaid_item.eu? ? plaid_eu_provider : plaid_provider
|
||||
def plaid_provider_for_region(region)
|
||||
region.to_sym == :eu ? plaid_eu_provider : plaid_us_provider
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def plaid_provider_for(plaid_item)
|
||||
self.class.plaid_provider_for(plaid_item)
|
||||
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
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue