yodlee_wrap 0.0.0 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.gitignore +3 -1
- data/README.md +1 -1
- data/lib/yodlee_wrap/config.rb +1 -1
- data/lib/yodlee_wrap/response.rb +10 -0
- data/lib/yodlee_wrap/version.rb +1 -1
- data/lib/yodlee_wrap/yodlee_api.rb +41 -35
- data/lib/yodlee_wrap.rb +0 -1
- data/log/test.log +4580 -0
- data/spec/integration/integration_spec.rb +474 -345
- data/spec/spec_helper.rb +4 -6
- data/spec/unit/yodlee_wrap/config_spec.rb +34 -0
- data/spec/unit/yodlee_wrap/response_spec.rb +49 -0
- data/spec/unit/yodlee_wrap/yodlee_api_spec.rb +265 -0
- data/spec/unit/yodleeicious/config_spec.rb +15 -28
- metadata +9 -9
- data/lib/yodlee_wrap/parameter_translator.rb +0 -27
- data/spec/unit/yodleeicious/parameter_translator_spec.rb +0 -80
- data/spec/unit/yodleeicious/response_spec.rb +0 -61
- data/spec/unit/yodleeicious/yodlee_api_spec.rb +0 -341
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b7e7dfd497e0eec58ac5065a0dd0de3bed1159e
|
4
|
+
data.tar.gz: ac68234bc087d55669679ce679fd2600019f0fdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0502d857969e62ccd9505e1bf4c90b298aba07767e9e42cfe6e31401fa3e7eb73706027b33797fed1d7dec1a83e60981e4b4e0ae673c29d328d9e6283e3dbb00
|
7
|
+
data.tar.gz: cc38d429861db459ad74445bda3b8b58b5aa24beeec761cb318a1fc899b11641c0a74b270c9eb0232346e1116ca94e41bb60b6c4a01b05edfd4f66da046a8e2c
|
data/.DS_Store
CHANGED
Binary file
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -134,7 +134,7 @@ pry(main)> yodlee_api.user_session_token
|
|
134
134
|
### Login existing user
|
135
135
|
|
136
136
|
```
|
137
|
-
pry(main)> response = yodlee_api.
|
137
|
+
pry(main)> response = yodlee_api.login_user 'my-username', 'my-password123'
|
138
138
|
pry(main)> yodlee_api.user_session_token
|
139
139
|
=> "12162013_1:69761d51a4010e6382ccb49b854513dbccad0f835a873d37884b68826acefaa5b8d41b634f4cc83d97d86e7df861f70860a4e4d8a3f08d5b5440eae504af5f19"
|
140
140
|
```
|
data/lib/yodlee_wrap/config.rb
CHANGED
data/lib/yodlee_wrap/response.rb
CHANGED
@@ -16,5 +16,15 @@ module YodleeWrap
|
|
16
16
|
def fail?
|
17
17
|
body.is_a?(Hash) && !(body.fetch('errorCode', nil)).nil?
|
18
18
|
end
|
19
|
+
|
20
|
+
def mfa?
|
21
|
+
if body.is_a?(Hash) && body['provider'] && body['provider'].length == 1
|
22
|
+
body['provider'].first['mfaType']
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def mfa_type
|
27
|
+
body['provider'].first['mfaType'] if mfa?
|
28
|
+
end
|
19
29
|
end
|
20
30
|
end
|
data/lib/yodlee_wrap/version.rb
CHANGED
@@ -16,12 +16,11 @@ module YodleeWrap
|
|
16
16
|
@cobranded_password = config[:cobranded_password] || YodleeWrap::Config.cobranded_password
|
17
17
|
@webhook_endpoint = config[:webhook_endpoint] || YodleeWrap::Config.webhook_endpoint
|
18
18
|
@logger = config[:logger] || YodleeWrap::Config.logger
|
19
|
-
|
20
|
-
info_log "YodleeApi configured with base_url=#{base_url} cobranded_username=#{cobranded_username} logger=#{logger}"
|
19
|
+
info_log "YodleeApi configured with cobrand_name=#{cobrand_name} cobranded_username=#{cobranded_username} logger=#{logger}"
|
21
20
|
end
|
22
21
|
|
23
22
|
def validate(config)
|
24
|
-
[:cobranded_username, :cobranded_password, :logger].each do |key|
|
23
|
+
[:cobrand_name, :cobranded_username, :cobranded_password, :logger].each do |key|
|
25
24
|
if config.key?(key) && config[key].nil?
|
26
25
|
fail 'Invalid config provided to YodleeApi. Values may not be nil/blank.'
|
27
26
|
end
|
@@ -36,33 +35,34 @@ module YodleeWrap
|
|
36
35
|
locale: "en_US"
|
37
36
|
}
|
38
37
|
}
|
39
|
-
response = execute_api('/v1/cobrand/login', params)
|
38
|
+
response = execute_api(:post, '/v1/cobrand/login', params)
|
40
39
|
|
41
40
|
@cobranded_auth = response.success? ? response.body : nil
|
42
41
|
|
43
42
|
response
|
44
43
|
end
|
45
44
|
|
46
|
-
def user_params(username, password)
|
45
|
+
def user_params(username, password, email)
|
47
46
|
{
|
48
47
|
user: {
|
49
48
|
loginName: username,
|
49
|
+
email: email,
|
50
50
|
password: password,
|
51
51
|
locale: 'en_US'
|
52
52
|
}
|
53
53
|
}
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
57
|
-
params = user_params(username, password)
|
58
|
-
response = cobranded_session_execute_api('/v1/user/login', params)
|
56
|
+
def login_user(username:, password:)
|
57
|
+
params = user_params(username, password, nil)
|
58
|
+
response = cobranded_session_execute_api(:post, '/v1/user/login', params)
|
59
59
|
@user_auth = response.success? ? response.body : nil
|
60
60
|
response
|
61
61
|
end
|
62
62
|
|
63
|
-
def register_user(username:, password:, options: {}, subscribe: true)
|
64
|
-
params = user_params(username, password).merge(options)
|
65
|
-
response = cobranded_session_execute_api('/v1/user/register', params)
|
63
|
+
def register_user(username:, password:, email:, options: {}, subscribe: true)
|
64
|
+
params = user_params(username, password, email).merge(options)
|
65
|
+
response = cobranded_session_execute_api(:post, '/v1/user/register', params)
|
66
66
|
@user_auth = response.success? ? response.body : nil
|
67
67
|
subscribe_user_to_refresh if response.success? && subscribe
|
68
68
|
response
|
@@ -75,26 +75,25 @@ module YodleeWrap
|
|
75
75
|
callbackUrl: webhookEndpoint
|
76
76
|
}
|
77
77
|
}
|
78
|
-
user_session_execute_api('v1/cobrand/config/notifications/events/REFRESH', params)
|
78
|
+
user_session_execute_api(:post, 'v1/cobrand/config/notifications/events/REFRESH', params)
|
79
79
|
end
|
80
80
|
|
81
81
|
def unregister_user
|
82
|
-
response = user_session_execute_api('v1/user/unregister')
|
82
|
+
response = user_session_execute_api(:delete, 'v1/user/unregister')
|
83
83
|
@user_auth = nil if response.success?
|
84
84
|
end
|
85
85
|
|
86
86
|
def logout_user
|
87
|
-
user_session_execute_api('/v1/user/logout')
|
87
|
+
user_session_execute_api(:post, '/v1/user/logout')
|
88
88
|
end
|
89
89
|
|
90
|
-
def login_or_register_user(username:, password:, subscribe: true)
|
90
|
+
def login_or_register_user(username:, password:, email:, subscribe: true)
|
91
91
|
info_log "Attempting to log in #{username}"
|
92
|
-
response =
|
93
|
-
|
92
|
+
response = login_user(username: username, password: password)
|
94
93
|
# TODO: look into what other errors could occur here
|
95
94
|
if response.fail? && response.error_code == 'Y002'
|
96
95
|
info_log "Invalid credentials for #{username}. Attempting to register"
|
97
|
-
response = register_user(username: username, password: password, subscribe: subscribe)
|
96
|
+
response = register_user(username: username, password: password, email: email, subscribe: subscribe)
|
98
97
|
else
|
99
98
|
info_log response.error_message
|
100
99
|
end
|
@@ -104,36 +103,43 @@ module YodleeWrap
|
|
104
103
|
response
|
105
104
|
end
|
106
105
|
|
106
|
+
def get_transactions
|
107
|
+
user_session_execute_api(:get, "/v1/transactions")
|
108
|
+
end
|
109
|
+
|
107
110
|
def get_provider_details(provider_id)
|
108
|
-
user_session_execute_api("/v1/providers/#{provider_id}")
|
111
|
+
user_session_execute_api(:get, "/v1/providers/#{provider_id}")
|
109
112
|
end
|
110
113
|
|
111
114
|
def add_provider_account(provider_id, provider_params)
|
112
|
-
user_session_execute_api("v1/providers/#{provider_id}", provider_params)
|
115
|
+
user_session_execute_api(:post, "/v1/providers/#{provider_id}", provider_params)
|
113
116
|
end
|
114
117
|
|
115
118
|
def delete_provider_account(provider_account_id)
|
116
|
-
user_session_execute_api("v1/providers/providerAccounts/#{provider_account_id}")
|
119
|
+
user_session_execute_api(:delete, "/v1/providers/providerAccounts/#{provider_account_id}")
|
117
120
|
end
|
118
121
|
|
119
122
|
# After an account has been added, use the returned provider_account_id
|
120
123
|
# to get updates about the provider account.
|
121
124
|
def get_provider_account_status(provider_account_id)
|
122
|
-
user_session_execute_api("v1/providers/#{provider_account_id}")
|
125
|
+
user_session_execute_api(:get, "/v1/providers/providerAccounts/#{provider_account_id}")
|
123
126
|
end
|
124
127
|
|
125
|
-
|
126
|
-
|
128
|
+
# Get all provider accounts for the currently logged in user.
|
129
|
+
def get_all_provider_accounts
|
130
|
+
user_session_execute_api(:get, '/v1/providers/providerAccounts')
|
127
131
|
end
|
128
132
|
|
129
|
-
def
|
130
|
-
|
131
|
-
execute_api(url, params, cobranded_auth_header)
|
133
|
+
def update_provider_account(provider_account_id, provider_params)
|
134
|
+
user_session_execute_api(:put, "/v1/providers/providerAccounts?providerAccountIds=#{provider_account_id}", provider_params)
|
132
135
|
end
|
133
136
|
|
134
|
-
def
|
137
|
+
def cobranded_session_execute_api(method, url, params = {})
|
138
|
+
execute_api(method, url, params, cobranded_auth_header)
|
139
|
+
end
|
135
140
|
|
136
|
-
|
141
|
+
def user_session_execute_api(method, url, params = {})
|
142
|
+
execute_api(method, url, params, user_auth_header)
|
137
143
|
end
|
138
144
|
|
139
145
|
def cobranded_auth_header
|
@@ -141,18 +147,18 @@ module YodleeWrap
|
|
141
147
|
end
|
142
148
|
|
143
149
|
def user_auth_header
|
144
|
-
cobranded_auth_header + "userSession=#{user_session_token}"
|
150
|
+
cobranded_auth_header + ",userSession=#{user_session_token}"
|
145
151
|
end
|
146
152
|
|
147
|
-
def execute_api(url, params, auth_header = "")
|
153
|
+
def execute_api(method, url, params, auth_header = "")
|
148
154
|
debug_log "calling #{url} with #{params}"
|
149
155
|
ssl_opts = { verify: false }
|
150
156
|
connection = Faraday.new(url: base_url, ssl: ssl_opts, request: { proxy: [] })
|
151
|
-
response = connection.
|
157
|
+
response = connection.send(method) do |request|
|
152
158
|
request.url "#{base_url}#{url}"
|
153
|
-
request.headers['Content-Type'] = 'application/json'
|
154
159
|
request.headers['Authorization'] = auth_header
|
155
|
-
request.body = params.to_json
|
160
|
+
request.body = params.to_json unless params.empty?
|
161
|
+
request.headers['Content-Type'] = 'application/json' unless params.empty?
|
156
162
|
end
|
157
163
|
debug_log "response=#{response.status} success?=#{response.success?} body=#{response.body}"
|
158
164
|
Response.new(JSON.parse(response.body), response.status)
|
@@ -165,7 +171,7 @@ module YodleeWrap
|
|
165
171
|
|
166
172
|
def user_session_token
|
167
173
|
return nil if user_auth.nil?
|
168
|
-
user_auth.fetch('
|
174
|
+
user_auth.fetch('user', {}).fetch('session', {}).fetch('userSession')
|
169
175
|
end
|
170
176
|
|
171
177
|
def debug_log(msg)
|
data/lib/yodlee_wrap.rb
CHANGED
@@ -6,7 +6,6 @@ require 'socksify/http'
|
|
6
6
|
|
7
7
|
require File.dirname(__FILE__) + "/yodlee_wrap/version"
|
8
8
|
require File.dirname(__FILE__) + "/yodlee_wrap/config"
|
9
|
-
require File.dirname(__FILE__) + "/yodlee_wrap/parameter_translator"
|
10
9
|
require File.dirname(__FILE__) + "/yodlee_wrap/response"
|
11
10
|
require File.dirname(__FILE__) + "/yodlee_wrap/yodlee_api"
|
12
11
|
|