mirror of
https://github.com/we-promise/sure.git
synced 2026-04-14 01:24:06 +00:00
* Add support for dynamic config UI
* Add support for section description
* Better dynamic class settings
Added dynamic_fields hash field - Stores all undeclared settings
[] method - Checks declared fields first, then falls back to dynamic hash
[]= method - Updates declared fields normally, stores others in hash
No runtime field declaration - Fields are never dynamically created on the class
* FIX proper lookup for provider keys
- Also validate configurable values properly.
- Change Provider factory to use Rails autoloading (Zeitwerk)
* Fix factory
The derive_adapter_name method relies on string manipulation ("PlaidAccount".sub(/Account$/, "") + "Adapter" → "PlaidAdapter"), but we already have explicit registration in place.
* Make updates atomic, field-aware, and handle blanks explicitly
* Small UX detail
* Add support for PlaidEU in UI also
- This looks like partial support atm
62 lines
2.4 KiB
Ruby
62 lines
2.4 KiB
Ruby
# PlaidEuAdapter is a configuration-only manager for Plaid EU credentials.
|
|
#
|
|
# It does NOT register as a provider type because:
|
|
# - There's no separate "PlaidEuAccount" model
|
|
# - All PlaidAccounts (regardless of region) use PlaidAdapter as their instance adapter
|
|
#
|
|
# This class only manages Rails.application.config.plaid_eu, which
|
|
# Provider::Registry.plaid_provider_for_region(:eu) uses to create Provider::Plaid instances.
|
|
#
|
|
# This separation into a distinct adapter class provides:
|
|
# - Clear UI separation: "Plaid" vs "Plaid Eu" sections in settings
|
|
# - Better UX: Users only configure the region they need
|
|
class Provider::PlaidEuAdapter
|
|
include Provider::Configurable
|
|
|
|
# Configuration for Plaid EU
|
|
configure do
|
|
description <<~DESC
|
|
Setup instructions:
|
|
1. Visit the [Plaid Dashboard](https://dashboard.plaid.com/team/keys) to get your API credentials
|
|
2. Your Client ID and Secret Key are required to enable Plaid bank sync for European banks
|
|
3. For production use, set environment to 'production', for testing use 'sandbox'
|
|
DESC
|
|
|
|
field :client_id,
|
|
label: "Client ID",
|
|
required: false,
|
|
env_key: "PLAID_EU_CLIENT_ID",
|
|
description: "Your Plaid Client ID from the Plaid Dashboard for EU region"
|
|
|
|
field :secret,
|
|
label: "Secret Key",
|
|
required: false,
|
|
secret: true,
|
|
env_key: "PLAID_EU_SECRET",
|
|
description: "Your Plaid Secret from the Plaid Dashboard for EU region"
|
|
|
|
field :environment,
|
|
label: "Environment",
|
|
required: false,
|
|
env_key: "PLAID_EU_ENV",
|
|
default: "sandbox",
|
|
description: "Plaid environment: sandbox, development, or production"
|
|
end
|
|
|
|
# Reload Plaid EU configuration when settings are updated
|
|
def self.reload_configuration
|
|
client_id = config_value(:client_id).presence || ENV["PLAID_EU_CLIENT_ID"]
|
|
secret = config_value(:secret).presence || ENV["PLAID_EU_SECRET"]
|
|
environment = config_value(:environment).presence || ENV["PLAID_EU_ENV"] || "sandbox"
|
|
|
|
if client_id.present? && secret.present?
|
|
Rails.application.config.plaid_eu = Plaid::Configuration.new
|
|
Rails.application.config.plaid_eu.server_index = Plaid::Configuration::Environment[environment]
|
|
Rails.application.config.plaid_eu.api_key["PLAID-CLIENT-ID"] = client_id
|
|
Rails.application.config.plaid_eu.api_key["PLAID-SECRET"] = secret
|
|
else
|
|
Rails.application.config.plaid_eu = nil
|
|
end
|
|
end
|
|
end
|