Sha256: bbbf745cdce6a9660eaeb9ff98c8dfff55f83bd4142ae119dba6f3e1311e790f
Contents?: true
Size: 1.31 KB
Versions: 5
Compression:
Stored size: 1.31 KB
Contents
module PlaidRails class CreateAccountService # creates a new plaid_rails_account for each account the user has selected def self.call(account_params) account_params["account_ids"].each do |id| # set Plaid::User user = Plaid::User.load(:connect, account_params["access_token"]) # get all the info, make plaid /connect/get call user.transactions #find the account by account_id account = user.accounts.find{|a| a.id==id} PlaidRails::Account.create!( access_token: account_params["access_token"], token: account_params["token"], plaid_type: account_params["type"], name: account.name, bank_name: Plaid::Institution.get(account_params["type"]).name, number: account.meta["number"], owner_id: account_params["owner_id"], owner_type: account_params["owner_type"], available_balance: account.available_balance, current_balance: account.current_balance, transactions_start_date: account_params["transactions_start_date"], plaid_id: id ) unless PlaidRails::Account.exists?(plaid_id: id) end PlaidRails::Account.where(owner_id: account_params["owner_id"], owner_type: account_params["owner_type"]) end end end
Version data entries
5 entries across 5 versions & 1 rubygems