class YodleeWrap::Response

Attributes

body[RW]
error_code[RW]
error_message[RW]
status[RW]

Public Class Methods

new(body, status) click to toggle source
# File lib/yodlee_wrap/response.rb, line 5
def initialize(body, status)
  @body = body
  @status = status
  @error_code = body.fetch('errorCode') if fail?
  @error_message = body.fetch('errorMessage') if fail?
end

Public Instance Methods

add_failed?() click to toggle source
# File lib/yodlee_wrap/response.rb, line 57
def add_failed?
  return false unless body['providerAccount']
  refresh_status == 'FAILED'
end
add_in_progress?() click to toggle source
# File lib/yodlee_wrap/response.rb, line 42
def add_in_progress?
  return false unless body['providerAccount']
  refresh_status == 'IN_PROGRESS' && additional_status == 'USER_INPUT_REQUIRED'
end
add_successful?() click to toggle source
# File lib/yodlee_wrap/response.rb, line 52
def add_successful?
  return false unless body['providerAccount']
  ['SUCCESS', 'PARTIAL_SUCCESS'].include? refresh_status
end
additional_status() click to toggle source
# File lib/yodlee_wrap/response.rb, line 37
def additional_status
  return nil unless body['providerAccount']
  body['providerAccount']['refreshInfo']['additionalStatus']
end
fail?() click to toggle source
# File lib/yodlee_wrap/response.rb, line 16
def fail?
  body.is_a?(Hash) && !(body.fetch('errorCode', nil)).nil?
end
mfa?() click to toggle source

Determine if the PROVIDER has mfa

# File lib/yodlee_wrap/response.rb, line 21
def mfa?
  if body.is_a?(Hash) && body['provider'] && body['provider'].length == 1
    body['provider'].first['mfaType'].present?
  end
end
mfa_available?() click to toggle source
# File lib/yodlee_wrap/response.rb, line 47
def mfa_available?
  return false unless body['providerAccount']
  body['providerAccount']['loginForm'] && body['providerAccount']['loginForm']['formType'] != 'login'
end
mfa_type() click to toggle source
# File lib/yodlee_wrap/response.rb, line 27
def mfa_type
  return nil unless body['provider']
  body['provider'].first['mfaType'] if mfa?
end
provider_account_id() click to toggle source
# File lib/yodlee_wrap/response.rb, line 62
def provider_account_id
  return nil unless body['providerAccount']
  body['providerAccount']['id']
end
refresh_status() click to toggle source
# File lib/yodlee_wrap/response.rb, line 32
def refresh_status
  return nil unless body['providerAccount']
  body['providerAccount']['refreshInfo']['status']
end
success?() click to toggle source
# File lib/yodlee_wrap/response.rb, line 12
def success?
  !fail?
end