Class: PlaidRails::LinkController

Inherits:
ApplicationController show all
Defined in:
app/controllers/plaid_rails/link_controller.rb

Instance Method Summary collapse

Instance Method Details

#authenticateObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/plaid_rails/link_controller.rb', line 6

def authenticate
  begin
    @exchange_token = Plaid.exchange_token(link_params[:public_token])

    @params = link_params.merge!(token: link_params[:public_token])
    
  rescue => e
    Rails.logger.error "Error: #{e}"
    Rails.logger.error e.backtrace.join("\n")
    render text: e.message, status: 500
  end
end

#updateObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/plaid_rails/link_controller.rb', line 19

def update
  begin
    exchange_token = Plaid.exchange_token(link_params[:public_token])

    @accounts =PlaidRails::.where(owner_type: link_params[:owner_type],
    owner_id: link_params[:owner_id])
    @accounts.each do ||
      .update(access_token: exchange_token.access_token)
    end
    flash[:success]="You have successfully updated your account(s)"
  rescue => e
    Rails.logger.error "Error: #{e}"
    Rails.logger.error e.backtrace.join("\n")
    render text: e.message, status: 500
  end
end