class PlaidResponse

Attributes

access_token[R]
accounts[R]
http_code[R]
mfa_message[R]
transactions[R]

Public Class Methods

new(response, message=nil) click to toggle source
# File lib/plaid/plaid_response.rb, line 17
def initialize(response, message=nil)
  @http_code = response.code
  zed = PlaidObject.new(response)

  if save_full_response.eql?(true)
    @response = zed
  end

  unless message.eql?("MFA")
    @accounts = zed.accounts if zed.class.method_defined? :accounts
    @transactions = zed.transactions if zed.class.method_defined? :transactions
    @is_mfa_initialized = false
  else
    manage_mfa_type(zed)
    @is_mfa_initialized = true
  end

  @access_token = zed.access_token
  @message = message if message
  zed = nil
end

Public Instance Methods

is_mfa?() click to toggle source
# File lib/plaid/plaid_response.rb, line 51
def is_mfa?
  @is_mfa_initialized
end
manage_mfa_type(zed) click to toggle source
# File lib/plaid/plaid_response.rb, line 59
def manage_mfa_type(zed)
  @mfa_type = zed.type

  if @mfa_type.eql?("device")
    @mfa_message = zed.mfa["message"]
  elsif @mfa_type.eql?("questions")
    @questions ||= []
    zed.mfa.each do |q|
      @questions << q.question
    end
    @mfa_message = @questions.reverse.pop
  elsif @mfa_type.eql?("list")
    @mfa_modes ||= []
    @mfa_message = "There are several ways to authenticate, or it will default to your email"
    zed.mfa.each do |q|
      @mfa_modes << q
    end
  end

end
message() click to toggle source
# File lib/plaid/plaid_response.rb, line 43
def message
  @message.eql?("MFA") ? @message + ": " + @mfa_message : @message
end
mfa_modes() click to toggle source
# File lib/plaid/plaid_response.rb, line 55
def mfa_modes
  @mfa_modes
end
mfa_type() click to toggle source
# File lib/plaid/plaid_response.rb, line 47
def mfa_type
  @message.eql?("MFA") ? @mfa_type : "Not a response from an MFA request to a bank"
end
raw_response() click to toggle source
# File lib/plaid/plaid_response.rb, line 39
def raw_response
  @response
end