Class: Plaider::Client
- Inherits:
-
Object
- Object
- Plaider::Client
- Defined in:
- lib/plaider/client.rb
Constant Summary collapse
- BASE_URL =
'https://tartan.plaid.com'- DATE_FORMAT =
'%Y-%m-%d'- OPEN_TIMEOUT =
15- READ_TIMEOUT =
120
Instance Method Summary collapse
- #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.
14 15 16 17 18 19 20 21 |
# File 'lib/plaider/client.rb', line 14 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
#add_user(institution_type, username, password, email) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/plaider/client.rb', line 50 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}) status_code = response[:status_code].to_i @access_token = response[:result][:access_token] if [200, 201].include?(status_code) response end |
#balance ⇒ Object
46 47 48 |
# File 'lib/plaider/client.rb', line 46 def balance post('/balance') end |
#categories ⇒ Object
32 33 34 |
# File 'lib/plaider/client.rb', line 32 def categories get('/categories') end |
#category(category_id) ⇒ Object
36 37 38 39 |
# File 'lib/plaider/client.rb', line 36 def category(category_id) validate(category_id: category_id) get("/categories/#{category_id}") end |
#delete_user ⇒ Object
77 78 79 80 81 |
# File 'lib/plaider/client.rb', line 77 def delete_user response = delete('/connect') @access_token = nil response end |
#entity(entity_id) ⇒ Object
41 42 43 44 |
# File 'lib/plaider/client.rb', line 41 def entity(entity_id) validate(entity_id: entity_id) get("/entities/#{entity_id}") end |
#institution(institution_id) ⇒ Object
27 28 29 30 |
# File 'lib/plaider/client.rb', line 27 def institution(institution_id) validate(institution_id: institution_id) get("/institutions/#{institution_id}") end |
#institutions ⇒ Object
23 24 25 |
# File 'lib/plaider/client.rb', line 23 def institutions get('/institutions') end |
#transactions(account_id = nil, start_date = nil, end_date = nil, pending = false) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/plaider/client.rb', line 63 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] = account_id if pending post('/connect/get', params) end |
#update_user(username, password) ⇒ Object
72 73 74 75 |
# File 'lib/plaider/client.rb', line 72 def update_user(username, password) validate(username: username, password: password) patch('/connect', {username: username, password: password}) end |
#user_confirmation(mfa) ⇒ Object
58 59 60 61 |
# File 'lib/plaider/client.rb', line 58 def user_confirmation(mfa) validate(mfa: mfa) post('/connect/step', {mfa: mfa}) end |