mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 13:35:21 +02:00
Initial pass at Plaid EU (#1555)
* Initial pass at Plaid EU * Add EU support to Plaid Items * Lint * Temp fix for rubocop isseus * Merge cleanup * Pass in region and get tests passing * Use absolute path for translation --------- Signed-off-by: Josh Pigford <josh@joshpigford.com>
This commit is contained in:
parent
41873de11d
commit
4bf72506d5
15 changed files with 81 additions and 21 deletions
|
@ -1,6 +1,8 @@
|
|||
class PlaidItem < ApplicationRecord
|
||||
include Plaidable, Syncable
|
||||
|
||||
enum :plaid_region, { us: "us", eu: "eu" }
|
||||
|
||||
if Rails.application.credentials.active_record_encryption.present?
|
||||
encrypts :access_token, deterministic: true
|
||||
end
|
||||
|
@ -19,13 +21,14 @@ class PlaidItem < ApplicationRecord
|
|||
scope :ordered, -> { order(created_at: :desc) }
|
||||
|
||||
class << self
|
||||
def create_from_public_token(token, item_name:)
|
||||
def create_from_public_token(token, item_name:, region: "us")
|
||||
response = plaid_provider.exchange_public_token(token)
|
||||
|
||||
new_plaid_item = create!(
|
||||
name: item_name,
|
||||
plaid_id: response.item_id,
|
||||
access_token: response.access_token,
|
||||
plaid_region: region
|
||||
)
|
||||
|
||||
new_plaid_item.sync_later
|
||||
|
@ -56,10 +59,11 @@ class PlaidItem < ApplicationRecord
|
|||
private
|
||||
def fetch_and_load_plaid_data
|
||||
data = {}
|
||||
item = plaid_provider.get_item(access_token).item
|
||||
provider = plaid_provider_for(self)
|
||||
item = provider.get_item(access_token).item
|
||||
update!(available_products: item.available_products, billed_products: item.billed_products)
|
||||
|
||||
fetched_accounts = plaid_provider.get_item_accounts(self).accounts
|
||||
fetched_accounts = provider.get_item_accounts(self).accounts
|
||||
data[:accounts] = fetched_accounts || []
|
||||
|
||||
internal_plaid_accounts = fetched_accounts.map do |account|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue