finapps 2.0.11 → 2.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/core_extensions/object/is_integer.rb +0 -2
- data/lib/finapps.rb +1 -0
- data/lib/finapps/rest/client.rb +4 -0
- data/lib/finapps/rest/connection.rb +1 -1
- data/lib/finapps/rest/order_tokens.rb +15 -0
- data/lib/finapps/rest/resources.rb +6 -4
- data/lib/finapps/version.rb +1 -1
- data/spec/rest/client_spec.rb +6 -2
- data/spec/rest/order_tokens_spec.rb +31 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/fake_api.rb +3 -0
- data/spec/support/fixtures/order_token.json +67 -0
- data/spec/support/fixtures/order_token_invalid.json +5 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 892658d99508ced4e79d11b2b61897f7c795b381
|
4
|
+
data.tar.gz: b839df6e00c6ad1720ed2a36fc53008c3fb9c6ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfa0c2e7fd724240be7ca119f996b70bb53bac454f21e1883b3a6b892e9ea628a0bc714c3eda3106a356aa69c01d6832f32dfd7b8f95880c478c32c923cfa9c8
|
7
|
+
data.tar.gz: 96ad3e2ddd0d94b881bf604316ada36e8abad77eed58692a11a95fd350dd62f05482855a9b46b84ee55ce3d7d677e90113a3fd68bdaa7f8a3629319d6fa3c232
|
data/lib/finapps.rb
CHANGED
data/lib/finapps/rest/client.rb
CHANGED
@@ -23,7 +23,7 @@ module FinApps
|
|
23
23
|
conn.use FinApps::Middleware::RaiseError
|
24
24
|
conn.response :rashify
|
25
25
|
conn.response :json, content_type: /\bjson$/
|
26
|
-
conn.response :logger, logger, bodies: true
|
26
|
+
conn.response :logger, logger, bodies: (ENV['RSPEC'] != 'true')
|
27
27
|
|
28
28
|
# Adapter (ensure that the adapter is always last.)
|
29
29
|
conn.adapter :typhoeus
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module FinApps
|
3
|
+
module REST
|
4
|
+
class OrderTokens < FinApps::REST::Resources # :nodoc:
|
5
|
+
using ObjectExtensions
|
6
|
+
using StringExtensions
|
7
|
+
|
8
|
+
def show(token)
|
9
|
+
raise MissingArgumentsError.new 'Missing argument: token.' if token.blank?
|
10
|
+
|
11
|
+
create nil, "orders/#{ERB::Util.url_encode(token)}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -14,16 +14,14 @@ module FinApps
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def create(params={}, path=nil)
|
17
|
-
path =
|
17
|
+
path = end_point if path.nil?
|
18
18
|
logger.debug "#{self.class.name}##{__method__} => path: #{path} params: #{params}"
|
19
19
|
results, error_messages = client.send_request(path, :post, params)
|
20
20
|
[results, error_messages]
|
21
21
|
end
|
22
22
|
|
23
23
|
def show(id, path=nil)
|
24
|
-
if path.nil?
|
25
|
-
path = "#{self.class.name.split('::').last.downcase}/:id".sub ':id', ERB::Util.url_encode(id)
|
26
|
-
end
|
24
|
+
path = "#{end_point}/:id".sub ':id', ERB::Util.url_encode(id) if path.nil?
|
27
25
|
logger.debug "#{self.class.name}##{__method__} => path: #{path}"
|
28
26
|
results, error_messages = client.send_request(path, :get)
|
29
27
|
[results, error_messages]
|
@@ -34,6 +32,10 @@ module FinApps
|
|
34
32
|
def logger
|
35
33
|
client.logger
|
36
34
|
end
|
35
|
+
|
36
|
+
def end_point
|
37
|
+
self.class.name.split('::').last.downcase
|
38
|
+
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
data/lib/finapps/version.rb
CHANGED
data/spec/rest/client_spec.rb
CHANGED
@@ -13,7 +13,7 @@ RSpec.describe FinApps::REST::Client do
|
|
13
13
|
context 'an instance of Client' do
|
14
14
|
subject { FinApps::REST::Client.new(:company_identifier, :company_token) }
|
15
15
|
|
16
|
-
%i(users orders).each do |method|
|
16
|
+
%i(users orders order_tokens).each do |method|
|
17
17
|
it "responds to #{method}" do
|
18
18
|
expect(subject).to respond_to(method)
|
19
19
|
end
|
@@ -23,6 +23,10 @@ RSpec.describe FinApps::REST::Client do
|
|
23
23
|
it { expect(subject.users).to be_an_instance_of(FinApps::REST::Users) }
|
24
24
|
end
|
25
25
|
|
26
|
+
describe '#order_tokens' do
|
27
|
+
it { expect(subject.order_tokens).to be_an_instance_of(FinApps::REST::OrderTokens) }
|
28
|
+
end
|
29
|
+
|
26
30
|
describe '#orders' do
|
27
31
|
it { expect(subject.orders).to be_an_instance_of(FinApps::REST::Orders) }
|
28
32
|
end
|
@@ -30,7 +34,7 @@ RSpec.describe FinApps::REST::Client do
|
|
30
34
|
# [:users, :institutions, :user_institutions, :transactions, :categories,
|
31
35
|
# :budget_models, :budget_calculation, :budgets, :cashflows,
|
32
36
|
# :alert, :alert_definition, :alert_preferences, :alert_settings, :rule_sets]
|
33
|
-
%i(users orders).each do |method|
|
37
|
+
%i(users orders order_tokens).each do |method|
|
34
38
|
it "memoizes the result of #{method}" do
|
35
39
|
first = subject.send(method)
|
36
40
|
second = subject.send(method)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
RSpec.describe FinApps::REST::OrderTokens, 'initialized with valid FinApps::Client object' do
|
3
|
+
describe '#show' do
|
4
|
+
client = FinApps::REST::Client.new :company_identifier, :company_token
|
5
|
+
subject(:order_tokens) { FinApps::REST::OrderTokens.new(client) }
|
6
|
+
|
7
|
+
context 'when missing token' do
|
8
|
+
it { expect { subject.show(nil) }.to raise_error(FinApps::MissingArgumentsError, 'Missing argument: token.') }
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'for valid token' do
|
12
|
+
let(:show) { subject.show(:valid_token) }
|
13
|
+
let(:results) { show[0] }
|
14
|
+
let(:error_messages) { show[1] }
|
15
|
+
|
16
|
+
it { expect { show }.not_to raise_error }
|
17
|
+
it('results is a Hashie::Rash') { expect(results).to be_a(Hashie::Rash) }
|
18
|
+
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'for invalid token' do
|
22
|
+
let(:show) { subject.show(:invalid_token) }
|
23
|
+
let(:results) { show[0] }
|
24
|
+
let(:error_messages) { show[1] }
|
25
|
+
|
26
|
+
it { expect { show }.not_to raise_error }
|
27
|
+
it('results is nil') { expect(results).to be_nil }
|
28
|
+
it('error messages array is populated') { expect(error_messages.first).to eq('resource not found') }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/fake_api.rb
CHANGED
@@ -8,6 +8,8 @@ class FakeApi < Sinatra::Base
|
|
8
8
|
get('/v2/resources/:id') { json_response 200, 'resource.json' }
|
9
9
|
|
10
10
|
# orders
|
11
|
+
post('/v2/orders/invalid_token') { json_response 404, 'order_token_invalid.json' }
|
12
|
+
post('/v2/orders/valid_token') { json_response 200, 'order_token.json' }
|
11
13
|
get('/v2/orders/:id') { json_response 200, 'resource.json' }
|
12
14
|
|
13
15
|
# users
|
@@ -16,6 +18,7 @@ class FakeApi < Sinatra::Base
|
|
16
18
|
# relevance
|
17
19
|
get('/v2/relevance/ruleset/names') { json_response 200, 'relevance_ruleset_names.json' }
|
18
20
|
|
21
|
+
# errors
|
19
22
|
get('/v2/client_error') { json_response 400, 'error.json' }
|
20
23
|
get('/v2/server_error') { status 500 }
|
21
24
|
get('/v2/proxy_error') { status 407 }
|
@@ -0,0 +1,67 @@
|
|
1
|
+
{
|
2
|
+
"public_id": "ead38f03-96e4-4c62-42fd-281d96170e41",
|
3
|
+
"user_id": "62356939-5837-48cc-4a3a-87cbe58daa0e",
|
4
|
+
"applicant": {
|
5
|
+
"first_name": "John",
|
6
|
+
"last_name": "Smith",
|
7
|
+
"ssn": "",
|
8
|
+
"dob": "",
|
9
|
+
"email": "erich@financialapps.com",
|
10
|
+
"mobile_phone": "",
|
11
|
+
"work_phone": "",
|
12
|
+
"home_phone": "",
|
13
|
+
"address": "",
|
14
|
+
"address2": "",
|
15
|
+
"city": "",
|
16
|
+
"state": "",
|
17
|
+
"zip": "33021",
|
18
|
+
"employer": {
|
19
|
+
"name": "",
|
20
|
+
"poistion": "",
|
21
|
+
"length_months": 0,
|
22
|
+
"pay_cycle": "",
|
23
|
+
"type": "",
|
24
|
+
"start_date": "0001-01-01T00:00:00Z",
|
25
|
+
"end_date": "0001-01-01T00:00:00Z",
|
26
|
+
"pay_amt_gross": 0,
|
27
|
+
"pay_amt_net": 0
|
28
|
+
},
|
29
|
+
"previous_employers": [],
|
30
|
+
"annual_income": 0,
|
31
|
+
"monthly_income": 0,
|
32
|
+
"weekly_income": 0,
|
33
|
+
"net_income": 0,
|
34
|
+
"marital_status": "",
|
35
|
+
"dependents": 0
|
36
|
+
},
|
37
|
+
"institutions": [
|
38
|
+
{
|
39
|
+
"name": "DAG",
|
40
|
+
"account_type": "",
|
41
|
+
"routing_no": "99999999",
|
42
|
+
"account_no": "1",
|
43
|
+
"name_on_account": "John Smith",
|
44
|
+
"account_nickname": "",
|
45
|
+
"account_address": "",
|
46
|
+
"shared": false,
|
47
|
+
"site_id": 16441
|
48
|
+
}
|
49
|
+
],
|
50
|
+
"product": {
|
51
|
+
"public_id": "77777777-6ac6-4183-a671-6e75ca5989a5",
|
52
|
+
"code": "PROD2"
|
53
|
+
},
|
54
|
+
"requestor": {
|
55
|
+
"company_id": "",
|
56
|
+
"company_name": "",
|
57
|
+
"broker": "",
|
58
|
+
"processor": "",
|
59
|
+
"phone": "",
|
60
|
+
"email": "",
|
61
|
+
"reference_no": ""
|
62
|
+
},
|
63
|
+
"webhook": "",
|
64
|
+
"status": 2,
|
65
|
+
"date": "2016-07-12T19:33:33.655Z",
|
66
|
+
"date_modified": "2016-07-12T19:33:33.655Z"
|
67
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finapps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erich Quintero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -261,6 +261,7 @@ files:
|
|
261
261
|
- lib/finapps/rest/connection.rb
|
262
262
|
- lib/finapps/rest/credentials.rb
|
263
263
|
- lib/finapps/rest/defaults.rb
|
264
|
+
- lib/finapps/rest/order_tokens.rb
|
264
265
|
- lib/finapps/rest/orders.rb
|
265
266
|
- lib/finapps/rest/resources.rb
|
266
267
|
- lib/finapps/rest/users.rb
|
@@ -276,11 +277,14 @@ files:
|
|
276
277
|
- spec/rest/client_spec.rb
|
277
278
|
- spec/rest/configuration_spec.rb
|
278
279
|
- spec/rest/credentials_spec.rb
|
280
|
+
- spec/rest/order_tokens_spec.rb
|
279
281
|
- spec/rest/orders_spec.rb
|
280
282
|
- spec/rest/resources_spec.rb
|
281
283
|
- spec/spec_helper.rb
|
282
284
|
- spec/support/fake_api.rb
|
283
285
|
- spec/support/fixtures/error.json
|
286
|
+
- spec/support/fixtures/order_token.json
|
287
|
+
- spec/support/fixtures/order_token_invalid.json
|
284
288
|
- spec/support/fixtures/relevance_ruleset_names.json
|
285
289
|
- spec/support/fixtures/resource.json
|
286
290
|
- spec/support/fixtures/user.json
|
@@ -324,6 +328,7 @@ test_files:
|
|
324
328
|
- spec/rest/resources_spec.rb
|
325
329
|
- spec/rest/client_spec.rb
|
326
330
|
- spec/rest/orders_spec.rb
|
331
|
+
- spec/rest/order_tokens_spec.rb
|
327
332
|
- spec/rest/base_client_spec.rb
|
328
333
|
- spec/rest/configuration_spec.rb
|
329
334
|
- spec/core_extensions/object/is_integer_spec.rb
|