Class: Plaider::Client
- Inherits:
-
Object
- Object
- Plaider::Client
- Defined in:
- lib/plaider/client.rb
Constant Summary collapse
- DEV_BASE_URL =
'https://tartan.plaid.com'- PROD_BASE_URL =
'https://api.plaid.com'- DATE_FORMAT =
'%Y-%m-%d'- OPEN_TIMEOUT =
15- READ_TIMEOUT =
120
Instance Method Summary collapse
- #access_token ⇒ Object
- #add_user(institution_type, username, password, email) ⇒ Object
- #balance ⇒ Object
- #categories ⇒ Object
- #category(category_id) ⇒ Object
- #delete_user ⇒ Object
- #entity(entity_id) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #institution(institution_id) ⇒ Object
- #institutions ⇒ Object
- #transactions(account_id = nil, start_date = nil, end_date = nil, pending = false) ⇒ Object
- #update_user(username, password) ⇒ Object
- #user_confirmation(mfa) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 21 22 |
# File 'lib/plaider/client.rb', line 15 def initialize(={}) [:open_timeout] ||= OPEN_TIMEOUT [:read_timeout] ||= READ_TIMEOUT [:verbose] ||= false Plaider::Configurable::KEYS.each do |key| instance_variable_set(:"@#{key}", ![key].nil? ? [key] : Plaider.instance_variable_get(:"@#{key}")) end end |
Instance Method Details
#access_token ⇒ Object
84 85 86 |
# File 'lib/plaider/client.rb', line 84 def access_token @access_token end |
#add_user(institution_type, username, password, email) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/plaider/client.rb', line 51 def add_user(institution_type, username, password, email) validate(institution_type: institution_type, username: username, password: password, email: email) response = post('/connect', {type: institution_type, username: username, password: password, email: email, login_only: true}) status_code = response[:status_code].to_i @access_token = response[:result][:access_token] if [200, 201].include?(status_code) response end |
#balance ⇒ Object
47 48 49 |
# File 'lib/plaider/client.rb', line 47 def balance post('/balance') end |
#categories ⇒ Object
33 34 35 |
# File 'lib/plaider/client.rb', line 33 def categories get('/categories') end |
#category(category_id) ⇒ Object
37 38 39 40 |
# File 'lib/plaider/client.rb', line 37 def category(category_id) validate(category_id: category_id) get("/categories/#{category_id}") end |
#delete_user ⇒ Object
78 79 80 81 82 |
# File 'lib/plaider/client.rb', line 78 def delete_user response = delete('/connect') @access_token = nil response end |
#entity(entity_id) ⇒ Object
42 43 44 45 |
# File 'lib/plaider/client.rb', line 42 def entity(entity_id) validate(entity_id: entity_id) get("/entities/#{entity_id}") end |
#institution(institution_id) ⇒ Object
28 29 30 31 |
# File 'lib/plaider/client.rb', line 28 def institution(institution_id) validate(institution_id: institution_id) get("/institutions/#{institution_id}") end |
#institutions ⇒ Object
24 25 26 |
# File 'lib/plaider/client.rb', line 24 def institutions get('/institutions') end |
#transactions(account_id = nil, start_date = nil, end_date = nil, pending = false) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/plaider/client.rb', line 64 def transactions(account_id = nil, start_date = nil, end_date = nil, pending = false) params = {} params[:account_id] = account_id if account_id params[:gte] = format_date(start_date) params[:lte] = format_date(end_date) params[:pending] = pending post('/connect/get', params) end |
#update_user(username, password) ⇒ Object
73 74 75 76 |
# File 'lib/plaider/client.rb', line 73 def update_user(username, password) validate(username: username, password: password) patch('/connect', {username: username, password: password}) end |
#user_confirmation(mfa) ⇒ Object
59 60 61 62 |
# File 'lib/plaider/client.rb', line 59 def user_confirmation(mfa) validate(mfa: mfa) post('/connect/step', {mfa: mfa}) end |