mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
Lunchflow integration (#259)
* First pass lunch flow * Fixes - Fix apikey not being saved properly due to provider no reload support - Fix proper messages if we try to link existing accounts. * Fix better error handling * Filter existing transactions and skip duplicates * FIX messaging * Branding :) * Fix XSS and linter * FIX provider concern - also fix code duplication * FIX md5 digest * Updated determine_sync_start_date to be account-aware * Review fixes * Broaden error catch to not crash UI * Fix buttons styling * FIX process account error handling * FIX account cap and url parsing * Lunch Flow brand * Found orphan i18n strings * Remove per conversation with @sokie --------- Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
This commit is contained in:
@@ -68,6 +68,32 @@ module AccountableResource
|
||||
def set_link_options
|
||||
@show_us_link = Current.family.can_connect_plaid_us?
|
||||
@show_eu_link = Current.family.can_connect_plaid_eu?
|
||||
@show_lunchflow_link = Current.family.can_connect_lunchflow?
|
||||
|
||||
# Preload Lunchflow accounts if available and cache them
|
||||
if @show_lunchflow_link
|
||||
cache_key = "lunchflow_accounts_#{Current.family.id}"
|
||||
|
||||
@lunchflow_accounts = Rails.cache.fetch(cache_key, expires_in: 5.minutes) do
|
||||
begin
|
||||
lunchflow_provider = Provider::LunchflowAdapter.build_provider
|
||||
|
||||
if lunchflow_provider.present?
|
||||
accounts_data = lunchflow_provider.get_accounts
|
||||
accounts_data[:accounts] || []
|
||||
else
|
||||
[]
|
||||
end
|
||||
rescue Provider::Lunchflow::LunchflowError => e
|
||||
Rails.logger.error("Failed to preload Lunchflow accounts: #{e.message}")
|
||||
[]
|
||||
rescue StandardError => e
|
||||
Rails.logger.error("Unexpected error preloading Lunchflow accounts: #{e.class}: #{e.message}")
|
||||
Rails.logger.error(e.backtrace.join("\n"))
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def accountable_type
|
||||
|
||||
Reference in New Issue
Block a user