Class: Plaid::Client::Base
- Inherits:
-
Object
- Object
- Plaid::Client::Base
- Includes:
- HTTParty, Bodies, Configurations, Logins
- Defined in:
- lib/plaid/client/client.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#email ⇒ Object
Returns the value of attribute email.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#institution ⇒ Object
Returns the value of attribute institution.
-
#is_mfa_initialized ⇒ Object
Returns the value of attribute is_mfa_initialized.
-
#mfa_message ⇒ Object
Returns the value of attribute mfa_message.
-
#mfa_response ⇒ Object
Returns the value of attribute mfa_response.
-
#mfa_type ⇒ Object
Returns the value of attribute mfa_type.
-
#password ⇒ Object
Returns the value of attribute password.
-
#secret ⇒ Object
Returns the value of attribute secret.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#handle(response) ⇒ Object
generic method for handling the structure of the response.
-
#initialize(user, e_mail, pass_word, institution, access_token = nil) ⇒ Base
constructor
A new instance of Base.
- #is_mfa? ⇒ Boolean
- #plaid_response_codes ⇒ Object
-
#secrets(client_id, secret) ⇒ Object
for testing through IRB.
- #settings ⇒ Object
Methods included from Bodies
#body, #body_delete_user, #body_entity, #body_init_user, #body_mfa, #body_mfa_mode, #body_mfa_webhook, #body_original, #body_retrieve, #body_test, #body_update_credentials, #credentials, #options
Methods included from Logins
#connect, #connect_delete_user, #connect_filter_response, #connect_init_user, #connect_step, #connect_step_specify_mode, #connect_step_webhook, #connect_update_credentials
Constructor Details
#initialize(user, e_mail, pass_word, institution, access_token = nil) ⇒ Base
Returns a new instance of Base.
25 26 27 28 29 30 31 32 |
# File 'lib/plaid/client/client.rb', line 25 def initialize(user, e_mail, pass_word, institution, access_token=nil) self.username = user self.email = e_mail self.password = pass_word self.institution = institution self.access_token = access_token unless access_token.blank? self.mfa_response ||= [] end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/plaid/client/client.rb', line 5 def access_token @access_token end |
#email ⇒ Object
Returns the value of attribute email.
5 6 7 |
# File 'lib/plaid/client/client.rb', line 5 def email @email end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
5 6 7 |
# File 'lib/plaid/client/client.rb', line 5 def endpoint @endpoint end |
#institution ⇒ Object
Returns the value of attribute institution.
5 6 7 |
# File 'lib/plaid/client/client.rb', line 5 def institution @institution end |
#is_mfa_initialized ⇒ Object
Returns the value of attribute is_mfa_initialized.
5 6 7 |
# File 'lib/plaid/client/client.rb', line 5 def is_mfa_initialized @is_mfa_initialized end |
#mfa_message ⇒ Object
Returns the value of attribute mfa_message.
5 6 7 |
# File 'lib/plaid/client/client.rb', line 5 def @mfa_message end |
#mfa_response ⇒ Object
Returns the value of attribute mfa_response.
5 6 7 |
# File 'lib/plaid/client/client.rb', line 5 def mfa_response @mfa_response end |
#mfa_type ⇒ Object
Returns the value of attribute mfa_type.
5 6 7 |
# File 'lib/plaid/client/client.rb', line 5 def mfa_type @mfa_type end |
#password ⇒ Object
Returns the value of attribute password.
5 6 7 |
# File 'lib/plaid/client/client.rb', line 5 def password @password end |
#secret ⇒ Object
Returns the value of attribute secret.
5 6 7 |
# File 'lib/plaid/client/client.rb', line 5 def secret @secret end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/plaid/client/client.rb', line 5 def username @username end |
Instance Method Details
#handle(response) ⇒ Object
generic method for handling the structure of the response. Only creates an error object if there is an error (business error) from Plaid.com. Yields to the block with calling function
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/plaid/client/client.rb', line 45 def handle(response) if response.code.eql? 200 self.mfa_type = nil self. = nil self.is_mfa_initialized = false yield(response) if block_given? elsif response.code.eql? 201 #mfa mfa_201 = PlaidResponse.new(response, "MFA") self.access_token = mfa_201.access_token self.mfa_type = mfa_201.raw_response.type self.mfa_response << mfa_201 self. = mfa_201. self.is_mfa_initialized = mfa_201.is_mfa? mfa_201 else PlaidError.new(response, "Error") end end |
#is_mfa? ⇒ Boolean
71 72 73 |
# File 'lib/plaid/client/client.rb', line 71 def is_mfa? @is_mfa_initialized end |
#plaid_response_codes ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/plaid/client/client.rb', line 75 def plaid_response_codes { 200 => "Success", 201 => "MFA Required", 400 => "Bad Request", 401 => "Unauthorized", 402 => "Request Failed", 404 => "Cannot be Found", 500 => "Server Error" } end |
#secrets(client_id, secret) ⇒ Object
for testing through IRB
65 66 67 68 69 |
# File 'lib/plaid/client/client.rb', line 65 def secrets(client_id, secret) self.client_id = client_id self.secret = secret "Set" end |
#settings ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/plaid/client/client.rb', line 34 def settings puts "Base URI: " + endpoint.to_s puts "Cert: " + certpath.to_s puts "User: " + self.username.to_s puts "Email: " + self.email.to_s puts "Plaid Client_id: " + self.client_id.to_s puts "Webhook address: " + webhook_address puts "Save full response: " + save_full_response.to_s end |