plaid 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/plaid/call.rb +47 -42
  3. data/lib/plaid/customer.rb +26 -60
  4. metadata +16 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14a32a8d16bcdbeee7125f3dc2c0026c40570ae2
4
- data.tar.gz: c0adfe0c406e9c2c3f1a6148add5e87d72c0bdc6
3
+ metadata.gz: e809fa56df8552695b93076d9d4e657301214dce
4
+ data.tar.gz: 599f6ceeb4e92f61fe31a93e28babac8726a067d
5
5
  SHA512:
6
- metadata.gz: c94ab43042bf39ceb5b88dccaf8188ad3281dd2549e44ccb2071e9af8007f0ea128a60c8602e6551bfe5ef5d72790729cfc2360ba1a9d6e5eb1e09efe5edff16
7
- data.tar.gz: d3dab156da6a6fc84c992ae4b1dbb7844b8b24e9f5743a04ce6a374298e50bea6b83422f3d18790850d7360eec0ebf66bbb87a83effa069b4914e92d225cd1a8
6
+ metadata.gz: 491571f86e7ff9f2bd61e0cc58e4088a79dcc92a118c69686863296882dfe5c5f0d3a3d57e477d4c48cc1e76d049e5a0571aafac08ab8f2129cfebda35373468
7
+ data.tar.gz: 50d6b0fabe1074af7a13590b038192d29bcef0846e4717f305fbaa6077a7382811c7fdf76e101aa0f6b717c7a43efd56cded725cac97604d4e2e4d6de1f21bdc
data/lib/plaid/call.rb CHANGED
@@ -10,68 +10,73 @@ module Plaid
10
10
  end
11
11
  end
12
12
 
13
- def add_account(type,username,password,email)
14
- post('/connect',type,username,password,email)
15
- return parse_response(@response)
13
+ # This is a specific route for auth,
14
+ # it returns specific acct info
15
+ def add_account_auth(type, username, password, email)
16
+ parse_auth_response(post('/auth', type, username, password, email))
17
+ end
18
+
19
+ # This is a specific route for connect,
20
+ # it returns transaction information
21
+ def add_account_connect(type,username,password,email,options={})
22
+ parse_connect_response(post('/connect',type,username,password,email,options))
16
23
  end
17
24
 
18
25
  def get_place(id)
19
- get('/entity',id)
20
- return parse_place(@response)
26
+ parse_place(get('entities/',id))
27
+ end
28
+
29
+ def get_institutions
30
+ JSON.parse(get('/institutions'))
21
31
  end
32
+
22
33
  protected
23
34
 
24
- def parse_response(response)
35
+ # Specific parser for auth response
36
+ def parse_auth_response(response)
37
+ parsed = JSON.parse(response)
38
+ case response.code
39
+ when 200
40
+ {code: response.code, access_token: parsed['access_token'], accounts: parsed['accounts']}
41
+ when 201
42
+ {code: response.code, type: parsed['type'], access_token: parsed['access_token'], mfa: parsed['mfa']}
43
+ else
44
+ {code: response.code, message: parsed}
45
+ end
46
+ end
47
+
48
+ def parse_connect_response(response)
49
+ parsed = JSON.parse(response)
25
50
  case response.code
26
51
  when 200
27
- @parsed_response = Hash.new
28
- @parsed_response[:code] = response.code
29
- response = JSON.parse(response)
30
- @parsed_response[:access_token] = response["access_token"]
31
- @parsed_response[:accounts] = response["accounts"]
32
- @parsed_response[:transactions] = response["transactions"]
33
- return @parsed_response
34
- when 201
35
- @parsed_response = Hash.new
36
- @parsed_response[:code] = response.code
37
- response = JSON.parse(response)
38
- @parsed_response = Hash.new
39
- @parsed_response[:type] = response["type"]
40
- @parsed_response[:access_token] = response["access_token"]
41
- @parsed_response[:mfa_info] = response["mfa_info"]
42
- return @parsed_response
52
+ {code: response.code, access_token: parsed['access_token'], accounts: parsed['accounts'], transactions: parsed['transactions']}
53
+ when 201
54
+ {code: response.code, type: parsed['type'], access_token: parsed['access_token'], mfa: parsed['mfa']}
43
55
  else
44
- @parsed_response = Hash.new
45
- @parsed_response[:code] = response.code
46
- @parsed_response[:message] = response
47
- return @parsed_response
56
+ {code: response.code, message: parsed}
48
57
  end
49
58
  end
50
59
 
51
60
  def parse_place(response)
52
- @parsed_response = Hash.new
53
- @parsed_response[:code] = response.code
54
- response = JSON.parse(response)["entity"]
55
- @parsed_response[:category] = response["category"]
56
- @parsed_response[:name] = response["name"]
57
- @parsed_response[:id] = response["_id"]
58
- @parsed_response[:phone] = response["meta"]["contact"]["telephone"]
59
- @parsed_response[:location] = response["meta"]["location"]
60
- return @parsed_response
61
+ parsed = JSON.parse(response)
62
+ {code: response.code, category: parsed['category'], name: parsed['name'], id: parsed['_id'], phone: parsed['meta']['contact']['telephone'], location: parsed['meta']['location']}
63
+ end
64
+
65
+ def parse_institutions(response)
66
+ parsed = JSON.parse(response)
67
+ {code: response.code, institutions: parsed}
61
68
  end
62
69
 
63
70
  private
64
71
 
65
- def post(path,type,username,password,email)
72
+ def post(path,type,username,password,email,options={})
66
73
  url = BASE_URL + path
67
- @response = RestClient.post url, :client_id => self.instance_variable_get(:'@customer_id') ,:secret => self.instance_variable_get(:'@secret'), :type => type ,:credentials => {:username => username, :password => password} ,:email => email
68
- return @response
74
+ RestClient.post url, client_id: self.instance_variable_get(:'@customer_id') ,secret: self.instance_variable_get(:'@secret'), type: type ,credentials: {username: username, password: password} ,email: email, options: options
69
75
  end
70
76
 
71
- def get(path,id)
72
- url = BASE_URL + path
73
- @response = RestClient.get(url,:params => {:entity_id => id})
74
- return @response
77
+ def get(path,id = nil)
78
+ url = BASE_URL + path + id.to_s
79
+ RestClient.get(url)
75
80
  end
76
81
 
77
82
  end
@@ -12,91 +12,57 @@ module Plaid
12
12
  end
13
13
  end
14
14
 
15
- def mfa_step(access_token,code)
16
- @mfa = code
17
- post("/connect/step", access_token, mfa: @mfa)
18
- return parse_response(@response,1)
15
+ def mfa_auth_step(access_token, code, type)
16
+ parse_response(post('/auth/step', access_token, mfa: code, type: type), 0)
17
+ end
18
+
19
+ def mfa_connect_step(access_token,code)
20
+ parse_response(post('/connect/step', access_token, mfa: code),1)
19
21
  end
20
22
 
21
23
  def get_transactions(access_token)
22
- get('/connect', access_token)
23
- return parse_response(@response,2)
24
+ parse_response(get('/connect', access_token),2)
24
25
  end
25
26
 
26
27
  def delete_account(access_token)
27
- delete('/connect', access_token)
28
- return parse_response(@response,3)
28
+ parse_response(delete('/connect', access_token),3)
29
29
  end
30
30
 
31
31
  protected
32
32
 
33
33
  def parse_response(response,method)
34
- case method
35
- when 1
36
- case response.code
37
- when 200
38
- @parsed_response = Hash.new
39
- @parsed_response[:code] = response.code
40
- response = JSON.parse(response)
41
- @parsed_response[:access_token] = response["access_token"]
42
- @parsed_response[:accounts] = response["accounts"]
43
- @parsed_response[:transactions] = response["transactions"]
44
- return @parsed_response
45
- else
46
- @parsed_response = Hash.new
47
- @parsed_response[:code] = response.code
48
- @parsed_response[:message] = response
49
- return @parsed_response
50
- end
51
- when 2
52
- case response.code
53
- when 200
54
- @parsed_response = Hash.new
55
- @parsed_response[:code] = response.code
56
- response = JSON.parse(response)
57
- @parsed_response[:transactions] = response["transactions"]
58
- return @parsed_response
59
- else
60
- @parsed_response = Hash.new
61
- @parsed_response[:code] = response.code
62
- @parsed_response[:message] = response
63
- return @parsed_response
64
- end
65
- when 3
66
- case response.code
67
- when 200
68
- @parsed_response = Hash.new
69
- @parsed_response[:code] = response.code
70
- response = JSON.parse(response)
71
- @parsed_response[:message] = response
72
- return @parsed_response
34
+ parsed = JSON.parse(response)
35
+ if response.code == '200'
36
+ case method
37
+ when 0
38
+ {code: response.code, access_token: parsed['access_token'], accounts: parsed['accounts']}
39
+ when 1
40
+ {code: response.code, access_token: parsed['access_token'], accounts: parsed['accounts'], transactions: parsed['transactions']}
41
+ when 2
42
+ {code: response.code, transactions: parsed['transactions']}
73
43
  else
74
- @parsed_response = Hash.new
75
- @parsed_response[:code] = response.code
76
- @parsed_response[:message] = response
77
- return @parsed_response
44
+ {code: response.code, message: parsed}
78
45
  end
46
+ else
47
+ {code: response.code, message: parsed}
79
48
  end
80
49
  end
81
50
 
82
51
  private
83
52
 
84
- def get(path,access_token,options={})
53
+ def get(path,access_token)
85
54
  url = BASE_URL + path
86
- @response = RestClient.get(url,:params => {:client_id => self.instance_variable_get(:'@customer_id'), :secret => self.instance_variable_get(:'@secret'), :access_token => access_token})
87
- return @response
55
+ RestClient.get(url, params: {client_id: self.instance_variable_get(:'@customer_id'), secret: self.instance_variable_get(:'@secret'), access_token: access_token})
88
56
  end
89
57
 
90
58
  def post(path,access_token,options={})
91
59
  url = BASE_URL + path
92
- @response = RestClient.post url, :client_id => self.instance_variable_get(:'@customer_id') ,:secret => self.instance_variable_get(:'@secret'), :access_token => access_token, :mfa => @mfa
93
- return @response
60
+ RestClient.post url, client_id: self.instance_variable_get(:'@customer_id'), secret: self.instance_variable_get(:'@secret'), access_token: access_token, mfa: options[:mfa], type: options[:type]
94
61
  end
95
62
 
96
- def delete(path,access_token,options={})
63
+ def delete(path,access_token)
97
64
  url = BASE_URL + path
98
- @response = RestClient.delete(url,:params => {:client_id => self.instance_variable_get(:'@customer_id'), :secret => self.instance_variable_get(:'@secret'), :access_token => access_token})
99
- return @response
65
+ RestClient.delete(url, params: {client_id: self.instance_variable_get(:'@customer_id'), secret: self.instance_variable_get(:'@secret'), access_token: access_token})
100
66
  end
101
67
  end
102
- end
68
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plaid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Crites
@@ -16,69 +16,69 @@ dependencies:
16
16
  name: rest-client
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - '>='
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - '>='
26
+ - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  version: '0'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: json
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - '>='
33
+ - - ">="
34
34
  - !ruby/object:Gem::Version
35
35
  version: '0'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - '>='
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: rake
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - '>='
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0'
50
50
  type: :development
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - '>='
54
+ - - ">="
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: rspec
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - '>='
61
+ - - ">="
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0'
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - '>='
68
+ - - ">="
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
- description: A simple to use ruby wrapper for Plaid.io API.
71
+ description: Ruby Gem wrapper for Plaid API.
72
72
  email: justin@guavatext.com
73
73
  executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - lib/plaid.rb
78
- - lib/plaid/config.rb
79
78
  - lib/plaid/call.rb
79
+ - lib/plaid/config.rb
80
80
  - lib/plaid/customer.rb
81
- homepage: https://github.com/j4ustin/plaid
81
+ homepage: https://github.com/plaid/plaid-ruby
82
82
  licenses:
83
83
  - MIT
84
84
  metadata: {}
@@ -88,18 +88,18 @@ require_paths:
88
88
  - lib
89
89
  required_ruby_version: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - '>='
91
+ - - ">="
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - '>='
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.0.3
101
+ rubygems_version: 2.2.2
102
102
  signing_key:
103
103
  specification_version: 4
104
- summary: Plaid.io api gem
104
+ summary: Plaid Ruby Gem
105
105
  test_files: []