finapps 5.0.27 → 5.0.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +2 -1
  3. data/RELEASES.md +49 -0
  4. data/lib/finapps.rb +6 -1
  5. data/lib/finapps/rest/client.rb +14 -8
  6. data/lib/finapps/rest/consumers.rb +21 -5
  7. data/lib/finapps/rest/documents_orders.rb +104 -0
  8. data/lib/finapps/rest/documents_orders_notifications.rb +14 -0
  9. data/lib/finapps/rest/esign_templates.rb +11 -0
  10. data/lib/finapps/rest/signed_documents_downloads.rb +15 -0
  11. data/lib/finapps/rest/verix/verix_documents.rb +21 -0
  12. data/lib/finapps/rest/verix/verix_pdf_documents.rb +15 -0
  13. data/lib/finapps/version.rb +1 -1
  14. data/spec/rest/consumers_spec.rb +19 -0
  15. data/spec/rest/documents_orders_notifications_spec.rb +40 -0
  16. data/spec/rest/documents_orders_spec.rb +287 -0
  17. data/spec/rest/esign_templates_spec.rb +20 -0
  18. data/spec/rest/signed_documents_downloads_spec.rb +35 -0
  19. data/spec/rest/verix/verix_documents_spec.rb +52 -0
  20. data/spec/rest/verix/verix_pdf_documents_spec.rb +35 -0
  21. data/spec/rest/verix/verix_records_spec.rb +3 -14
  22. data/spec/support/fake_api.rb +74 -8
  23. data/spec/support/fixtures/documents_order.json +75 -0
  24. data/spec/support/fixtures/documents_orders.json +32 -0
  25. data/spec/support/fixtures/esign_templates.json +6 -0
  26. data/spec/support/fixtures/invalid_order_id.json +5 -0
  27. data/spec/support/fixtures/invalid_signature_id.json +5 -0
  28. data/spec/support/fixtures/sign_url.json +4 -0
  29. data/spec/support/fixtures/signed_document.pdf +0 -0
  30. data/spec/support/fixtures/verix/document/document.pdf +0 -0
  31. data/spec/support/fixtures/verix/document/list.json +36 -0
  32. data/spec/support/fixtures/verix/document/show.json +35 -0
  33. data/spec/support/fixtures/verix/record/create.json +25 -17
  34. data/spec/support/fixtures/verix/record/list.json +121 -45
  35. metadata +78 -54
  36. data/lib/finapps/rest/statements.rb +0 -16
  37. data/spec/rest/statements_spec.rb +0 -42
  38. data/spec/support/fixtures/fake_pdf_statement.json +0 -3
@@ -0,0 +1,287 @@
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) { FinApps::REST::DocumentsOrders.new(client).list(params) }
19
+ let(:results) { list[0] }
20
+ let(:error_messages) { list[1] }
21
+
22
+ context 'with valid params' do
23
+ let(:params) do
24
+ {
25
+ page: 2,
26
+ sort: 'tag',
27
+ requested: 25,
28
+ searchTerm: 'term',
29
+ consumer: 'valid_consumer_id'
30
+ }
31
+ end
32
+
33
+ context 'without searchTerm' do
34
+ let(:params) { { "searchTerm": nil, "page": 2 } }
35
+ it_behaves_like 'an API request'
36
+ it_behaves_like 'a successful request'
37
+ it 'performs a get and returns the response' do
38
+ expect(results).to have_key(:records)
39
+ end
40
+ it 'builds query and sends proper request' do
41
+ list
42
+ url = "#{versioned_api_path}/documents/orders?page=2"
43
+ expect(WebMock).to have_requested(:get, url)
44
+ end
45
+ end
46
+
47
+ context 'with search term' do
48
+ it_behaves_like 'an API request'
49
+ it_behaves_like 'a successful request'
50
+ it 'performs a get and returns the response' do
51
+ expect(results).to have_key(:records)
52
+ end
53
+ it 'builds query and sends proper request' do
54
+ list
55
+ url =
56
+ "#{versioned_api_path}/documents/orders?filter=%7B%22$or%22:%5B%7B%22applicant.email%22:"\
57
+ '%22term%22%7D,%7B%22applicant.first_name%22:%22term%22%7D,%7B%22applicant.last_name%22:'\
58
+ '%22term%22%7D,%7B%22reference_no%22:%7B%22$regex%22:%22%5Eterm%22,%22$options%22:%22i%22%7D%7D%5D,'\
59
+ '%22consumer_id%22:%22valid_consumer_id%22%7D&page=2&requested=25&sort=tag '
60
+
61
+ expect(WebMock).to have_requested(:get, url)
62
+ end
63
+
64
+ context 'with search term containing spaces' do
65
+ let(:params) { { "searchTerm": 'Blue Jay', "page": 2 } }
66
+ it 'builds query and sends proper request' do
67
+ list
68
+ url =
69
+ "#{versioned_api_path}/documents/orders?filter=%7B%22$or%22:%5B%7B%22applicant.email%22:"\
70
+ '%22Blue%20Jay%22%7D,%7B%22applicant.first_name%22:%22Blue%20Jay%22%7D,%7B%22applicant.last_name%22:'\
71
+ '%22Blue%20Jay%22%7D,%7B%22reference_no%22:%7B%22$regex%22:%22%5EBlue%20Jay%22,%22$options%22:'\
72
+ '%22i%22%7D%7D,%7B%22applicant.first_name%22:%22Blue%22%7D,%7B%22applicant.last_name%22:%22Blue%22%7D,'\
73
+ '%7B%22applicant.first_name%22:%22Jay%22%7D,%7B%22applicant.last_name%22:%22Jay%22%7D%5D%7D&page=2'
74
+
75
+ expect(WebMock).to have_requested(:get, url)
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ context 'with invalid params' do
82
+ let(:params) { ['invalid array'] }
83
+ it { expect { list }.to raise_error(FinAppsCore::InvalidArgumentsError) }
84
+ end
85
+
86
+ context 'with missing params' do
87
+ let(:params) { nil }
88
+ it_behaves_like 'an API request'
89
+ it_behaves_like 'a successful request'
90
+ it('performs a get and returns the response') do
91
+ expect(results).to have_key(:records)
92
+ end
93
+ end
94
+ end
95
+
96
+ describe '#show' do
97
+ subject(:show) { FinApps::REST::DocumentsOrders.new(client).show(id) }
98
+ let(:results) { show[0] }
99
+ let(:error_messages) { show[1] }
100
+
101
+ context 'with valid id' do
102
+ let(:id) { :valid_order_id }
103
+ it_behaves_like 'an API request'
104
+ it_behaves_like 'a successful request'
105
+ it('results is a Hash') { expect(results).to be_a(Hash) }
106
+ it('performs a get and returns the response') do
107
+ expect(results).to have_key(:order_id)
108
+ end
109
+ end
110
+
111
+ context 'with invalid id' do
112
+ let(:id) { :invalid_order_id }
113
+ it { expect(results).to be_nil }
114
+ it { expect(error_messages).to_not be_empty }
115
+ end
116
+
117
+ context 'when missing id' do
118
+ let(:id) { nil }
119
+ it_behaves_like 'a request that raises an error'
120
+ end
121
+ end
122
+
123
+ describe '#create' do
124
+ subject(:create) { FinApps::REST::DocumentsOrders.new(client).create(params) }
125
+ let(:results) { create[0] }
126
+ let(:error_messages) { create[1] }
127
+
128
+ context 'with valid params' do
129
+ let(:params) do
130
+ {
131
+ "applicant": {
132
+ "email": 'validemail@financialapps.com',
133
+ "first_name": 'Emily',
134
+ "last_name": 'Macs',
135
+ "role": 'patient'
136
+ },
137
+ "esign_documents": [
138
+ 'temp-id'
139
+ ],
140
+ "reference_no": 'REFNO',
141
+ "tag": 'new'
142
+ }
143
+ end
144
+ it_behaves_like 'an API request'
145
+ it_behaves_like 'a successful request'
146
+ it('results is a Hash') { expect(results).to be_a(Hash) }
147
+ it('performs a post and returns the response') do
148
+ expect(results).to have_key(:order_id)
149
+ end
150
+ end
151
+
152
+ context 'with invalid params' do
153
+ let(:params) do
154
+ {
155
+ "applicant": {
156
+ "email": 'validemail@financialapps.com',
157
+ "first_name": 'Emily',
158
+ "last_name": 'Macs',
159
+ "role": 'patient'
160
+ },
161
+ "reference_no": 'REFNO'
162
+ }
163
+ end
164
+ it { expect { create }.not_to raise_error }
165
+ it('results is nil') { expect(results).to be_nil }
166
+ it('error messages array is populated') do
167
+ expect(error_messages.first.downcase).to eq('invalid request body')
168
+ end
169
+ end
170
+
171
+ context 'with missing params' do
172
+ let(:params) { nil }
173
+ it_behaves_like 'a request that raises an error'
174
+ end
175
+ end
176
+
177
+ describe '#update' do
178
+ subject(:update) { FinApps::REST::DocumentsOrders.new(client).update(id, params) }
179
+ let(:params) { {} }
180
+ let(:results) { update[0] }
181
+ let(:error_messages) { update[1] }
182
+
183
+ context 'with valid id' do
184
+ let(:id) { :valid_order_id }
185
+
186
+ context 'with valid params' do
187
+ let(:params) { { "tag": 'pending' } }
188
+ it_behaves_like 'an API request'
189
+ it_behaves_like 'a successful request'
190
+ it('results is nil') { expect(results).to be_nil }
191
+ end
192
+
193
+ context 'with invalid params' do
194
+ let(:params) { { "tag": 'invalid' } }
195
+ it_behaves_like 'an API request'
196
+ it('results is nil') { expect(results).to be_nil }
197
+ it('error messages array is populated') do
198
+ expect(error_messages.first.downcase).to eq('invalid request body')
199
+ end
200
+ end
201
+ end
202
+
203
+ context 'with invalid id' do
204
+ let(:id) { :invalid_order_id }
205
+ let(:params) { { applicant: { first_name: 'Quasar' } } }
206
+ it_behaves_like 'an API request'
207
+ it('results is nil') { expect(results).to be_nil }
208
+ it('error messages array is populated') do
209
+ expect(error_messages.first.downcase).to eq(
210
+ 'order id is invalid'
211
+ )
212
+ end
213
+ end
214
+
215
+ context 'with missing id' do
216
+ let(:id) { nil }
217
+ it_behaves_like 'a request that raises an error'
218
+ end
219
+ end
220
+
221
+ describe '#destroy' do
222
+ subject(:destroy) { FinApps::REST::DocumentsOrders.new(client).destroy(id) }
223
+ let(:results) { destroy[0] }
224
+ let(:error_messages) { destroy[1] }
225
+
226
+ context 'with valid id' do
227
+ let(:id) { :valid_order_id }
228
+ it_behaves_like 'an API request'
229
+ it_behaves_like 'a successful request'
230
+ it('results is nil') { expect(results).to be_nil }
231
+ end
232
+
233
+ context 'with invalid id' do
234
+ let(:id) { :invalid_order_id }
235
+ it_behaves_like 'an API request'
236
+ it('results is nil') { expect(results).to be_nil }
237
+ it('error messages array is populated') do
238
+ expect(error_messages.first.downcase).to eq('resource not found')
239
+ end
240
+ end
241
+
242
+ context 'with missing id' do
243
+ let(:id) { nil }
244
+ it_behaves_like 'a request that raises an error'
245
+ end
246
+ end
247
+
248
+ describe '#show_signing_url' do
249
+ subject(:sign_url) { FinApps::REST::DocumentsOrders.new(client).show_signing_url(order_id, signature_id) }
250
+ let(:results) { sign_url[0] }
251
+ let(:error_messages) { sign_url[1] }
252
+ let(:order_id) { :valid_order_id }
253
+ let(:signature_id) { :valid_signature_id }
254
+
255
+ context 'with valid order id' do
256
+ context 'with valid signature id' do
257
+ it_behaves_like 'an API request'
258
+ it_behaves_like 'a successful request'
259
+ it('performs a get and returns the response') do
260
+ expect(results).to have_key(:sign_url)
261
+ end
262
+ end
263
+
264
+ context 'with invalid signature id' do
265
+ let(:signature_id) { :invalid_signature_id }
266
+ it { expect(results).to be_nil }
267
+ it { expect(error_messages).to_not be_empty }
268
+ end
269
+ end
270
+
271
+ context 'with invalid order id' do
272
+ let(:order_id) { :invalid_order_id }
273
+ it { expect(results).to be_nil }
274
+ it { expect(error_messages).to_not be_empty }
275
+ end
276
+
277
+ context 'with missing order id' do
278
+ let(:order_id) { nil }
279
+ it_behaves_like 'a request that raises an error'
280
+ end
281
+
282
+ context 'with missing signature id' do
283
+ let(:signature_id) { nil }
284
+ it_behaves_like 'a request that raises an error'
285
+ end
286
+ end
287
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helpers/client'
4
+ require 'rest/api_request'
5
+
6
+ RSpec.describe FinApps::REST::EsignTemplates do
7
+ include SpecHelpers::Client
8
+ subject(:templates) { FinApps::REST::EsignTemplates.new(client).list }
9
+ let(:results) { templates[0] }
10
+
11
+ describe '#list' do
12
+ context 'when called' do
13
+ it_behaves_like 'an API request'
14
+ it_behaves_like 'a successful request'
15
+ it('performs a get and returns the response') do
16
+ expect(results[0]).to have_key(:template_id)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helpers/client'
4
+ require 'rest/api_request'
5
+
6
+ RSpec.describe FinApps::REST::SignedDocumentsDownloads do
7
+ include SpecHelpers::Client
8
+
9
+ let(:api_client) { client }
10
+ let(:document) { FinApps::REST::SignedDocumentsDownloads.new(api_client) }
11
+
12
+ describe '#show' do
13
+ context 'when missing parameters' do
14
+ subject { document.show(nil, :signature_request_id) }
15
+ it 'raises an error when missing consumer id' do
16
+ expect { subject }.to raise_error(FinAppsCore::MissingArgumentsError)
17
+ end
18
+
19
+ subject { document.show(:consumer_id, nil) }
20
+ it 'raises an error when missing signature request id' do
21
+ expect { subject }.to raise_error(FinAppsCore::MissingArgumentsError)
22
+ end
23
+ end
24
+
25
+ subject(:show) do
26
+ document.show(
27
+ :consumer_id,
28
+ :signature_request_id
29
+ )
30
+ end
31
+
32
+ it_behaves_like 'an API request'
33
+ it_behaves_like 'a successful request'
34
+ end
35
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helpers/client'
4
+ require 'rest/api_request'
5
+
6
+ RSpec.describe FinApps::REST::VerixDocuments do
7
+ include SpecHelpers::Client
8
+
9
+ let(:api_client) { client }
10
+ let(:document) { FinApps::REST::VerixDocuments.new(api_client) }
11
+
12
+ describe '#list' do
13
+ context 'when missing parameters' do
14
+ subject { document.list(nil) }
15
+ it 'raises an error when missing record id' do
16
+ expect { subject }.to raise_error(FinAppsCore::MissingArgumentsError)
17
+ end
18
+ end
19
+
20
+ subject(:list) do
21
+ document.list(
22
+ :record_id
23
+ )
24
+ end
25
+ it_behaves_like 'an API request'
26
+ it_behaves_like 'a successful request'
27
+ end
28
+
29
+ describe '#show' do
30
+ context 'when missing parameters' do
31
+ subject { document.show(nil, :document_id) }
32
+ it 'raises an error when missing record id' do
33
+ expect { subject }.to raise_error(FinAppsCore::MissingArgumentsError)
34
+ end
35
+
36
+ subject { document.show(:record_id, nil) }
37
+ it 'raises an error when missing document id' do
38
+ expect { subject }.to raise_error(FinAppsCore::MissingArgumentsError)
39
+ end
40
+ end
41
+
42
+ subject(:show) do
43
+ document.show(
44
+ :record_id,
45
+ :document_id
46
+ )
47
+ end
48
+
49
+ it_behaves_like 'an API request'
50
+ it_behaves_like 'a successful request'
51
+ end
52
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helpers/client'
4
+ require 'rest/api_request'
5
+
6
+ RSpec.describe FinApps::REST::VerixPdfDocuments do
7
+ include SpecHelpers::Client
8
+
9
+ let(:api_client) { client }
10
+ let(:document) { FinApps::REST::VerixPdfDocuments.new(api_client) }
11
+
12
+ describe '#show' do
13
+ context 'when missing parameters' do
14
+ subject { document.show(nil, :provider_id) }
15
+ it 'raises an error when missing record id' do
16
+ expect { subject }.to raise_error(FinAppsCore::MissingArgumentsError)
17
+ end
18
+
19
+ subject { document.show(:record_id, nil) }
20
+ it 'raises an error when missing provider id' do
21
+ expect { subject }.to raise_error(FinAppsCore::MissingArgumentsError)
22
+ end
23
+ end
24
+
25
+ subject(:show) do
26
+ document.show(
27
+ :record_id,
28
+ :provider_id
29
+ )
30
+ end
31
+
32
+ it_behaves_like 'an API request'
33
+ it_behaves_like 'a successful request'
34
+ end
35
+ end
@@ -12,10 +12,7 @@ RSpec.describe FinApps::REST::VerixRecords do
12
12
  describe '#create' do
13
13
  subject(:create) do
14
14
  FinApps::REST::VerixRecords.new(api_client).create(
15
- code: 'authcode',
16
- download: [
17
- 'form_1040'
18
- ]
15
+ code: 'authcode'
19
16
  )
20
17
  end
21
18
 
@@ -26,11 +23,7 @@ RSpec.describe FinApps::REST::VerixRecords do
26
23
  it('returns a status') { expect(create[RESULTS]).to have_key(:status) }
27
24
  it('returns an error node') { expect(create[RESULTS]).to have_key(:error) }
28
25
  it('returns a list of documents') { expect(create[RESULTS]).to have_key(:documents) }
29
- it('returns a document count') { expect(create[RESULTS][:documents].first).to have_key(:count) }
30
- it('returns a document date sycned node') { expect(create[RESULTS][:documents].first).to have_key(:date_synced) }
31
- it('returns a document id') { expect(create[RESULTS][:documents].first).to have_key(:document_id) }
32
- it('returns a document downloaded bool') { expect(create[RESULTS][:documents].first).to have_key(:downloaded) }
33
- it('returns a document type') { expect(create[RESULTS][:documents].first).to have_key(:type) }
26
+ it('returns a list of downloaded documents') { expect(create[RESULTS]).to have_key(:downloaded_documents) }
34
27
  end
35
28
 
36
29
  describe '#list' do
@@ -44,10 +37,6 @@ RSpec.describe FinApps::REST::VerixRecords do
44
37
  it('returns a consumer id') { expect(list[RESULTS].first).to have_key(:consumer_id) }
45
38
  it('returns an error node') { expect(list[RESULTS].first).to have_key(:error) }
46
39
  it('returns a list of documents') { expect(list[RESULTS].first).to have_key(:documents) }
47
- it('returns a document type') { expect(list[RESULTS].first[:documents].first).to have_key(:type) }
48
- it('returns a document id') { expect(list[RESULTS].first[:documents].first).to have_key(:document_id) }
49
- it('returns a document count') { expect(list[RESULTS].first[:documents].first).to have_key(:count) }
50
- it('returns a document downloaded bool') { expect(list[RESULTS].first[:documents].first).to have_key(:downloaded) }
51
- it('returns a document date_synced') { expect(list[RESULTS].first[:documents].first).to have_key(:date_synced) }
40
+ it('returns a list of downloaded documents') { expect(list[RESULTS].first).to have_key(:downloaded_documents) }
52
41
  end
53
42
  end