mirror of
https://github.com/we-promise/sure.git
synced 2026-04-17 19:14:11 +00:00
* Move provider config to family * remove global settings * Remove turbo auto submit * Fix flash location * Fix mssing syncer for lunchflow * Update schema.rb * FIX tests and encryption config * FIX make rabbit happy * FIX run migration in SQL * FIX turbo frame modal * Branding fixes * FIX rabbit * OCD with product names * More OCD * No other console.log|warn in codebase --------- Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
61 lines
1.3 KiB
Ruby
61 lines
1.3 KiB
Ruby
class Provider::SimplefinAdapter < Provider::Base
|
|
include Provider::Syncable
|
|
include Provider::InstitutionMetadata
|
|
|
|
# Register this adapter with the factory
|
|
Provider::Factory.register("SimplefinAccount", self)
|
|
|
|
def provider_name
|
|
"simplefin"
|
|
end
|
|
|
|
def sync_path
|
|
Rails.application.routes.url_helpers.sync_simplefin_item_path(item)
|
|
end
|
|
|
|
def item
|
|
provider_account.simplefin_item
|
|
end
|
|
|
|
def can_delete_holdings?
|
|
false
|
|
end
|
|
|
|
def institution_domain
|
|
org_data = provider_account.org_data
|
|
return nil unless org_data.present?
|
|
|
|
domain = org_data["domain"]
|
|
url = org_data["url"] || org_data["sfin-url"]
|
|
|
|
# Derive domain from URL if missing
|
|
if domain.blank? && url.present?
|
|
begin
|
|
domain = URI.parse(url).host&.gsub(/^www\./, "")
|
|
rescue URI::InvalidURIError
|
|
Rails.logger.warn("Invalid institution URL for SimpleFin account #{provider_account.id}: #{url}")
|
|
end
|
|
end
|
|
|
|
domain
|
|
end
|
|
|
|
def institution_name
|
|
org_data = provider_account.org_data
|
|
return nil unless org_data.present?
|
|
|
|
org_data["name"] || item&.institution_name
|
|
end
|
|
|
|
def institution_url
|
|
org_data = provider_account.org_data
|
|
return nil unless org_data.present?
|
|
|
|
org_data["url"] || org_data["sfin-url"] || item&.institution_url
|
|
end
|
|
|
|
def institution_color
|
|
item&.institution_color
|
|
end
|
|
end
|