yodlee-icious 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9eab47ae01a99ab1d4ac7a9f7eb2b5890c254f1
4
- data.tar.gz: 9b4ab7293d4ef8a6a610b773afbeed171bea2bbd
3
+ metadata.gz: ef657a8e0be48fd78555ced77a44dc9fa8a442e8
4
+ data.tar.gz: c38c3dc0f39b588f9dbd89e832e0a524c08bb75d
5
5
  SHA512:
6
- metadata.gz: 5f3086d4c81ca0d5736ec609a81137b43c70119384c06314deab9c45257b8b7a17d922bfc98fcd670003af0cfd95acf9b6c5b9f54bea6a5c6e6e5ebb65f23fb7
7
- data.tar.gz: 3d4c97573ff3105ec774b0c468eea8a334d07fba96d79f57e568ce416d73ee553a5deef6fbb81476f2b8fb9553129ec3eb474dc4cefe771779bed4c43174a3bb
6
+ metadata.gz: de70078bd2302015cb9ef739043eb137c38cb0059d4607d3c772a9604bf166686b1de718a952e6767746a3b6f64ccc33ba5394674ca3253fe0b1a3ed5b9aa030
7
+ data.tar.gz: a95ee9952630975c96961ec0b64ef0268a004ad1e45f8f3331e30ddeca420a6831015187c9abc456a6213963f42c4871a3a68d3a36561690b917724b1752a70d
@@ -0,0 +1 @@
1
+ 2.3.1
@@ -1,8 +1,9 @@
1
1
  module Yodleeicious
2
2
  class Response
3
3
 
4
- def initialize body
5
- @body = body
4
+ def initialize res, payload=nil
5
+ @res = res
6
+ @payload = payload
6
7
  end
7
8
 
8
9
  def success?
@@ -14,7 +15,25 @@ module Yodleeicious
14
15
  end
15
16
 
16
17
  def body
17
- @body
18
+ @body ||= JSON.parse(@res.body)
19
+ end
20
+
21
+ def payload
22
+ @payload
23
+ end
24
+
25
+ def request_url
26
+ @res.env.url.to_s
27
+ rescue
28
+ nil
29
+ end
30
+
31
+ def status
32
+ @res.status
33
+ end
34
+
35
+ def response
36
+ body
18
37
  end
19
38
 
20
39
  def error
@@ -1,3 +1,3 @@
1
1
  module Yodleeicious
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -16,7 +16,7 @@ module Yodleeicious
16
16
  @cobranded_password = config[:cobranded_password] || Yodleeicious::Config.cobranded_password
17
17
  @proxy_url = config[:proxy_url] || Yodleeicious::Config.proxy_url
18
18
  @logger = config[:logger] || Yodleeicious::Config.logger
19
-
19
+
20
20
  info_log "YodleeApi configured with base_url=#{base_url} cobranded_username=#{cobranded_username} proxy_url=#{proxy_url} logger=#{logger}"
21
21
  end
22
22
 
@@ -32,7 +32,7 @@ module Yodleeicious
32
32
  proxy_opts = {}
33
33
 
34
34
  unless proxy_url == nil
35
- proxy_opts[:uri] = URI.parse(proxy_url)
35
+ proxy_opts[:uri] = URI.parse(proxy_url)
36
36
  proxy_opts[:socks] = use_socks?
37
37
  end
38
38
 
@@ -40,7 +40,7 @@ module Yodleeicious
40
40
  end
41
41
 
42
42
  def use_socks?
43
- return proxy_url != nil && proxy_url.start_with?('socks')
43
+ return proxy_url != nil && proxy_url.start_with?('socks')
44
44
  end
45
45
 
46
46
  def cobranded_login
@@ -138,7 +138,7 @@ module Yodleeicious
138
138
  end
139
139
 
140
140
  def add_site_account site_id, site_login_form
141
- params = {
141
+ params = {
142
142
  siteId: site_id
143
143
  }.merge(translator.site_login_form_to_add_site_account_params(site_login_form))
144
144
 
@@ -167,7 +167,7 @@ module Yodleeicious
167
167
  end
168
168
 
169
169
  def should_retry_get_site_refresh_info? response, try, max_trys
170
- return response.success? && try < max_trys && (response.body['code'] == 801 || (response.body['code'] == 0 &&
170
+ return response.success? && try < max_trys && (response.body['code'] == 801 || (response.body['code'] == 0 &&
171
171
  response.body['siteRefreshStatus']['siteRefreshStatus'] != 'REFRESH_COMPLETED' &&
172
172
  response.body['siteRefreshStatus']['siteRefreshStatus'] != 'REFRESH_TIMED_OUT' &&
173
173
  response.body['siteRefreshStatus']['siteRefreshStatus'] != 'LOGIN_SUCCESS' ))
@@ -329,7 +329,7 @@ module Yodleeicious
329
329
 
330
330
  case response.status
331
331
  when 200
332
- Response.new(JSON.parse(response.body))
332
+ Response.new(response, params)
333
333
  else
334
334
  end
335
335
  end
@@ -1,8 +1,8 @@
1
1
  require "yodleeicious"
2
2
 
3
3
  describe 'the yodlee api client integration tests', integration: true do
4
- let(:config) {
5
- {
4
+ let(:config) {
5
+ {
6
6
  base_url: ENV['YODLEE_BASE_URL'],
7
7
  cobranded_username: ENV['YODLEE_COBRANDED_USERNAME'],
8
8
  cobranded_password: ENV['YODLEE_COBRANDED_PASSWORD'],
@@ -19,6 +19,25 @@ describe 'the yodlee api client integration tests', integration: true do
19
19
  }
20
20
  }
21
21
 
22
+ shared_examples "request_response_examples" do
23
+ it 'sets the response data' do
24
+ expect(subject.response).not_to be_nil
25
+ end
26
+
27
+ it 'sets the request_url' do
28
+ expect(subject.request_url).not_to be_nil
29
+ end
30
+
31
+ it 'sets payload' do
32
+ expect(subject.payload).not_to be_nil
33
+ end
34
+
35
+ it 'sets the status code' do
36
+ expect(subject.status).not_to be_nil
37
+ end
38
+ end
39
+
40
+
22
41
  describe 'the yodlee apis cobranded login endpoint' do
23
42
  context 'Given valid cobranded credentials and base_url' do
24
43
  context 'When /authenticate/coblogin is called the return' do
@@ -27,6 +46,8 @@ describe 'the yodlee api client integration tests', integration: true do
27
46
  it { is_expected.to be_kind_of(Yodleeicious::Response) }
28
47
  it { is_expected.to be_success }
29
48
 
49
+ include_examples 'request_response_examples'
50
+
30
51
  it 'contains valid json response' do
31
52
  expect(subject.body['cobrandConversationCredentials']).not_to be_nil
32
53
  expect(subject.body['cobrandConversationCredentials']['sessionToken']).not_to be_nil
@@ -39,7 +60,7 @@ describe 'the yodlee api client integration tests', integration: true do
39
60
  context 'Given valid cobranded credentials and base_url' do
40
61
  context 'Given a new user who does not exist within the cobranded account' do
41
62
  describe 'When /authenticate/coblogin is called the return' do
42
- subject {
63
+ subject {
43
64
  api.cobranded_login
44
65
  api.user_login 'testuser', 'testpassword'
45
66
  }
@@ -47,6 +68,8 @@ describe 'the yodlee api client integration tests', integration: true do
47
68
  it { is_expected.to be_kind_of(Yodleeicious::Response) }
48
69
  it { is_expected.to be_fail }
49
70
 
71
+ include_examples 'request_response_examples'
72
+
50
73
  it 'returns an error response' do
51
74
  expect(subject.body).to eq({"Error"=>[{"errorDetail"=>"Invalid User Credentials"}]})
52
75
  end
@@ -55,7 +78,7 @@ describe 'the yodlee api client integration tests', integration: true do
55
78
 
56
79
  context 'Given a user who does exist within the cobranded account' do
57
80
  describe 'When /authenticate/coblogin is called the return' do
58
- subject {
81
+ subject {
59
82
  api.cobranded_login
60
83
  api.user_login 'testuser', 'testpassword'
61
84
  }
@@ -63,6 +86,8 @@ describe 'the yodlee api client integration tests', integration: true do
63
86
  it { is_expected.to be_kind_of(Yodleeicious::Response) }
64
87
  it { is_expected.to be_fail }
65
88
 
89
+ include_examples 'request_response_examples'
90
+
66
91
  it 'returns an error response' do
67
92
  expect(subject.body).to eq({"Error"=>[{"errorDetail"=>"Invalid User Credentials"}]})
68
93
  end
@@ -84,6 +109,8 @@ describe 'the yodlee api client integration tests', integration: true do
84
109
  api.unregister_user
85
110
  }
86
111
 
112
+ include_examples 'request_response_examples'
113
+
87
114
  it 'is expected to offer a valid response' do
88
115
  is_expected.to be_kind_of(Yodleeicious::Response)
89
116
  is_expected.to be_success
@@ -108,6 +135,7 @@ describe 'the yodlee api client integration tests', integration: true do
108
135
  api.unregister_user
109
136
  }
110
137
 
138
+ include_examples 'request_response_examples'
111
139
 
112
140
  it 'is expected to offer a valid response' do
113
141
  is_expected.to be_kind_of(Yodleeicious::Response)
@@ -133,7 +161,9 @@ describe 'the yodlee api client integration tests', integration: true do
133
161
  context 'When login_or_register_user is called' do
134
162
  subject { api.login_or_register_user email, password, email }
135
163
 
136
- it 'should register the new user and set the user_session_token' do
164
+ include_examples 'request_response_examples'
165
+
166
+ it 'should register the new user and set the user_session_token' do
137
167
  expect(subject).to be_success
138
168
  expect(subject).to be_kind_of(Yodleeicious::Response)
139
169
  expect(api.user_session_token).not_to be_nil
@@ -147,6 +177,8 @@ describe 'the yodlee api client integration tests', integration: true do
147
177
  context 'When login_or_register_user is called' do
148
178
  subject { api.login_or_register_user registered_user[:email], registered_user[:password], registered_user[:email] }
149
179
 
180
+ include_examples 'request_response_examples'
181
+
150
182
  it 'should login the user and not register them' do
151
183
  expect(subject).to be_success
152
184
  expect(subject).to be_kind_of(Yodleeicious::Response)
@@ -158,13 +190,15 @@ describe 'the yodlee api client integration tests', integration: true do
158
190
 
159
191
  describe '#get_site_info' do
160
192
  context 'Given a valid cobranded credentials and base_url' do
161
- before {
193
+ before {
162
194
  api.cobranded_login
163
195
  }
164
196
 
165
197
  context 'When a request for site info is performed the result' do
166
198
  subject { api.get_site_info 16441 }
167
199
 
200
+ include_examples 'request_response_examples'
201
+
168
202
  it 'is expected to contain login form details' do
169
203
  is_expected.not_to be_nil
170
204
  is_expected.to be_kind_of(Yodleeicious::Response)
@@ -185,6 +219,8 @@ describe 'the yodlee api client integration tests', integration: true do
185
219
  context 'When #get_content_service_info_by_routing_number is called with a valid routing number the result' do
186
220
  subject { api.get_content_service_info_by_routing_number 999988181 }
187
221
 
222
+ include_examples 'request_response_examples'
223
+
188
224
  it 'is expected to contain valid content services info' do
189
225
  is_expected.not_to be_nil
190
226
  is_expected.to be_kind_of(Yodleeicious::Response)
@@ -198,6 +234,8 @@ describe 'the yodlee api client integration tests', integration: true do
198
234
  context 'When #get_content_service_info_by_routing_number is called with an invalid routing number' do
199
235
  subject { api.get_content_service_info_by_routing_number -23423 }
200
236
 
237
+ include_examples 'request_response_examples'
238
+
201
239
  it 'is expected to contain valid error details' do
202
240
  is_expected.not_to be_nil
203
241
  is_expected.to be_kind_of(Yodleeicious::Response)
@@ -232,6 +270,8 @@ describe 'the yodlee api client integration tests', integration: true do
232
270
  api.get_mfa_response_for_site response.body['siteAccountId']
233
271
  }
234
272
 
273
+ include_examples 'request_response_examples'
274
+
235
275
  it 'is expected be a valid response' do
236
276
  is_expected.to be_kind_of(Yodleeicious::Response)
237
277
  is_expected.to be_success
@@ -267,6 +307,8 @@ describe 'the yodlee api client integration tests', integration: true do
267
307
  api.get_mfa_response_for_site_and_wait response.body['siteAccountId'], 2
268
308
  }
269
309
 
310
+ include_examples 'request_response_examples'
311
+
270
312
  it 'is expected be a valid response' do
271
313
  is_expected.to be_kind_of(Yodleeicious::Response)
272
314
  is_expected.to be_success
@@ -310,6 +352,8 @@ describe 'the yodlee api client integration tests', integration: true do
310
352
  api.put_mfa_request_for_site site_account_id, :MFATokenResponse, field_info
311
353
  }
312
354
 
355
+ include_examples 'request_response_examples'
356
+
313
357
  it 'is expected be a valid response' do
314
358
  is_expected.to be_kind_of(Yodleeicious::Response)
315
359
  is_expected.to be_success
@@ -347,6 +391,8 @@ describe 'the yodlee api client integration tests', integration: true do
347
391
  api.put_mfa_request_for_site site_account_id, :MFAQuesAnsResponse, field_info
348
392
  }
349
393
 
394
+ include_examples 'request_response_examples'
395
+
350
396
  it 'is expected be a valid response' do
351
397
  is_expected.to be_kind_of(Yodleeicious::Response)
352
398
  is_expected.to be_success
@@ -384,6 +430,8 @@ describe 'the yodlee api client integration tests', integration: true do
384
430
  api.put_mfa_request_for_site site_account_id, :MFAImageResponse, field_info
385
431
  }
386
432
 
433
+ include_examples 'request_response_examples'
434
+
387
435
  it 'is expected be a valid response' do
388
436
  is_expected.to be_kind_of(Yodleeicious::Response)
389
437
  is_expected.to be_success
@@ -399,7 +447,7 @@ describe 'the yodlee api client integration tests', integration: true do
399
447
 
400
448
  describe 'the yodlee apis fetching summary data about registered site accounts endpoints' do
401
449
  context 'Given a registered user with registered accounts' do
402
- before {
450
+ before {
403
451
  api.cobranded_login
404
452
  api.user_login "testuser_with_transactions@liftforward.com", 'testpassword143'
405
453
  # api.register_user "testuser#{rand(100..999)}", 'testpassword143', 'test@test.com'
@@ -408,9 +456,11 @@ describe 'the yodlee api client integration tests', integration: true do
408
456
  # api.add_site_account_and_wait(16441, dag_login_form)
409
457
  }
410
458
 
411
- context 'when getAllSiteAccounts is called the return' do
459
+ context 'when getAllSiteAccounts is called the return' do
412
460
  subject { api.get_all_site_accounts }
413
461
 
462
+ include_examples 'request_response_examples'
463
+
414
464
  it 'is expected to return an array containing 1 siteAccount' do
415
465
  # puts JSON.pretty_generate(subject)
416
466
  is_expected.to be_success
@@ -456,7 +506,7 @@ describe 'the yodlee api client integration tests', integration: true do
456
506
 
457
507
  describe 'the yodlee apis fetching user/s transactions' do
458
508
  context 'Given a registered user with registered accounts' do
459
- before {
509
+ before {
460
510
  api.cobranded_login
461
511
  api.login_or_register_user 'testuser_with_transactions@liftforward.com', 'testpassword143', 'testuser_with_transactions@liftforward.com'
462
512
  dag_login_form['componentList'][0]['fieldValue'] = 'yodlicious.site16441.1'
@@ -482,7 +532,7 @@ describe 'the yodlee api client integration tests', integration: true do
482
532
  end
483
533
  end
484
534
 
485
- pending 'downloading transaction history'
535
+ pending 'downloading transaction history'
486
536
  pending 'fetching a list of content services'
487
537
  pending 'failing to create a new session'
488
538
  pending 'failing when running a search for a site'
@@ -1,29 +1,41 @@
1
1
  require "yodleeicious"
2
2
 
3
- describe Yodleeicious::Response do
4
- let(:error_response_1) {
5
- {
6
- "errorOccurred"=>"true",
7
- "exceptionType"=>"com.yodlee.core.IllegalArgumentValueException",
8
- "referenceCode"=>"_3932d208-345a-400f-a273-83619b8b548b",
9
- "message"=>"Multiple exceptions encapsulated within: invoke getWrappedExceptions for details"
10
- }
11
- }
3
+ shared_examples 'sets_the_requests' do
4
+ it 'sets the response data' do
5
+ expect(subject.response).not_to be_nil
6
+ end
7
+
8
+ it 'sets the request_url' do
9
+ expect(subject.request_url).not_to be_nil
10
+ end
12
11
 
13
- let(:error_response_2) {
14
- { "Error" => [ {"errorDetail" => "Invalid User Credentials"} ] }
15
- }
12
+ it 'sets payload' do
13
+ expect(subject.payload).not_to be_nil
14
+ end
16
15
 
17
- let(:success_hash_response) {
18
- {}
19
- }
16
+ it 'sets the status code' do
17
+ expect(subject.status).not_to be_nil
18
+ end
19
+ end
20
20
 
21
- let(:success_array_response) {
22
- [{}]
23
- }
21
+
22
+ describe Yodleeicious::Response do
23
+ let (:mock_env) { double("env", url: "http://example.com") }
24
+ let (:response) { double("Response", body: response_json, env: mock_env, status: 200 ) }
25
+
26
+ subject { Yodleeicious::Response.new response, { key: "val" } }
24
27
 
25
28
  context 'When the error_response is the errorOccured syntax' do
26
- subject { Yodleeicious::Response.new error_response_1 }
29
+ let(:response_json) {
30
+ {
31
+ "errorOccurred"=>"true",
32
+ "exceptionType"=>"com.yodlee.core.IllegalArgumentValueException",
33
+ "referenceCode"=>"_3932d208-345a-400f-a273-83619b8b548b",
34
+ "message"=>"Multiple exceptions encapsulated within: invoke getWrappedExceptions for details"
35
+ }.to_json
36
+ }
37
+
38
+ include_examples "sets_the_requests"
27
39
  it { is_expected.not_to be_success }
28
40
  it { is_expected.to be_fail }
29
41
  it "is expected to return error of InvalidArgumentValueException" do
@@ -32,7 +44,13 @@ describe Yodleeicious::Response do
32
44
  end
33
45
 
34
46
  context 'When the error_response is the Error : ["errorDetail"] syntax' do
35
- subject { Yodleeicious::Response.new error_response_2 }
47
+ let(:response_json) { { "Error" => [ {"errorDetail" => "Invalid User Credentials"} ] }.to_json }
48
+ let (:mock_env) { double("env", url: "http://example.com") }
49
+ let (:response) { double("Response", body: response_json, env: mock_env, status: 200 ) }
50
+
51
+ subject { Yodleeicious::Response.new response, { key: "val" } }
52
+
53
+ include_examples "sets_the_requests"
36
54
  it { is_expected.not_to be_success }
37
55
  it { is_expected.to be_fail }
38
56
  it "is expected to return error of Invalid User Credentials" do
@@ -41,7 +59,11 @@ describe Yodleeicious::Response do
41
59
  end
42
60
 
43
61
  context 'When operation is a success and returns hash' do
44
- subject { Yodleeicious::Response.new success_hash_response }
62
+ let(:response_json) { {}.to_json }
63
+
64
+ subject { Yodleeicious::Response.new response, { key: "val" } }
65
+
66
+ include_examples "sets_the_requests"
45
67
  it { is_expected.to be_success }
46
68
  it { is_expected.not_to be_fail }
47
69
  it 'is expected to return nil for error' do
@@ -50,7 +72,11 @@ describe Yodleeicious::Response do
50
72
  end
51
73
 
52
74
  context 'When operation is a success and return array' do
53
- subject { Yodleeicious::Response.new success_array_response }
75
+ let(:response_json) { [{}].to_json }
76
+
77
+ subject { Yodleeicious::Response.new response, { key: "val" } }
78
+
79
+ include_examples "sets_the_requests"
54
80
  it { is_expected.to be_success }
55
81
  it { is_expected.not_to be_fail }
56
82
  it 'is expected to return nil for error' do
@@ -31,6 +31,7 @@ describe Yodleeicious::YodleeApi do
31
31
  it 'should return a translator' do
32
32
  expect(subject.translator).not_to be_nil
33
33
  end
34
+
34
35
  end
35
36
 
36
37
  context 'Given a Yodleeicious::Config with nil configuration' do
@@ -104,7 +105,7 @@ describe Yodleeicious::YodleeApi do
104
105
  end
105
106
  end
106
107
  end
107
-
108
+
108
109
  context 'Given a Yodleeicious::Config with nil configuration' do
109
110
  context 'When a new YodleeApi instance is created and provided a configuration' do
110
111
  before {
@@ -114,7 +115,7 @@ describe Yodleeicious::YodleeApi do
114
115
  Yodleeicious::Config.proxy_url=nil
115
116
  }
116
117
  let(:config) {
117
- {
118
+ {
118
119
  base_url: "https://rest.developer.yodlee.com/services/srest/restserver/v1.0",
119
120
  cobranded_username: "some_username",
120
121
  cobranded_password: "some_password",
@@ -162,7 +163,7 @@ describe Yodleeicious::YodleeApi do
162
163
  Yodleeicious::Config.cobranded_password='password'
163
164
  Yodleeicious::Config.proxy_url='socks5h://somehostname'
164
165
  }
165
- let(:config) {
166
+ let(:config) {
166
167
  {
167
168
  base_url: "https://rest.developer.yodlee.com/services/srest/restserver/v1.0",
168
169
  cobranded_username: "some_username",
@@ -245,7 +246,7 @@ describe Yodleeicious::YodleeApi do
245
246
  subject { api.should_retry_get_mfa_response?(response,0,1) }
246
247
  it { is_expected.to be_falsy }
247
248
  end
248
-
249
+
249
250
  context 'Given get mfa response is success' do
250
251
  before { allow(response).to receive(:success?).and_return(true) }
251
252
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yodlee-icious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drew Nichols
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-13 00:00:00.000000000 Z
11
+ date: 2016-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -61,6 +61,7 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
63
  - ".rspec"
64
+ - ".ruby-version"
64
65
  - Gemfile
65
66
  - Guardfile
66
67
  - LICENSE.txt
@@ -102,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
103
  version: '0'
103
104
  requirements: []
104
105
  rubyforge_project:
105
- rubygems_version: 2.2.2
106
+ rubygems_version: 2.5.1
106
107
  signing_key:
107
108
  specification_version: 4
108
109
  summary: Yodlee API Client Gem