Lunchflow settings family (#363)

* 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>
This commit is contained in:
soky srm
2025-11-22 02:14:29 +01:00
committed by GitHub
parent 983fb177fc
commit be0b20dfd9
25 changed files with 532 additions and 127 deletions

View File

@@ -1,7 +1,7 @@
class Provider::Lunchflow
include HTTParty
headers "User-Agent" => "Sure Finance Lunchflow Client"
headers "User-Agent" => "Sure Finance Lunch Flow Client"
default_options.merge!(verify: true, ssl_verify_mode: OpenSSL::SSL::VERIFY_PEER, timeout: 120)
attr_reader :api_key, :base_url
@@ -94,7 +94,7 @@ class Provider::Lunchflow
JSON.parse(response.body, symbolize_names: true)
when 400
Rails.logger.error "Lunch Flow API: Bad request - #{response.body}"
raise LunchflowError.new("Bad request to Lunchflow API: #{response.body}", :bad_request)
raise LunchflowError.new("Bad request to Lunch Flow API: #{response.body}", :bad_request)
when 401
raise LunchflowError.new("Invalid API key", :unauthorized)
when 403

View File

@@ -1,55 +1,29 @@
class Provider::LunchflowAdapter < Provider::Base
include Provider::Syncable
include Provider::InstitutionMetadata
include Provider::Configurable
# Register this adapter with the factory
Provider::Factory.register("LunchflowAccount", self)
# Configuration for Lunch Flow
configure do
description <<~DESC
Setup instructions:
1. Visit [Lunch Flow](https://www.lunchflow.app) to get your API key
2. Enter your API key below to enable Lunch Flow bank data sync
3. Choose the appropriate environment (production or staging)
DESC
field :api_key,
label: "API Key",
required: true,
secret: true,
env_key: "LUNCHFLOW_API_KEY",
description: "Your Lunch Flow API key for authentication"
field :base_url,
label: "Base URL",
required: false,
env_key: "LUNCHFLOW_BASE_URL",
default: "https://lunchflow.app/api/v1",
description: "Base URL for Lunch Flow API"
end
def provider_name
"lunchflow"
end
# Build a Lunch Flow provider instance with configured credentials
# Build a Lunch Flow provider instance with family-specific credentials
# Lunchflow is now fully per-family - no global credentials supported
# @param family [Family] The family to get credentials for (required)
# @return [Provider::Lunchflow, nil] Returns nil if API key is not configured
def self.build_provider
api_key = config_value(:api_key)
return nil unless api_key.present?
def self.build_provider(family: nil)
return nil unless family.present?
base_url = config_value(:base_url).presence || "https://lunchflow.app/api/v1"
Provider::Lunchflow.new(api_key, base_url: base_url)
end
# Get family-specific credentials
lunchflow_item = family.lunchflow_items.where.not(api_key: nil).first
return nil unless lunchflow_item&.credentials_configured?
# Reload Lunchflow configuration when settings are updated
def self.reload_configuration
# Lunch Flow doesn't need to configure Rails.application.config like Plaid does
# The configuration is read dynamically via config_value(:api_key) and config_value(:base_url)
# This method exists to be called by the settings controller after updates
# No action needed here since values are fetched on-demand
Provider::Lunchflow.new(
lunchflow_item.api_key,
base_url: lunchflow_item.effective_base_url
)
end
def sync_path

View File

@@ -1,27 +1,10 @@
class Provider::SimplefinAdapter < Provider::Base
include Provider::Syncable
include Provider::InstitutionMetadata
include Provider::Configurable
# Register this adapter with the factory
Provider::Factory.register("SimplefinAccount", self)
# Configuration for SimpleFIN
configure do
description <<~DESC
Setup instructions:
1. Visit [SimpleFIN Bridge](https://bridge.simplefin.org/simplefin/create) to get a setup token
2. This token is optional and only needed if you want to provide a default setup token for users
DESC
field :setup_token,
label: "Setup Token",
required: false,
secret: true,
env_key: "SIMPLEFIN_SETUP_TOKEN",
description: "Optional: SimpleFIN setup token from your SimpleFIN Bridge account (one-time use)"
end
def provider_name
"simplefin"
end