finapps 5.0.45 → 5.2.1
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/.github/dependabot.yml +7 -0
- data/.github/workflows/ci.yaml +47 -0
- data/.github/workflows/release.yml +42 -42
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/Guardfile +1 -1
- data/README.md +6 -4
- data/finapps.gemspec +8 -7
- data/lib/finapps.rb +1 -0
- data/lib/finapps/rest/client.rb +2 -1
- data/lib/finapps/rest/consumers.rb +5 -5
- data/lib/finapps/rest/documents_orders.rb +31 -13
- data/lib/finapps/rest/operators.rb +3 -3
- data/lib/finapps/rest/orders.rb +6 -6
- data/lib/finapps/rest/screenings.rb +71 -0
- data/lib/finapps/version.rb +1 -1
- data/spec/rest/api_request.rb +8 -0
- data/spec/rest/documents_orders_spec.rb +49 -46
- data/spec/rest/screenings_spec.rb +251 -0
- data/spec/support/fake_api.rb +12 -0
- data/spec/support/fixtures/documents/retrieve_order.json +97 -0
- data/spec/support/fixtures/screening.json +26 -0
- data/spec/support/fixtures/screening_invalid_update.json +5 -0
- data/spec/support/fixtures/screening_list.json +25 -0
- data/spec/support/fixtures/screenings/last_session.json +13 -0
- data/spec/support/fixtures/screenings/session_not_found_with_id.json +5 -0
- data/spec/support/fixtures/session_not_found.json +5 -0
- data/spec/support/screenings_routes.rb +72 -0
- metadata +109 -76
- data/.github/workflows/main.yaml +0 -38
data/lib/finapps/version.rb
CHANGED
data/spec/rest/api_request.rb
CHANGED
@@ -16,3 +16,11 @@ RSpec.shared_examples 'a successful request' do |_parameter|
|
|
16
16
|
expect(subject[ERROR_MESSAGES]).to be_empty
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
RSpec.shared_examples 'a request that raises an error' do |_parameter|
|
21
|
+
it do
|
22
|
+
expect { subject }.to raise_error(
|
23
|
+
FinAppsCore::MissingArgumentsError
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -6,14 +6,6 @@ require 'rest/api_request'
|
|
6
6
|
RSpec.describe FinApps::REST::DocumentsOrders do
|
7
7
|
include SpecHelpers::Client
|
8
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
9
|
describe '#list' do
|
18
10
|
subject(:list) { described_class.new(client).list(params) }
|
19
11
|
|
@@ -60,33 +52,30 @@ RSpec.describe FinApps::REST::DocumentsOrders do
|
|
60
52
|
"#{versioned_api_path}/documents/orders?"\
|
61
53
|
'filter=%7B%22$or%22:%5B%7B%22applicant.email%22:'\
|
62
54
|
'%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
|
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 '
|
55
|
+
'%7B%22applicant.last_name%22:%22term%22%7D,'\
|
56
|
+
'%7B%22applicant.external_id%22:%22term%22%7D,%7B%22reference_no%22:'\
|
57
|
+
'%7B%22$regex%22:%22%5Eterm%22,%22$options%22:%22i%22%7D%7D%5D,'\
|
58
|
+
'%22consumer_id%22:%22valid_consumer_id%22%7D&page=2&requested=25&sort=tag'
|
68
59
|
|
69
60
|
expect(WebMock).to have_requested(:get, url)
|
70
61
|
end
|
71
62
|
|
72
63
|
context 'with search term containing spaces' do
|
73
|
-
let(:params) { {
|
64
|
+
let(:params) { {searchTerm: 'Blue Jay', page: 2} }
|
74
65
|
|
75
66
|
it 'builds query and sends proper request' do
|
76
67
|
list
|
77
68
|
url =
|
78
69
|
"#{versioned_api_path}/documents/orders?"\
|
79
70
|
'filter=%7B%22$or%22:%5B%7B%22applicant.email%22:'\
|
80
|
-
'%22Blue%20Jay%22%7D
|
81
|
-
'%
|
82
|
-
'%7B%22applicant.
|
83
|
-
'%22Blue%20Jay%22%7D
|
84
|
-
'%
|
85
|
-
'%22
|
86
|
-
'%
|
87
|
-
'%7B%22applicant.last_name%22:%
|
88
|
-
'%7B%22applicant.first_name%22:%22Jay%22%7D,'\
|
89
|
-
'%7B%22applicant.last_name%22:%22Jay%22%7D%5D%7D&page=2'
|
71
|
+
'%22Blue%20Jay%22%7D,%7B%22applicant.first_name%22:'\
|
72
|
+
'%22Blue%20Jay%22%7D,%7B%22applicant.last_name%22:'\
|
73
|
+
'%22Blue%20Jay%22%7D,%7B%22applicant.external_id%22:'\
|
74
|
+
'%22Blue%20Jay%22%7D,%7B%22reference_no%22:%7B%22$regex%22:'\
|
75
|
+
'%22%5EBlue%20Jay%22,%22$options%22:%22i%22%7D%7D,'\
|
76
|
+
'%7B%22applicant.first_name%22:%22Blue%22%7D,%7B%22'\
|
77
|
+
'applicant.last_name%22:%22Blue%22%7D,%7B%22applicant.first_name%22:'\
|
78
|
+
'%22Jay%22%7D,%7B%22applicant.last_name%22:%22Jay%22%7D%5D%7D&page=2'
|
90
79
|
|
91
80
|
expect(WebMock).to have_requested(:get, url)
|
92
81
|
end
|
@@ -134,14 +123,28 @@ RSpec.describe FinApps::REST::DocumentsOrders do
|
|
134
123
|
let(:error_messages) { show[1] }
|
135
124
|
|
136
125
|
context 'with valid id' do
|
137
|
-
|
126
|
+
context 'when id is an identifier' do
|
127
|
+
let(:id) { :valid_order_id }
|
138
128
|
|
139
|
-
|
140
|
-
|
141
|
-
|
129
|
+
it_behaves_like 'an API request'
|
130
|
+
it_behaves_like 'a successful request'
|
131
|
+
it('has an order_id node in the response') do
|
132
|
+
expect(results).to have_key(:order_id)
|
133
|
+
end
|
134
|
+
end
|
142
135
|
|
143
|
-
|
144
|
-
|
136
|
+
context 'when id is a token' do
|
137
|
+
let(:id) { '0123456abc.0123456abc.0123456abc' }
|
138
|
+
|
139
|
+
it_behaves_like 'an API request'
|
140
|
+
it_behaves_like 'a successful request'
|
141
|
+
it('has an order node in the response') do
|
142
|
+
expect(results).to have_key(:order)
|
143
|
+
end
|
144
|
+
|
145
|
+
it('has a consumer node in the response') do
|
146
|
+
expect(results).to have_key(:consumer)
|
147
|
+
end
|
145
148
|
end
|
146
149
|
end
|
147
150
|
|
@@ -168,17 +171,17 @@ RSpec.describe FinApps::REST::DocumentsOrders do
|
|
168
171
|
context 'with valid params' do
|
169
172
|
let(:params) do
|
170
173
|
{
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
174
|
+
applicant: {
|
175
|
+
email: 'validemail@financialapps.com',
|
176
|
+
first_name: 'Emily',
|
177
|
+
last_name: 'Macs',
|
178
|
+
role: 'patient'
|
176
179
|
},
|
177
|
-
|
180
|
+
esign_documents: [
|
178
181
|
'temp-id'
|
179
182
|
],
|
180
|
-
|
181
|
-
|
183
|
+
reference_no: 'REFNO',
|
184
|
+
tag: 'new'
|
182
185
|
}
|
183
186
|
end
|
184
187
|
|
@@ -194,13 +197,13 @@ RSpec.describe FinApps::REST::DocumentsOrders do
|
|
194
197
|
context 'with invalid params' do
|
195
198
|
let(:params) do
|
196
199
|
{
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
200
|
+
applicant: {
|
201
|
+
email: 'validemail@financialapps.com',
|
202
|
+
first_name: 'Emily',
|
203
|
+
last_name: 'Macs',
|
204
|
+
role: 'patient'
|
202
205
|
},
|
203
|
-
|
206
|
+
reference_no: 'REFNO'
|
204
207
|
}
|
205
208
|
end
|
206
209
|
|
@@ -230,7 +233,7 @@ RSpec.describe FinApps::REST::DocumentsOrders do
|
|
230
233
|
let(:id) { :valid_order_id }
|
231
234
|
|
232
235
|
context 'with valid params' do
|
233
|
-
let(:params) { {
|
236
|
+
let(:params) { {tag: 'pending'} }
|
234
237
|
|
235
238
|
it_behaves_like 'an API request'
|
236
239
|
it_behaves_like 'a successful request'
|
@@ -238,7 +241,7 @@ RSpec.describe FinApps::REST::DocumentsOrders do
|
|
238
241
|
end
|
239
242
|
|
240
243
|
context 'with invalid params' do
|
241
|
-
let(:params) { {
|
244
|
+
let(:params) { {tag: 'invalid'} }
|
242
245
|
|
243
246
|
it_behaves_like 'an API request'
|
244
247
|
it('results is nil') { expect(results).to be_nil }
|
@@ -0,0 +1,251 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helpers/client'
|
4
|
+
require 'rest/api_request'
|
5
|
+
|
6
|
+
RSpec.describe FinApps::REST::Screenings do
|
7
|
+
include SpecHelpers::Client
|
8
|
+
|
9
|
+
let(:results) { subject[0] }
|
10
|
+
let(:error_messages) { subject[1] }
|
11
|
+
|
12
|
+
describe '#list' do
|
13
|
+
subject(:list) { described_class.new(client).list(params) }
|
14
|
+
|
15
|
+
context 'with valid params' do
|
16
|
+
let(:params) do
|
17
|
+
{
|
18
|
+
page: 2,
|
19
|
+
sort: 'date_created',
|
20
|
+
requested: 25,
|
21
|
+
searchTerm: 'term'
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'without searchTerm' do
|
26
|
+
let(:params) { {searchTerm: nil, page: 2} }
|
27
|
+
|
28
|
+
it_behaves_like 'an API request'
|
29
|
+
it_behaves_like 'a successful request'
|
30
|
+
it 'performs a get and returns the response' do
|
31
|
+
expect(results).to have_key(:records)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'builds query and sends proper request' do
|
35
|
+
list
|
36
|
+
url = "#{versioned_api_path}/screenings?page=2"
|
37
|
+
expect(WebMock).to have_requested(:get, url)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# rubocop:disable RSpec/ExampleLength
|
42
|
+
context 'with searchTerm' do
|
43
|
+
it_behaves_like 'an API request'
|
44
|
+
it_behaves_like 'a successful request'
|
45
|
+
it 'performs a get and returns the response' do
|
46
|
+
expect(results).to have_key(:records)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'builds query and sends proper request' do
|
50
|
+
list
|
51
|
+
url =
|
52
|
+
"#{versioned_api_path}/screenings?filter=%7B%22$or%22:%5B%7B%22" \
|
53
|
+
'consumer.public_id%22:%22term%22%7D,%7B%22consumer.email%22:%22' \
|
54
|
+
'term%22%7D%5D%7D&page=2&requested=25&sort=date_created'
|
55
|
+
|
56
|
+
expect(WebMock).to have_requested(:get, url)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
# rubocop:enable RSpec/ExampleLength
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'with invalid params' do
|
63
|
+
let(:params) { ['invalid array'] }
|
64
|
+
|
65
|
+
it { expect { list }.to raise_error(FinAppsCore::InvalidArgumentsError) }
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'with missing params' do
|
69
|
+
let(:params) { nil }
|
70
|
+
|
71
|
+
it_behaves_like 'an API request'
|
72
|
+
it_behaves_like 'a successful request'
|
73
|
+
it('performs a get and returns the response') do
|
74
|
+
expect(results).to have_key(:records)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#show' do
|
80
|
+
subject(:show) { described_class.new(client).show(id) }
|
81
|
+
|
82
|
+
context 'with valid id' do
|
83
|
+
let(:id) { :valid_id }
|
84
|
+
|
85
|
+
it_behaves_like 'an API request'
|
86
|
+
it_behaves_like 'a successful request'
|
87
|
+
it('performs a get and returns the response') do
|
88
|
+
expect(results).to have_key(:session)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'with invalid id' do
|
93
|
+
let(:id) { :invalid_id }
|
94
|
+
|
95
|
+
it { expect(results).to be_nil }
|
96
|
+
it { expect(error_messages).not_to be_empty }
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'when missing id' do
|
100
|
+
let(:id) { nil }
|
101
|
+
|
102
|
+
it_behaves_like 'a request that raises an error'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe '#last' do
|
107
|
+
subject(:last) { described_class.new(client).last(consumer_id) }
|
108
|
+
|
109
|
+
context 'with valid consumer_id' do
|
110
|
+
let(:consumer_id) { :valid_consumer_id }
|
111
|
+
|
112
|
+
it_behaves_like 'an API request'
|
113
|
+
it_behaves_like 'a successful request'
|
114
|
+
it('results have an :s_id node') do
|
115
|
+
expect(results).to have_key(:s_id)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context 'with invalid consumer_id' do
|
120
|
+
let(:consumer_id) { :invalid_consumer_id }
|
121
|
+
|
122
|
+
it { expect(results).to be_nil }
|
123
|
+
it { expect(error_messages).not_to be_empty }
|
124
|
+
end
|
125
|
+
|
126
|
+
context 'when missing consumer_id' do
|
127
|
+
let(:consumer_id) { nil }
|
128
|
+
|
129
|
+
it_behaves_like 'a request that raises an error'
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe '#create' do
|
134
|
+
subject(:create) { described_class.new(client).create(params) }
|
135
|
+
|
136
|
+
context 'with valid params' do
|
137
|
+
let(:params) do
|
138
|
+
{
|
139
|
+
email: 'validemail@financialapps.com',
|
140
|
+
first_name: 'Geo',
|
141
|
+
last_name: 'Metric',
|
142
|
+
public_id: '1234'
|
143
|
+
}
|
144
|
+
end
|
145
|
+
|
146
|
+
it_behaves_like 'an API request'
|
147
|
+
it_behaves_like 'a successful request'
|
148
|
+
it('results is a Hash') { expect(results).to be_a(Hash) }
|
149
|
+
|
150
|
+
it('performs a post and returns the response') do
|
151
|
+
expect(results).to have_key(:question)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'with invalid params' do
|
156
|
+
let(:params) { {params: 'invalid'} }
|
157
|
+
|
158
|
+
it { expect { create }.not_to raise_error }
|
159
|
+
it('results is nil') { expect(results).to be_nil }
|
160
|
+
|
161
|
+
it('error messages array is populated') do
|
162
|
+
expect(error_messages.first.downcase).to eq('invalid request body')
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
context 'with missing params' do
|
167
|
+
let(:params) { nil }
|
168
|
+
|
169
|
+
it_behaves_like 'a request that raises an error'
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe '#update' do
|
174
|
+
subject(:update) { described_class.new(client).update(id, params) }
|
175
|
+
|
176
|
+
let(:params) { {} }
|
177
|
+
|
178
|
+
context 'with valid session id' do
|
179
|
+
let(:id) { :valid_id }
|
180
|
+
|
181
|
+
context 'with valid params' do
|
182
|
+
let(:params) { {question_id: '1234'} }
|
183
|
+
|
184
|
+
it_behaves_like 'an API request'
|
185
|
+
it_behaves_like 'a successful request'
|
186
|
+
it('returns the next question') do
|
187
|
+
expect(results).to have_key(:question)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
context 'with invalid params' do
|
192
|
+
let(:params) { {question_id: 'invalid'} }
|
193
|
+
|
194
|
+
it_behaves_like 'an API request'
|
195
|
+
it('results is nil') { expect(results).to be_nil }
|
196
|
+
|
197
|
+
it('error messages array is populated') do
|
198
|
+
expect(error_messages.first.downcase).to eq('question with id (invalid) not found ')
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
context 'with invalid session id' do
|
204
|
+
let(:id) { :invalid_id }
|
205
|
+
let(:params) { {question_id: '1234'} }
|
206
|
+
|
207
|
+
it_behaves_like 'an API request'
|
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(
|
212
|
+
'resource not found'
|
213
|
+
)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
describe '#destroy' do
|
219
|
+
subject(:destroy) { described_class.new(client).destroy(id) }
|
220
|
+
|
221
|
+
context 'with valid session id' do
|
222
|
+
let(:id) { :valid_id }
|
223
|
+
|
224
|
+
it_behaves_like 'an API request'
|
225
|
+
it_behaves_like 'a successful request'
|
226
|
+
it('results is nil') { expect(results).to be_nil }
|
227
|
+
it('error_messages is empty') { expect(error_messages).to be_empty }
|
228
|
+
end
|
229
|
+
|
230
|
+
context 'when missing session id' do
|
231
|
+
let(:id) { nil }
|
232
|
+
|
233
|
+
it_behaves_like 'a request that raises an error'
|
234
|
+
end
|
235
|
+
|
236
|
+
context 'with invalid session id' do
|
237
|
+
let(:id) { :invalid_id }
|
238
|
+
|
239
|
+
it_behaves_like 'an API request'
|
240
|
+
it('results is nil') { expect(results).to be_nil }
|
241
|
+
|
242
|
+
it('error_messages is not empty') do
|
243
|
+
expect(error_messages).not_to be_empty
|
244
|
+
end
|
245
|
+
|
246
|
+
it('error messages array is populated') do
|
247
|
+
expect(error_messages.first.downcase).to eq('session not found')
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
data/spec/support/fake_api.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'sinatra/base'
|
4
4
|
require_relative 'documents_uploads_routes'
|
5
|
+
require_relative 'screenings_routes'
|
6
|
+
|
5
7
|
module Fake
|
6
8
|
# the FakeApi class is used to mock API requests while testing.
|
7
9
|
class FakeApi < Sinatra::Base
|
@@ -214,6 +216,9 @@ module Fake
|
|
214
216
|
get("/#{version}/documents/orders/valid_order_id") do
|
215
217
|
json_response 200, 'documents_order.json'
|
216
218
|
end
|
219
|
+
get("/#{version}/documents/retrieve_order") do
|
220
|
+
json_response 200, 'documents/retrieve_order.json'
|
221
|
+
end
|
217
222
|
get("/#{version}/documents/orders/invalid_order_id") do
|
218
223
|
json_response 404, 'resource_not_found.json'
|
219
224
|
end
|
@@ -272,6 +277,9 @@ module Fake
|
|
272
277
|
# document_upload_types
|
273
278
|
get("/#{version}/documents/upload_types") { json_response 200, 'upload_types.json' }
|
274
279
|
|
280
|
+
# screenings
|
281
|
+
include ScreeningsRoutes
|
282
|
+
|
275
283
|
# consumers
|
276
284
|
get("/#{version}/consumers") do
|
277
285
|
json_response 200, 'users.json'
|
@@ -494,6 +502,10 @@ module Fake
|
|
494
502
|
|
495
503
|
private
|
496
504
|
|
505
|
+
def resource_not_found
|
506
|
+
json_response 404, 'resource_not_found.json'
|
507
|
+
end
|
508
|
+
|
497
509
|
def json_response(response_code, file_name)
|
498
510
|
http_response :json, response_code, file_name
|
499
511
|
end
|