finapps 2.0.27 → 2.0.28
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.
- checksums.yaml +4 -4
- data/lib/finapps/rest/order_reports.rb +24 -0
- data/lib/finapps/rest/orders.rb +31 -12
- data/lib/finapps/rest/users.rb +5 -0
- data/lib/finapps/version.rb +1 -1
- data/lib/finapps.rb +1 -0
- data/spec/rest/order_reports_spec.rb +36 -0
- data/spec/rest/orders_spec.rb +36 -0
- data/spec/rest/users_spec.rb +36 -6
- data/spec/support/fake_api.rb +14 -0
- data/spec/support/fixtures/invalid_user_id.json +5 -0
- data/spec/support/fixtures/order_report.json +31 -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: 96e530944d9dd3ef2ad9fa275645777bd14f47e1
|
4
|
+
data.tar.gz: bafbeb5761ff48a077ac50a07b0f816bdafc9b70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38eb922890d8e99ff8b408f8e1fead1dc99ad74ac68408af4537803aa55641f95df3539823d01b7c54be191cb90b2eab643ea6e65ab9af814b02f78ecb1f9312
|
7
|
+
data.tar.gz: eaa2583d8a286ee234d717511aed8a18c574869658d0b936de30d680d5cc74e2e29ae6b60dacce9ec8f2c86a0b90c6a95920988ef8bffd258fb43981bd48b03f
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module FinApps
|
3
|
+
module REST
|
4
|
+
class OrderReports < FinApps::REST::Resources # :nodoc:
|
5
|
+
using ObjectExtensions
|
6
|
+
using StringExtensions
|
7
|
+
|
8
|
+
def show(id, format)
|
9
|
+
raise MissingArgumentsError.new 'Missing argument: id.' if id.blank?
|
10
|
+
raise MissingArgumentsError.new 'Missing argument: format' if format.blank?
|
11
|
+
raise InvalidArgumentsError.new 'Invalid argument: format' unless accepted_format?(format)
|
12
|
+
|
13
|
+
path = "orders/#{ERB::Util.url_encode(id)}/report.#{ERB::Util.url_encode(format)}"
|
14
|
+
super nil, path
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def accepted_format?(format)
|
20
|
+
[:json, :html, :pdf].include? format.to_sym
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/finapps/rest/orders.rb
CHANGED
@@ -10,18 +10,24 @@ module FinApps
|
|
10
10
|
super
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
13
|
+
def create(params)
|
14
|
+
raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
|
15
|
+
super params
|
16
|
+
end
|
17
|
+
|
18
|
+
# GET /v2/list/orders/:page/:requested/:sort/:asc
|
19
|
+
# :page - page number requested
|
20
|
+
# :requested - number of results per page requested
|
21
|
+
# :sort - sort order
|
22
|
+
# options:
|
23
|
+
# date - the date of the order
|
24
|
+
# status - the status of the order
|
25
|
+
# :asc - sort order true for asc false for desc
|
26
|
+
def list(params=nil) # params hash with optional keys [:page, :requested, :sort, :asc]
|
27
|
+
return super 'list/orders/1/10000/date/false' if params.nil?
|
28
|
+
raise InvalidArgumentsError.new 'Invalid argument: params' unless params.is_a? Hash
|
29
|
+
|
30
|
+
super build_path(params)
|
25
31
|
end
|
26
32
|
|
27
33
|
def update(id, params)
|
@@ -35,6 +41,19 @@ module FinApps
|
|
35
41
|
|
36
42
|
super params, path
|
37
43
|
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def build_path(p)
|
48
|
+
page = p[:page] || 1
|
49
|
+
requested = p[:requested] || 100
|
50
|
+
sort = p[:sort] || 'date'
|
51
|
+
asc = p[:asc] || false
|
52
|
+
end_point = 'list/orders'
|
53
|
+
path = end_point.dup
|
54
|
+
[page, requested, sort, asc].each_with_index {|a| path << "/#{ERB::Util.url_encode(a)}" }
|
55
|
+
path
|
56
|
+
end
|
38
57
|
end
|
39
58
|
end
|
40
59
|
end
|
data/lib/finapps/rest/users.rb
CHANGED
data/lib/finapps/version.rb
CHANGED
data/lib/finapps.rb
CHANGED
@@ -33,6 +33,7 @@ require 'finapps/rest/institutions'
|
|
33
33
|
require 'finapps/rest/user_institutions_statuses'
|
34
34
|
require 'finapps/rest/user_institutions'
|
35
35
|
require 'finapps/rest/user_institutions_forms'
|
36
|
+
require 'finapps/rest/order_reports'
|
36
37
|
|
37
38
|
require 'finapps/rest/configuration'
|
38
39
|
require 'finapps/rest/credentials'
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
RSpec.describe FinApps::REST::OrderReports do
|
3
|
+
let(:client) { FinApps::REST::Client.new(:company_identifier, :company_token) }
|
4
|
+
describe '#show' do
|
5
|
+
context 'when missing id' do
|
6
|
+
subject { FinApps::REST::OrderReports.new(client).show(nil, :pdf) }
|
7
|
+
it { expect { subject }.to raise_error(FinApps::MissingArgumentsError) }
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'when missing format' do
|
11
|
+
subject { FinApps::REST::OrderReports.new(client).show(:valid_id, nil) }
|
12
|
+
it { expect { subject }.to raise_error(FinApps::MissingArgumentsError) }
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'when invalid format is provided' do
|
16
|
+
subject { FinApps::REST::OrderReports.new(client).show(:valid_id, :xml) }
|
17
|
+
it { expect { subject }.to raise_error(FinApps::InvalidArgumentsError) }
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when valid params are provided' do
|
21
|
+
subject { FinApps::REST::OrderReports.new(client).show(:valid_id, :json) }
|
22
|
+
|
23
|
+
it { expect { subject }.not_to raise_error }
|
24
|
+
it('performs a get and returns the response') { expect(subject[0]).to respond_to(:days_requested) }
|
25
|
+
it('returns no error messages') { expect(subject[1]).to be_empty }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when invalid id is provided' do
|
29
|
+
subject { FinApps::REST::OrderReports.new(client).show(:invalid_id, :json) }
|
30
|
+
|
31
|
+
it { expect { subject }.not_to raise_error }
|
32
|
+
it('results is nil') { expect(subject[0]).to be_nil }
|
33
|
+
it('error messages array is populated') { expect(subject[1].first.downcase).to eq('resource not found') }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/rest/orders_spec.rb
CHANGED
@@ -10,11 +10,37 @@ RSpec.describe FinApps::REST::Orders do
|
|
10
10
|
context 'when valid params are provided' do
|
11
11
|
subject { FinApps::REST::Orders.new(client).show(:id) }
|
12
12
|
|
13
|
+
it { expect { subject }.not_to raise_error }
|
14
|
+
it('returns an array') { expect(subject).to be_a(Array) }
|
15
|
+
it('performs a get and returns the response') { expect(subject[0]).to respond_to(:public_id) }
|
16
|
+
it('returns no error messages') { expect(subject[1]).to be_empty }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#create' do
|
21
|
+
context 'when missing params' do
|
22
|
+
subject { FinApps::REST::Orders.new(client).create(nil) }
|
23
|
+
it { expect { subject }.to raise_error(FinApps::MissingArgumentsError) }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when valid params are provided' do
|
27
|
+
subject { FinApps::REST::Orders.new(client).create(valid_params) }
|
28
|
+
let(:valid_params) { {applicant: 'valid', institutions: 'valid', product: 'valid'} }
|
29
|
+
|
13
30
|
it { expect { subject }.not_to raise_error }
|
14
31
|
it('returns an array') { expect(subject).to be_a(Array) }
|
15
32
|
it('performs a post and returns the response') { expect(subject[0]).to respond_to(:public_id) }
|
16
33
|
it('returns no error messages') { expect(subject[1]).to be_empty }
|
17
34
|
end
|
35
|
+
|
36
|
+
context 'when invalid params are provided' do
|
37
|
+
subject { FinApps::REST::Orders.new(client).create(invalid_params) }
|
38
|
+
let(:invalid_params) { {applicant: 'valid'} }
|
39
|
+
|
40
|
+
it { expect { subject }.not_to raise_error }
|
41
|
+
it('results is nil') { expect(subject[0]).to be_nil }
|
42
|
+
it('error messages array is populated') { expect(subject[1].first.downcase).to eq('invalid request body') }
|
43
|
+
end
|
18
44
|
end
|
19
45
|
|
20
46
|
describe '#list' do
|
@@ -28,6 +54,16 @@ RSpec.describe FinApps::REST::Orders do
|
|
28
54
|
it('performs a get and returns the response') { expect(subject[0]).to respond_to(:orders) }
|
29
55
|
it('returns no error messages') { expect(subject[1]).to be_empty }
|
30
56
|
end
|
57
|
+
|
58
|
+
context 'when including partial params' do
|
59
|
+
subject { FinApps::REST::Orders.new(client).list(params) }
|
60
|
+
let(:params) { {page: 2, sort: 'status'} }
|
61
|
+
|
62
|
+
it { expect { subject }.not_to raise_error }
|
63
|
+
it('returns an array') { expect(subject).to be_a(Array) }
|
64
|
+
it('performs a get and returns the response') { expect(subject[0]).to respond_to(:orders) }
|
65
|
+
it('returns no error messages') { expect(subject[1]).to be_empty }
|
66
|
+
end
|
31
67
|
end
|
32
68
|
|
33
69
|
describe '#update' do
|
data/spec/rest/users_spec.rb
CHANGED
@@ -3,12 +3,10 @@ require 'spec_helpers/client'
|
|
3
3
|
|
4
4
|
RSpec.describe FinApps::REST::Users, 'initialized with valid FinApps::Client object' do
|
5
5
|
include SpecHelpers::Client
|
6
|
-
|
6
|
+
subject(:users) { FinApps::REST::Users.new(client) }
|
7
7
|
missing_public_id = 'Missing argument: public_id.'
|
8
8
|
|
9
9
|
describe '#show' do
|
10
|
-
subject(:users) { FinApps::REST::Users.new(client) }
|
11
|
-
|
12
10
|
context 'when missing public_id' do
|
13
11
|
it { expect { subject.show(nil) }.to raise_error(FinApps::MissingArgumentsError, missing_public_id) }
|
14
12
|
end
|
@@ -36,8 +34,6 @@ RSpec.describe FinApps::REST::Users, 'initialized with valid FinApps::Client obj
|
|
36
34
|
end
|
37
35
|
|
38
36
|
describe '#update' do
|
39
|
-
subject(:users) { FinApps::REST::Users.new(client) }
|
40
|
-
|
41
37
|
context 'when missing public_id' do
|
42
38
|
it { expect { subject.update(nil, {}) }.to raise_error(FinApps::MissingArgumentsError, missing_public_id) }
|
43
39
|
end
|
@@ -54,7 +50,15 @@ RSpec.describe FinApps::REST::Users, 'initialized with valid FinApps::Client obj
|
|
54
50
|
end
|
55
51
|
|
56
52
|
context 'for invalid public_id' do
|
57
|
-
|
53
|
+
let(:update) { subject.update(:invalid_public_id, postal_code: '33021') }
|
54
|
+
let(:results) { update[0] }
|
55
|
+
let(:error_messages) { update[1] }
|
56
|
+
|
57
|
+
it { expect { update }.not_to raise_error }
|
58
|
+
it('results is nil') { expect(results).to be_nil }
|
59
|
+
it('error messages array is populated') do
|
60
|
+
expect(error_messages.first.downcase).to eq('invalid user id specified.')
|
61
|
+
end
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
@@ -81,5 +85,31 @@ RSpec.describe FinApps::REST::Users, 'initialized with valid FinApps::Client obj
|
|
81
85
|
it('error messages array is populated') { expect(error_messages.first.downcase).to eq('resource not found') }
|
82
86
|
end
|
83
87
|
end
|
88
|
+
|
89
|
+
describe '#destroy' do
|
90
|
+
context 'when missing public_id' do
|
91
|
+
it { expect { subject.destroy(nil) }.to raise_error(FinApps::MissingArgumentsError, missing_public_id) }
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'for valid public_id' do
|
95
|
+
let(:destroy) { subject.destroy(:valid_public_id) }
|
96
|
+
let(:results) { destroy[0] }
|
97
|
+
let(:error_messages) { destroy[1] }
|
98
|
+
|
99
|
+
it { expect { destroy }.not_to raise_error }
|
100
|
+
it('results is nil') { expect(results).to be_nil }
|
101
|
+
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'for invalid token' do
|
105
|
+
let(:destroy) { subject.destroy(:invalid_public_id) }
|
106
|
+
let(:results) { destroy[0] }
|
107
|
+
let(:error_messages) { destroy[1] }
|
108
|
+
|
109
|
+
it { expect { destroy }.not_to raise_error }
|
110
|
+
it('results is nil') { expect(results).to be_nil }
|
111
|
+
it('error messages array is populated') { expect(error_messages.first.downcase).to eq('resource not found') }
|
112
|
+
end
|
113
|
+
end
|
84
114
|
end
|
85
115
|
end
|
data/spec/support/fake_api.rb
CHANGED
@@ -15,6 +15,8 @@ class FakeApi < Sinatra::Base
|
|
15
15
|
post('/v2/orders/invalid_token') { json_response 404, 'resource_not_found.json' }
|
16
16
|
get('/v2/orders/:id') { json_response 200, 'resource.json' }
|
17
17
|
get('/v2/list/orders/:page/:requested/:sort/:asc') { json_response 200, 'orders.json' }
|
18
|
+
get('/v2/orders/valid_id/report.:format') { json_response 200, 'order_report.json' }
|
19
|
+
get('/v2/orders/invalid_id/report.:format') { json_response 404, 'resource_not_found.json' }
|
18
20
|
put('/v2/orders/invalid_id') { json_response 404, 'resource_not_found.json' }
|
19
21
|
put('/v2/orders/valid_id') do
|
20
22
|
request.body.rewind
|
@@ -25,6 +27,15 @@ class FakeApi < Sinatra::Base
|
|
25
27
|
json_response 400, 'invalid_request_body.json'
|
26
28
|
end
|
27
29
|
end
|
30
|
+
post('/v2/orders') do
|
31
|
+
request.body.rewind
|
32
|
+
request_payload = JSON.parse request.body.read
|
33
|
+
if %w(applicant institutions product).all? {|s| request_payload.key? s }
|
34
|
+
json_response 200, 'order_token.json'
|
35
|
+
else
|
36
|
+
json_response 400, 'invalid_request_body.json'
|
37
|
+
end
|
38
|
+
end
|
28
39
|
|
29
40
|
# institutions
|
30
41
|
get('/v2/institutions/site/valid_site_id/form') { json_response 200, 'institution_login_form.json' }
|
@@ -53,8 +64,11 @@ class FakeApi < Sinatra::Base
|
|
53
64
|
get('/v2/users/valid_public_id') { json_response 200, 'user.json' }
|
54
65
|
get('/v2/users/invalid_public_id') { json_response 404, 'resource_not_found.json' }
|
55
66
|
put('/v2/users/valid_public_id') { status 204 }
|
67
|
+
put('/v2/users/invalid_public_id') { json_response 400, 'invalid_user_id.json' }
|
56
68
|
put('/v2/users/valid_public_id/password') { json_response 200, 'user.json' }
|
57
69
|
put('/v2/users/invalid_public_id/password') { json_response 404, 'resource_not_found.json' }
|
70
|
+
delete('/v2/users/valid_public_id') { status 204 }
|
71
|
+
delete('/v2/users/invalid_public_id') { json_response 404, 'resource_not_found.json' }
|
58
72
|
|
59
73
|
# session
|
60
74
|
post('/v2/login') do
|
@@ -0,0 +1,31 @@
|
|
1
|
+
{
|
2
|
+
"currency": "USD",
|
3
|
+
"days_requested": 90,
|
4
|
+
"applicant": {
|
5
|
+
"first_name": "Bobby",
|
6
|
+
"last_name": "P",
|
7
|
+
"ssn": "",
|
8
|
+
"dob": "",
|
9
|
+
"email": "bobby@bobby.com",
|
10
|
+
"mobile_phone": "",
|
11
|
+
"work_phone": "",
|
12
|
+
"home_phone": "",
|
13
|
+
"address": "",
|
14
|
+
"address2": "",
|
15
|
+
"city": "",
|
16
|
+
"state": "",
|
17
|
+
"zip": "33146",
|
18
|
+
"employer": {
|
19
|
+
"name": "",
|
20
|
+
"position": "",
|
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
|
+
}
|
30
|
+
// shortened version
|
31
|
+
}
|
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.28
|
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-09-
|
11
|
+
date: 2016-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -266,6 +266,7 @@ files:
|
|
266
266
|
- lib/finapps/rest/defaults.rb
|
267
267
|
- lib/finapps/rest/institutions.rb
|
268
268
|
- lib/finapps/rest/institutions_forms.rb
|
269
|
+
- lib/finapps/rest/order_reports.rb
|
269
270
|
- lib/finapps/rest/order_tokens.rb
|
270
271
|
- lib/finapps/rest/orders.rb
|
271
272
|
- lib/finapps/rest/resources.rb
|
@@ -290,6 +291,7 @@ files:
|
|
290
291
|
- spec/rest/credentials_spec.rb
|
291
292
|
- spec/rest/institutions_forms_spec.rb
|
292
293
|
- spec/rest/institutions_spec.rb
|
294
|
+
- spec/rest/order_reports_spec.rb
|
293
295
|
- spec/rest/order_tokens_spec.rb
|
294
296
|
- spec/rest/orders_spec.rb
|
295
297
|
- spec/rest/resources_spec.rb
|
@@ -307,7 +309,9 @@ files:
|
|
307
309
|
- spec/support/fixtures/institutions_search_list.json
|
308
310
|
- spec/support/fixtures/invalid_institution_id.json
|
309
311
|
- spec/support/fixtures/invalid_request_body.json
|
312
|
+
- spec/support/fixtures/invalid_user_id.json
|
310
313
|
- spec/support/fixtures/invalid_user_institution_id.json
|
314
|
+
- spec/support/fixtures/order_report.json
|
311
315
|
- spec/support/fixtures/order_token.json
|
312
316
|
- spec/support/fixtures/orders.json
|
313
317
|
- spec/support/fixtures/relevance_ruleset_names.json
|
@@ -369,6 +373,7 @@ test_files:
|
|
369
373
|
- spec/rest/users_spec.rb
|
370
374
|
- spec/rest/base_client_spec.rb
|
371
375
|
- spec/rest/user_institutions_forms_spec.rb
|
376
|
+
- spec/rest/order_reports_spec.rb
|
372
377
|
- spec/rest/user_institutions_statuses_spec.rb
|
373
378
|
- spec/rest/user_institutions_spec.rb
|
374
379
|
- spec/rest/client_spec.rb
|