Class: YodleeWrap::Response
- Inherits:
-
Object
- Object
- YodleeWrap::Response
- Defined in:
- lib/yodlee_wrap/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#error_code ⇒ Object
Returns the value of attribute error_code.
-
#error_message ⇒ Object
Returns the value of attribute error_message.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #add_failed? ⇒ Boolean
- #add_in_progress? ⇒ Boolean
- #add_successful? ⇒ Boolean
- #additional_status ⇒ Object
- #fail? ⇒ Boolean
-
#initialize(body, status) ⇒ Response
constructor
A new instance of Response.
-
#mfa? ⇒ Boolean
Determine if the PROVIDER has mfa.
- #mfa_available? ⇒ Boolean
- #mfa_type ⇒ Object
- #provider_account_id ⇒ Object
- #refresh_status ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(body, status) ⇒ Response
Returns a new instance of Response.
5 6 7 8 9 10 |
# 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 |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
3 4 5 |
# File 'lib/yodlee_wrap/response.rb', line 3 def body @body end |
#error_code ⇒ Object
Returns the value of attribute error_code.
3 4 5 |
# File 'lib/yodlee_wrap/response.rb', line 3 def error_code @error_code end |
#error_message ⇒ Object
Returns the value of attribute error_message.
3 4 5 |
# File 'lib/yodlee_wrap/response.rb', line 3 def @error_message end |
#status ⇒ Object
Returns the value of attribute status.
3 4 5 |
# File 'lib/yodlee_wrap/response.rb', line 3 def status @status end |
Instance Method Details
#add_failed? ⇒ Boolean
57 58 59 60 |
# File 'lib/yodlee_wrap/response.rb', line 57 def add_failed? return false unless body['providerAccount'] refresh_status == 'FAILED' end |
#add_in_progress? ⇒ Boolean
42 43 44 45 |
# 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? ⇒ Boolean
52 53 54 55 |
# 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 ⇒ Object
37 38 39 40 |
# File 'lib/yodlee_wrap/response.rb', line 37 def additional_status return nil unless body['providerAccount'] body['providerAccount']['refreshInfo']['additionalStatus'] end |
#fail? ⇒ Boolean
16 17 18 |
# File 'lib/yodlee_wrap/response.rb', line 16 def fail? body.is_a?(Hash) && !(body.fetch('errorCode', nil)).nil? end |
#mfa? ⇒ Boolean
Determine if the PROVIDER has mfa
21 22 23 24 25 |
# 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? ⇒ Boolean
47 48 49 50 |
# 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 ⇒ Object
27 28 29 30 |
# 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 ⇒ Object
62 63 64 65 |
# File 'lib/yodlee_wrap/response.rb', line 62 def provider_account_id return nil unless body['providerAccount'] body['providerAccount']['id'] end |
#refresh_status ⇒ Object
32 33 34 35 |
# File 'lib/yodlee_wrap/response.rb', line 32 def refresh_status return nil unless body['providerAccount'] body['providerAccount']['refreshInfo']['status'] end |
#success? ⇒ Boolean
12 13 14 |
# File 'lib/yodlee_wrap/response.rb', line 12 def success? !fail? end |