finapps 5.0.28 → 5.0.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +2 -1
- data/.rubocop.yml +134 -61
- data/.rubocop_todo.yml +120 -0
- data/.tmuxinator.yml +1 -0
- data/.travis.yml +3 -1
- data/RELEASES.md +42 -0
- data/finapps.gemspec +3 -3
- data/lib/finapps.rb +4 -0
- data/lib/finapps/rest/alert_definitions.rb +1 -1
- data/lib/finapps/rest/alert_occurrences.rb +1 -1
- data/lib/finapps/rest/client.rb +12 -8
- data/lib/finapps/rest/consumers.rb +22 -6
- data/lib/finapps/rest/consumers_portfolios.rb +1 -1
- data/lib/finapps/rest/documents_orders.rb +105 -0
- data/lib/finapps/rest/documents_orders_notifications.rb +14 -0
- data/lib/finapps/rest/esign_templates.rb +11 -0
- data/lib/finapps/rest/operators.rb +5 -5
- data/lib/finapps/rest/operators_password_resets.rb +1 -1
- data/lib/finapps/rest/order_assignments.rb +1 -1
- data/lib/finapps/rest/order_reports.rb +1 -1
- data/lib/finapps/rest/orders.rb +10 -10
- data/lib/finapps/rest/plaid/plaid_consumer_institutions.rb +1 -1
- data/lib/finapps/rest/portfolio_reports.rb +1 -1
- data/lib/finapps/rest/portfolios.rb +1 -1
- data/lib/finapps/rest/portfolios_available_consumers.rb +1 -1
- data/lib/finapps/rest/portfolios_consumers.rb +1 -1
- data/lib/finapps/rest/sessions.rb +1 -1
- data/lib/finapps/rest/signed_documents_downloads.rb +17 -0
- data/lib/finapps/version.rb +1 -1
- data/spec/rest/alert_definitions_spec.rb +10 -2
- data/spec/rest/alert_occurrences_spec.rb +6 -1
- data/spec/rest/api_request.rb +1 -0
- data/spec/rest/client_spec.rb +2 -2
- data/spec/rest/consumers_portfolios_spec.rb +7 -2
- data/spec/rest/consumers_spec.rb +54 -7
- data/spec/rest/documents_orders_notifications_spec.rb +42 -0
- data/spec/rest/documents_orders_spec.rb +349 -0
- data/spec/rest/esign_templates_spec.rb +21 -0
- data/spec/rest/operators_password_resets_spec.rb +6 -1
- data/spec/rest/operators_spec.rb +22 -2
- data/spec/rest/order_assignments_spec.rb +6 -1
- data/spec/rest/order_notifications_spec.rb +3 -1
- data/spec/rest/order_refreshes_spec.rb +7 -1
- data/spec/rest/order_reports_spec.rb +7 -1
- data/spec/rest/order_statuses_spec.rb +7 -3
- data/spec/rest/order_tokens_spec.rb +7 -1
- data/spec/rest/orders_spec.rb +63 -29
- data/spec/rest/password_resets_spec.rb +20 -10
- data/spec/rest/plaid/plaid_account_permissions_spec.rb +5 -4
- data/spec/rest/plaid/plaid_accounts_spec.rb +9 -4
- data/spec/rest/plaid/plaid_consumer_institutions_spec.rb +10 -10
- data/spec/rest/plaid/plaid_institution_logos_spec.rb +1 -1
- data/spec/rest/plaid/plaid_webhooks_spec.rb +3 -1
- data/spec/rest/portfolio_reports_spec.rb +7 -2
- data/spec/rest/portfolios_alerts_spec.rb +6 -1
- data/spec/rest/portfolios_available_consumers_spec.rb +7 -2
- data/spec/rest/portfolios_consumers_spec.rb +13 -2
- data/spec/rest/portfolios_spec.rb +20 -5
- data/spec/rest/products_spec.rb +3 -1
- data/spec/rest/sessions_spec.rb +8 -4
- data/spec/rest/signed_documents_downloads_spec.rb +35 -0
- data/spec/rest/tenant_app_settings_spec.rb +9 -3
- data/spec/rest/tenant_settings_spec.rb +9 -3
- data/spec/rest/verix/verix_documents_spec.rb +13 -20
- data/spec/rest/verix/verix_metadata_spec.rb +1 -1
- data/spec/rest/verix/verix_pdf_documents_spec.rb +14 -19
- data/spec/rest/verix/verix_records_spec.rb +31 -10
- data/spec/rest/version_spec.rb +3 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/support/fake_api.rb +64 -1
- data/spec/support/fixtures/documents_order.json +75 -0
- data/spec/support/fixtures/documents_orders.json +32 -0
- data/spec/support/fixtures/documents_orders_none.json +6 -0
- data/spec/support/fixtures/esign_templates.json +6 -0
- data/spec/support/fixtures/invalid_order_id.json +5 -0
- data/spec/support/fixtures/invalid_signature_id.json +5 -0
- data/spec/support/fixtures/sign_url.json +4 -0
- data/spec/support/fixtures/signed_document.pdf +0 -0
- data/spec/utils/query_builder_spec.rb +40 -14
- metadata +81 -60
data/lib/finapps/version.rb
CHANGED
@@ -4,7 +4,7 @@ require 'spec_helpers/client'
|
|
4
4
|
|
5
5
|
RSpec.describe FinApps::REST::AlertDefinitions do
|
6
6
|
include SpecHelpers::Client
|
7
|
-
subject {
|
7
|
+
subject { described_class.new(client) }
|
8
8
|
|
9
9
|
describe '#list' do
|
10
10
|
let(:list) { subject.list(params) }
|
@@ -16,9 +16,11 @@ RSpec.describe FinApps::REST::AlertDefinitions do
|
|
16
16
|
|
17
17
|
it { expect { list }.not_to raise_error }
|
18
18
|
it('returns an array') { expect(list).to be_a(Array) }
|
19
|
+
|
19
20
|
it('performs a get and returns the response') do
|
20
21
|
expect(results).to have_key(:records)
|
21
22
|
end
|
23
|
+
|
22
24
|
it('returns no error messages') { expect(errors).to be_empty }
|
23
25
|
end
|
24
26
|
|
@@ -29,14 +31,17 @@ RSpec.describe FinApps::REST::AlertDefinitions do
|
|
29
31
|
end
|
30
32
|
|
31
33
|
context 'when including valid params' do
|
32
|
-
let(:params) { {
|
34
|
+
let(:params) { {page: 2, sort: '-created_date', requested: 25} }
|
33
35
|
|
34
36
|
it { expect { list }.not_to raise_error }
|
35
37
|
it('returns an array') { expect(list).to be_a(Array) }
|
38
|
+
|
36
39
|
it('performs a get and returns the response') do
|
37
40
|
expect(results).to have_key(:records)
|
38
41
|
end
|
42
|
+
|
39
43
|
it('returns no error messages') { expect(errors).to be_empty }
|
44
|
+
|
40
45
|
it 'builds query and sends proper request' do
|
41
46
|
list
|
42
47
|
url =
|
@@ -63,10 +68,12 @@ RSpec.describe FinApps::REST::AlertDefinitions do
|
|
63
68
|
|
64
69
|
it { expect { show }.not_to raise_error }
|
65
70
|
it('returns an array') { expect(show).to be_a(Array) }
|
71
|
+
|
66
72
|
it('performs a get and returns the response') do
|
67
73
|
expect(results).to have_key(:_id)
|
68
74
|
expect(results).to have_key(:rule_name)
|
69
75
|
end
|
76
|
+
|
70
77
|
it('returns no error messages') { expect(errors).to be_empty }
|
71
78
|
end
|
72
79
|
|
@@ -75,6 +82,7 @@ RSpec.describe FinApps::REST::AlertDefinitions do
|
|
75
82
|
|
76
83
|
it { expect { show }.not_to raise_error }
|
77
84
|
it('results is nil') { expect(results).to be_nil }
|
85
|
+
|
78
86
|
it('error messages array is populated') do
|
79
87
|
expect(errors.first.downcase).to eq('resource not found')
|
80
88
|
end
|
@@ -4,7 +4,7 @@ require 'spec_helpers/client'
|
|
4
4
|
|
5
5
|
RSpec.describe FinApps::REST::AlertOccurrences do
|
6
6
|
include SpecHelpers::Client
|
7
|
-
subject {
|
7
|
+
subject { described_class.new(client) }
|
8
8
|
|
9
9
|
describe '#list' do
|
10
10
|
let(:list) { subject.list(params) }
|
@@ -16,9 +16,11 @@ RSpec.describe FinApps::REST::AlertOccurrences do
|
|
16
16
|
|
17
17
|
it { expect { list }.not_to raise_error }
|
18
18
|
it('returns an array') { expect(list).to be_a(Array) }
|
19
|
+
|
19
20
|
it('performs a get and returns the response') do
|
20
21
|
expect(results).to have_key(:records)
|
21
22
|
end
|
23
|
+
|
22
24
|
it('returns no error messages') { expect(errors).to be_empty }
|
23
25
|
end
|
24
26
|
|
@@ -40,10 +42,13 @@ RSpec.describe FinApps::REST::AlertOccurrences do
|
|
40
42
|
|
41
43
|
it { expect { list }.not_to raise_error }
|
42
44
|
it('returns an array') { expect(list).to be_a(Array) }
|
45
|
+
|
43
46
|
it('performs a get and returns the response') do
|
44
47
|
expect(results).to have_key(:records)
|
45
48
|
end
|
49
|
+
|
46
50
|
it('returns no error messages') { expect(errors).to be_empty }
|
51
|
+
|
47
52
|
it 'builds query and sends proper request' do
|
48
53
|
list
|
49
54
|
url =
|
data/spec/rest/api_request.rb
CHANGED
data/spec/rest/client_spec.rb
CHANGED
@@ -3,14 +3,14 @@
|
|
3
3
|
RSpec.describe FinApps::REST::Client do
|
4
4
|
describe '#new' do
|
5
5
|
it 'raises for missing company_token' do
|
6
|
-
expect {
|
6
|
+
expect { described_class.new nil }.to raise_error(
|
7
7
|
FinAppsCore::MissingArgumentsError
|
8
8
|
)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
context 'an instance of Client' do
|
13
|
-
subject {
|
13
|
+
subject { described_class.new(:company_token) }
|
14
14
|
|
15
15
|
FinApps::REST::Client::RESOURCES.each do |method|
|
16
16
|
it("responds to #{method}") { expect(subject).to respond_to(method) }
|
@@ -4,7 +4,7 @@ require 'spec_helpers/client'
|
|
4
4
|
|
5
5
|
RSpec.describe FinApps::REST::ConsumersPortfolios do
|
6
6
|
include SpecHelpers::Client
|
7
|
-
subject {
|
7
|
+
subject { described_class.new(client) }
|
8
8
|
|
9
9
|
describe '#list' do
|
10
10
|
let(:list) { subject.list(id, params) }
|
@@ -24,9 +24,11 @@ RSpec.describe FinApps::REST::ConsumersPortfolios do
|
|
24
24
|
|
25
25
|
it { expect { list }.not_to raise_error }
|
26
26
|
it('returns an array') { expect(list).to be_a(Array) }
|
27
|
+
|
27
28
|
it('performs a get and returns the response') do
|
28
29
|
expect(results).to have_key(:records)
|
29
30
|
end
|
31
|
+
|
30
32
|
it('returns no error messages') { expect(errors).to be_empty }
|
31
33
|
end
|
32
34
|
|
@@ -39,14 +41,17 @@ RSpec.describe FinApps::REST::ConsumersPortfolios do
|
|
39
41
|
|
40
42
|
context 'when including valid params' do
|
41
43
|
let(:id) { 'valid_id' }
|
42
|
-
let(:params) { {
|
44
|
+
let(:params) { {page: 2, sort: '-created_date', requested: 25} }
|
43
45
|
|
44
46
|
it { expect { list }.not_to raise_error }
|
45
47
|
it('returns an array') { expect(list).to be_a(Array) }
|
48
|
+
|
46
49
|
it('performs a get and returns the response') do
|
47
50
|
expect(results).to have_key(:records)
|
48
51
|
end
|
52
|
+
|
49
53
|
it('returns no error messages') { expect(errors).to be_empty }
|
54
|
+
|
50
55
|
it 'builds query and sends proper request' do
|
51
56
|
list
|
52
57
|
url =
|
data/spec/rest/consumers_spec.rb
CHANGED
@@ -4,7 +4,8 @@ require 'spec_helpers/client'
|
|
4
4
|
RSpec.describe FinApps::REST::Consumers,
|
5
5
|
'initialized with valid FinApps::Client object' do
|
6
6
|
include SpecHelpers::Client
|
7
|
-
subject(:users) {
|
7
|
+
subject(:users) { described_class.new(client) }
|
8
|
+
|
8
9
|
missing_public_id = ': public_id'
|
9
10
|
|
10
11
|
describe '#create' do
|
@@ -24,9 +25,11 @@ RSpec.describe FinApps::REST::Consumers,
|
|
24
25
|
|
25
26
|
it { expect { create }.not_to raise_error }
|
26
27
|
it('results is a Hash') { expect(results).to be_a(Hash) }
|
28
|
+
|
27
29
|
it('performs a post and returns the response') do
|
28
30
|
expect(results).to have_key(:public_id)
|
29
31
|
end
|
32
|
+
|
30
33
|
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
31
34
|
end
|
32
35
|
|
@@ -35,6 +38,7 @@ RSpec.describe FinApps::REST::Consumers,
|
|
35
38
|
|
36
39
|
it { expect { create }.not_to raise_error }
|
37
40
|
it('results is nil') { expect(results).to be_nil }
|
41
|
+
|
38
42
|
it('error messages array is populated') do
|
39
43
|
expect(error_messages.first.downcase).to eq('invalid request body')
|
40
44
|
end
|
@@ -48,10 +52,13 @@ RSpec.describe FinApps::REST::Consumers,
|
|
48
52
|
|
49
53
|
context 'when missing params' do
|
50
54
|
let(:params) { nil }
|
51
|
-
|
55
|
+
|
56
|
+
it { expect { list }.not_to raise_error }
|
57
|
+
|
52
58
|
it('performs a get and returns the response') do
|
53
59
|
expect(results).to have_key(:records)
|
54
60
|
end
|
61
|
+
|
55
62
|
it('returns an array of records') { expect(results[:records]).to be_a(Array) }
|
56
63
|
it('returns no error messages') { expect(error_messages).to be_empty }
|
57
64
|
end
|
@@ -70,14 +77,17 @@ RSpec.describe FinApps::REST::Consumers,
|
|
70
77
|
}
|
71
78
|
end
|
72
79
|
|
73
|
-
it { expect { list }.
|
80
|
+
it { expect { list }.not_to raise_error }
|
74
81
|
it('returns an array') { expect(list).to be_a(Array) }
|
82
|
+
|
75
83
|
it('performs a get and returns the response') do
|
76
84
|
expect(results).to have_key(:records)
|
77
85
|
end
|
86
|
+
|
78
87
|
it('returns no error messages') do
|
79
88
|
expect(error_messages).to be_empty
|
80
89
|
end
|
90
|
+
|
81
91
|
it 'builds query and sends proper request' do
|
82
92
|
list
|
83
93
|
url = "#{versioned_api_path}/consumers?page=3&requested=19"
|
@@ -95,21 +105,49 @@ RSpec.describe FinApps::REST::Consumers,
|
|
95
105
|
}
|
96
106
|
end
|
97
107
|
|
98
|
-
it { expect { list }.
|
108
|
+
it { expect { list }.not_to raise_error }
|
99
109
|
it('returns an array') { expect(list).to be_a(Array) }
|
110
|
+
|
100
111
|
it('performs a get and returns the response') do
|
101
112
|
expect(results).to have_key(:records)
|
102
113
|
end
|
114
|
+
|
103
115
|
it('returns no error messages') do
|
104
116
|
expect(error_messages).to be_empty
|
105
117
|
end
|
118
|
+
|
106
119
|
it 'builds query and sends proper request' do
|
107
120
|
list
|
108
|
-
url = "#{versioned_api_path}/consumers?
|
109
|
-
|
110
|
-
|
121
|
+
url = "#{versioned_api_path}/consumers?"\
|
122
|
+
'filter=%7B%22$or%22:%5B%7B%22email%22:%22term%22%7D,' \
|
123
|
+
'%7B%22first_name%22:%22term%22%7D,'\
|
124
|
+
'%7B%22last_name%22:%22term%22%7D%5D%7D&page=2&requested=25' \
|
125
|
+
'&sort=date_created'
|
111
126
|
expect(WebMock).to have_requested(:get, url)
|
112
127
|
end
|
128
|
+
|
129
|
+
context 'when search term contains a space' do
|
130
|
+
let(:params) do
|
131
|
+
{
|
132
|
+
page: 2,
|
133
|
+
sort: 'date_created',
|
134
|
+
requested: 25,
|
135
|
+
searchTerm: 'Two terms'
|
136
|
+
}
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'treats space as start of a new query for first and last name' do
|
140
|
+
list
|
141
|
+
url = "#{versioned_api_path}/consumers?"\
|
142
|
+
'filter=%7B%22$or%22:%5B%7B%22email%22:%22Two%20terms%22%7D,'\
|
143
|
+
'%7B%22first_name%22:%22Two%20terms%22%7D,'\
|
144
|
+
'%7B%22last_name%22:%22Two%20terms%22%7D,%7B%22first_name%22:'\
|
145
|
+
'%22Two%22%7D,%7B%22last_name%22:%22Two%22%7D,'\
|
146
|
+
'%7B%22first_name%22:%22terms%22%7D,%7B%22last_name%22:'\
|
147
|
+
'%22terms%22%7D%5D%7D&page=2&requested=25&sort=date_created'
|
148
|
+
expect(WebMock).to have_requested(:get, url)
|
149
|
+
end
|
150
|
+
end
|
113
151
|
end
|
114
152
|
end
|
115
153
|
|
@@ -130,9 +168,11 @@ RSpec.describe FinApps::REST::Consumers,
|
|
130
168
|
|
131
169
|
it { expect { show }.not_to raise_error }
|
132
170
|
it('results is a Hash') { expect(results).to be_a(Hash) }
|
171
|
+
|
133
172
|
it('performs a get and returns the response') do
|
134
173
|
expect(results).to have_key(:public_id)
|
135
174
|
end
|
175
|
+
|
136
176
|
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
137
177
|
end
|
138
178
|
|
@@ -143,6 +183,7 @@ RSpec.describe FinApps::REST::Consumers,
|
|
143
183
|
|
144
184
|
it { expect { show }.not_to raise_error }
|
145
185
|
it('results is nil') { expect(results).to be_nil }
|
186
|
+
|
146
187
|
it('error messages array is populated') do
|
147
188
|
expect(error_messages.first.downcase).to eq('resource not found')
|
148
189
|
end
|
@@ -179,6 +220,7 @@ RSpec.describe FinApps::REST::Consumers,
|
|
179
220
|
|
180
221
|
it { expect { update }.not_to raise_error }
|
181
222
|
it('results is nil') { expect(results).to be_nil }
|
223
|
+
|
182
224
|
it('error messages array is populated') do
|
183
225
|
expect(error_messages.first.downcase).to eq(
|
184
226
|
'invalid user id specified.'
|
@@ -200,12 +242,15 @@ RSpec.describe FinApps::REST::Consumers,
|
|
200
242
|
|
201
243
|
it { expect { update }.not_to raise_error }
|
202
244
|
it('results is a Hash') { expect(results).to be_a(Hash) }
|
245
|
+
|
203
246
|
it('the public_id is on the results') do
|
204
247
|
expect(results).to have_key(:public_id)
|
205
248
|
end
|
249
|
+
|
206
250
|
it('the new token is on the results') do
|
207
251
|
expect(results).to have_key(:token)
|
208
252
|
end
|
253
|
+
|
209
254
|
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
210
255
|
end
|
211
256
|
|
@@ -221,6 +266,7 @@ RSpec.describe FinApps::REST::Consumers,
|
|
221
266
|
|
222
267
|
it { expect { update }.not_to raise_error }
|
223
268
|
it('results is nil') { expect(results).to be_nil }
|
269
|
+
|
224
270
|
it('error messages array is populated') do
|
225
271
|
expect(error_messages.first.downcase).to eq('resource not found')
|
226
272
|
end
|
@@ -254,6 +300,7 @@ RSpec.describe FinApps::REST::Consumers,
|
|
254
300
|
|
255
301
|
it { expect { destroy }.not_to raise_error }
|
256
302
|
it('results is nil') { expect(results).to be_nil }
|
303
|
+
|
257
304
|
it('error messages array is populated') do
|
258
305
|
expect(error_messages.first.downcase).to eq('resource not found')
|
259
306
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helpers/client'
|
4
|
+
|
5
|
+
RSpec.describe FinApps::REST::DocumentsOrdersNotifications do
|
6
|
+
include SpecHelpers::Client
|
7
|
+
|
8
|
+
describe '#create' do
|
9
|
+
subject(:notifications) { described_class.new(client) }
|
10
|
+
|
11
|
+
context 'when missing id' do
|
12
|
+
let(:create) { subject.create(nil) }
|
13
|
+
|
14
|
+
it('returns missing argument error') do
|
15
|
+
expect { create }.to raise_error(FinAppsCore::MissingArgumentsError)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when invalid id is provided' do
|
20
|
+
let(:create) { subject.create(:invalid_id) }
|
21
|
+
let(:results) { create[RESULTS] }
|
22
|
+
let(:error_messages) { create[ERROR_MESSAGES] }
|
23
|
+
|
24
|
+
it { expect { create }.not_to raise_error }
|
25
|
+
it('results is nil') { expect(results).to be_nil }
|
26
|
+
|
27
|
+
it('error messages array is populated') do
|
28
|
+
expect(error_messages.first.downcase).to eq('order id is invalid')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'for valid id' do
|
33
|
+
let(:create) { subject.create(:valid_id) }
|
34
|
+
let(:results) { create[RESULTS] }
|
35
|
+
let(:error_messages) { create[ERROR_MESSAGES] }
|
36
|
+
|
37
|
+
it { expect { create }.not_to raise_error }
|
38
|
+
it('results is nil') { expect(results).to be_nil }
|
39
|
+
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,349 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helpers/client'
|
4
|
+
require 'rest/api_request'
|
5
|
+
|
6
|
+
RSpec.describe FinApps::REST::DocumentsOrders do
|
7
|
+
include SpecHelpers::Client
|
8
|
+
|
9
|
+
RSpec.shared_examples 'a request that raises an error' do |_parameter|
|
10
|
+
it do
|
11
|
+
expect { subject }.to raise_error(
|
12
|
+
FinAppsCore::MissingArgumentsError
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#list' do
|
18
|
+
subject(:list) { described_class.new(client).list(params) }
|
19
|
+
|
20
|
+
let(:results) { list[0] }
|
21
|
+
let(:error_messages) { list[1] }
|
22
|
+
|
23
|
+
context 'with valid params' do
|
24
|
+
let(:params) do
|
25
|
+
{
|
26
|
+
page: 2,
|
27
|
+
sort: 'tag',
|
28
|
+
requested: 25,
|
29
|
+
searchTerm: 'term',
|
30
|
+
consumer: 'valid_consumer_id'
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'without searchTerm' do
|
35
|
+
let(:params) { {searchTerm: nil, page: 2} }
|
36
|
+
|
37
|
+
it_behaves_like 'an API request'
|
38
|
+
it_behaves_like 'a successful request'
|
39
|
+
it 'performs a get and returns the response' do
|
40
|
+
expect(results).to have_key(:records)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'builds query and sends proper request' do
|
44
|
+
list
|
45
|
+
url = "#{versioned_api_path}/documents/orders?page=2"
|
46
|
+
expect(WebMock).to have_requested(:get, url)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'with search term' do
|
51
|
+
it_behaves_like 'an API request'
|
52
|
+
it_behaves_like 'a successful request'
|
53
|
+
it 'performs a get and returns the response' do
|
54
|
+
expect(results).to have_key(:records)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'builds query and sends proper request' do
|
58
|
+
list
|
59
|
+
url =
|
60
|
+
"#{versioned_api_path}/documents/orders?"\
|
61
|
+
'filter=%7B%22$or%22:%5B%7B%22applicant.email%22:'\
|
62
|
+
'%22term%22%7D,%7B%22applicant.first_name%22:%22term%22%7D,'\
|
63
|
+
'%7B%22applicant.last_name%22:'\
|
64
|
+
'%22term%22%7D,%7B%22reference_no%22:%7B%22$regex%22:%22%5Eterm%22,'\
|
65
|
+
'%22$options%22:%22i%22%7D%7D%5D,'\
|
66
|
+
'%22consumer_id%22:%22valid_consumer_id%22%7D&'\
|
67
|
+
'page=2&requested=25&sort=tag '
|
68
|
+
|
69
|
+
expect(WebMock).to have_requested(:get, url)
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'with search term containing spaces' do
|
73
|
+
let(:params) { {"searchTerm": 'Blue Jay', "page": 2} }
|
74
|
+
|
75
|
+
it 'builds query and sends proper request' do
|
76
|
+
list
|
77
|
+
url =
|
78
|
+
"#{versioned_api_path}/documents/orders?"\
|
79
|
+
'filter=%7B%22$or%22:%5B%7B%22applicant.email%22:'\
|
80
|
+
'%22Blue%20Jay%22%7D,'\
|
81
|
+
'%7B%22applicant.first_name%22:%22Blue%20Jay%22%7D,'\
|
82
|
+
'%7B%22applicant.last_name%22:'\
|
83
|
+
'%22Blue%20Jay%22%7D,'\
|
84
|
+
'%7B%22reference_no%22:%7B%22$regex%22:%22%5EBlue%20Jay%22,'\
|
85
|
+
'%22$options%22:'\
|
86
|
+
'%22i%22%7D%7D,%7B%22applicant.first_name%22:%22Blue%22%7D,'\
|
87
|
+
'%7B%22applicant.last_name%22:%22Blue%22%7D,'\
|
88
|
+
'%7B%22applicant.first_name%22:%22Jay%22%7D,'\
|
89
|
+
'%7B%22applicant.last_name%22:%22Jay%22%7D%5D%7D&page=2'
|
90
|
+
|
91
|
+
expect(WebMock).to have_requested(:get, url)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'when filtering by open status ordes' do
|
97
|
+
let(:params) { {status: 1} }
|
98
|
+
|
99
|
+
it_behaves_like 'an API request'
|
100
|
+
it_behaves_like 'a successful request'
|
101
|
+
it { expect(subject.first[:records]).not_to be_empty }
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'when filtering by closed status ordes' do
|
105
|
+
let(:params) { {status: 2, searchTerm: 'term'} }
|
106
|
+
|
107
|
+
it_behaves_like 'an API request'
|
108
|
+
it_behaves_like 'a successful request'
|
109
|
+
it { expect(results[:records]).to be_empty }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'with invalid params' do
|
114
|
+
let(:params) { ['invalid array'] }
|
115
|
+
|
116
|
+
it { expect { list }.to raise_error(FinAppsCore::InvalidArgumentsError) }
|
117
|
+
end
|
118
|
+
|
119
|
+
context 'with missing params' do
|
120
|
+
let(:params) { nil }
|
121
|
+
|
122
|
+
it_behaves_like 'an API request'
|
123
|
+
it_behaves_like 'a successful request'
|
124
|
+
it('performs a get and returns the response') do
|
125
|
+
expect(results).to have_key(:records)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe '#show' do
|
131
|
+
subject(:show) { described_class.new(client).show(id) }
|
132
|
+
|
133
|
+
let(:results) { show[0] }
|
134
|
+
let(:error_messages) { show[1] }
|
135
|
+
|
136
|
+
context 'with valid id' do
|
137
|
+
let(:id) { :valid_order_id }
|
138
|
+
|
139
|
+
it_behaves_like 'an API request'
|
140
|
+
it_behaves_like 'a successful request'
|
141
|
+
it('results is a Hash') { expect(results).to be_a(Hash) }
|
142
|
+
|
143
|
+
it('performs a get and returns the response') do
|
144
|
+
expect(results).to have_key(:order_id)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
context 'with invalid id' do
|
149
|
+
let(:id) { :invalid_order_id }
|
150
|
+
|
151
|
+
it { expect(results).to be_nil }
|
152
|
+
it { expect(error_messages).not_to be_empty }
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'when missing id' do
|
156
|
+
let(:id) { nil }
|
157
|
+
|
158
|
+
it_behaves_like 'a request that raises an error'
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe '#create' do
|
163
|
+
subject(:create) { described_class.new(client).create(params) }
|
164
|
+
|
165
|
+
let(:results) { create[0] }
|
166
|
+
let(:error_messages) { create[1] }
|
167
|
+
|
168
|
+
context 'with valid params' do
|
169
|
+
let(:params) do
|
170
|
+
{
|
171
|
+
"applicant": {
|
172
|
+
"email": 'validemail@financialapps.com',
|
173
|
+
"first_name": 'Emily',
|
174
|
+
"last_name": 'Macs',
|
175
|
+
"role": 'patient'
|
176
|
+
},
|
177
|
+
"esign_documents": [
|
178
|
+
'temp-id'
|
179
|
+
],
|
180
|
+
"reference_no": 'REFNO',
|
181
|
+
"tag": 'new'
|
182
|
+
}
|
183
|
+
end
|
184
|
+
|
185
|
+
it_behaves_like 'an API request'
|
186
|
+
it_behaves_like 'a successful request'
|
187
|
+
it('results is a Hash') { expect(results).to be_a(Hash) }
|
188
|
+
|
189
|
+
it('performs a post and returns the response') do
|
190
|
+
expect(results).to have_key(:order_id)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
context 'with invalid params' do
|
195
|
+
let(:params) do
|
196
|
+
{
|
197
|
+
"applicant": {
|
198
|
+
"email": 'validemail@financialapps.com',
|
199
|
+
"first_name": 'Emily',
|
200
|
+
"last_name": 'Macs',
|
201
|
+
"role": 'patient'
|
202
|
+
},
|
203
|
+
"reference_no": 'REFNO'
|
204
|
+
}
|
205
|
+
end
|
206
|
+
|
207
|
+
it { expect { create }.not_to raise_error }
|
208
|
+
it('results is nil') { expect(results).to be_nil }
|
209
|
+
|
210
|
+
it('error messages array is populated') do
|
211
|
+
expect(error_messages.first.downcase).to eq('invalid request body')
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
context 'with missing params' do
|
216
|
+
let(:params) { nil }
|
217
|
+
|
218
|
+
it_behaves_like 'a request that raises an error'
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
describe '#update' do
|
223
|
+
subject(:update) { described_class.new(client).update(id, params) }
|
224
|
+
|
225
|
+
let(:params) { {} }
|
226
|
+
let(:results) { update[0] }
|
227
|
+
let(:error_messages) { update[1] }
|
228
|
+
|
229
|
+
context 'with valid id' do
|
230
|
+
let(:id) { :valid_order_id }
|
231
|
+
|
232
|
+
context 'with valid params' do
|
233
|
+
let(:params) { {"tag": 'pending'} }
|
234
|
+
|
235
|
+
it_behaves_like 'an API request'
|
236
|
+
it_behaves_like 'a successful request'
|
237
|
+
it('results is nil') { expect(results).to be_nil }
|
238
|
+
end
|
239
|
+
|
240
|
+
context 'with invalid params' do
|
241
|
+
let(:params) { {"tag": 'invalid'} }
|
242
|
+
|
243
|
+
it_behaves_like 'an API request'
|
244
|
+
it('results is nil') { expect(results).to be_nil }
|
245
|
+
|
246
|
+
it('error messages array is populated') do
|
247
|
+
expect(error_messages.first.downcase).to eq('invalid request body')
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
context 'with invalid id' do
|
253
|
+
let(:id) { :invalid_order_id }
|
254
|
+
let(:params) { {applicant: {first_name: 'Quasar'}} }
|
255
|
+
|
256
|
+
it_behaves_like 'an API request'
|
257
|
+
it('results is nil') { expect(results).to be_nil }
|
258
|
+
|
259
|
+
it('error messages array is populated') do
|
260
|
+
expect(error_messages.first.downcase).to eq(
|
261
|
+
'order id is invalid'
|
262
|
+
)
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
context 'with missing id' do
|
267
|
+
let(:id) { nil }
|
268
|
+
|
269
|
+
it_behaves_like 'a request that raises an error'
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
describe '#destroy' do
|
274
|
+
subject(:destroy) { described_class.new(client).destroy(id) }
|
275
|
+
|
276
|
+
let(:results) { destroy[0] }
|
277
|
+
let(:error_messages) { destroy[1] }
|
278
|
+
|
279
|
+
context 'with valid id' do
|
280
|
+
let(:id) { :valid_order_id }
|
281
|
+
|
282
|
+
it_behaves_like 'an API request'
|
283
|
+
it_behaves_like 'a successful request'
|
284
|
+
it('results is nil') { expect(results).to be_nil }
|
285
|
+
end
|
286
|
+
|
287
|
+
context 'with invalid id' do
|
288
|
+
let(:id) { :invalid_order_id }
|
289
|
+
|
290
|
+
it_behaves_like 'an API request'
|
291
|
+
it('results is nil') { expect(results).to be_nil }
|
292
|
+
|
293
|
+
it('error messages array is populated') do
|
294
|
+
expect(error_messages.first.downcase).to eq('resource not found')
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
context 'with missing id' do
|
299
|
+
let(:id) { nil }
|
300
|
+
|
301
|
+
it_behaves_like 'a request that raises an error'
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
describe '#show_signing_url' do
|
306
|
+
subject(:sign_url) { described_class.new(client).show_signing_url(order_id, signature_id) }
|
307
|
+
|
308
|
+
let(:results) { sign_url[0] }
|
309
|
+
let(:error_messages) { sign_url[1] }
|
310
|
+
let(:order_id) { :valid_order_id }
|
311
|
+
let(:signature_id) { :valid_signature_id }
|
312
|
+
|
313
|
+
context 'with valid order id' do
|
314
|
+
context 'with valid signature id' do
|
315
|
+
it_behaves_like 'an API request'
|
316
|
+
it_behaves_like 'a successful request'
|
317
|
+
it('performs a get and returns the response') do
|
318
|
+
expect(results).to have_key(:sign_url)
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
context 'with invalid signature id' do
|
323
|
+
let(:signature_id) { :invalid_signature_id }
|
324
|
+
|
325
|
+
it { expect(results).to be_nil }
|
326
|
+
it { expect(error_messages).not_to be_empty }
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
context 'with invalid order id' do
|
331
|
+
let(:order_id) { :invalid_order_id }
|
332
|
+
|
333
|
+
it { expect(results).to be_nil }
|
334
|
+
it { expect(error_messages).not_to be_empty }
|
335
|
+
end
|
336
|
+
|
337
|
+
context 'with missing order id' do
|
338
|
+
let(:order_id) { nil }
|
339
|
+
|
340
|
+
it_behaves_like 'a request that raises an error'
|
341
|
+
end
|
342
|
+
|
343
|
+
context 'with missing signature id' do
|
344
|
+
let(:signature_id) { nil }
|
345
|
+
|
346
|
+
it_behaves_like 'a request that raises an error'
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|