finapps 5.0.25 → 5.0.30

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +2 -1
  3. data/RELEASES.md +40 -0
  4. data/finapps.gemspec +1 -1
  5. data/lib/finapps.rb +6 -1
  6. data/lib/finapps/rest/client.rb +14 -8
  7. data/lib/finapps/rest/consumers.rb +3 -1
  8. data/lib/finapps/rest/documents_orders.rb +88 -0
  9. data/lib/finapps/rest/documents_orders_notifications.rb +14 -0
  10. data/lib/finapps/rest/esign_templates.rb +11 -0
  11. data/lib/finapps/rest/signed_documents_downloads.rb +15 -0
  12. data/lib/finapps/rest/verix/verix_documents.rb +21 -0
  13. data/lib/finapps/rest/verix/verix_pdf_documents.rb +15 -0
  14. data/lib/finapps/version.rb +1 -1
  15. data/spec/rest/consumers_spec.rb +24 -1
  16. data/spec/rest/documents_orders_notifications_spec.rb +40 -0
  17. data/spec/rest/documents_orders_spec.rb +272 -0
  18. data/spec/rest/esign_templates_spec.rb +20 -0
  19. data/spec/rest/signed_documents_downloads_spec.rb +35 -0
  20. data/spec/rest/verix/verix_documents_spec.rb +52 -0
  21. data/spec/rest/verix/verix_pdf_documents_spec.rb +35 -0
  22. data/spec/rest/verix/verix_records_spec.rb +3 -14
  23. data/spec/support/fake_api.rb +74 -8
  24. data/spec/support/fixtures/documents_order.json +75 -0
  25. data/spec/support/fixtures/documents_orders.json +32 -0
  26. data/spec/support/fixtures/esign_templates.json +6 -0
  27. data/spec/support/fixtures/invalid_order_id.json +5 -0
  28. data/spec/support/fixtures/invalid_signature_id.json +5 -0
  29. data/spec/support/fixtures/sign_url.json +4 -0
  30. data/spec/support/fixtures/signed_document.pdf +0 -0
  31. data/spec/support/fixtures/verix/document/document.pdf +0 -0
  32. data/spec/support/fixtures/verix/document/list.json +36 -0
  33. data/spec/support/fixtures/verix/document/show.json +35 -0
  34. data/spec/support/fixtures/verix/record/create.json +25 -17
  35. data/spec/support/fixtures/verix/record/list.json +121 -45
  36. metadata +80 -56
  37. data/lib/finapps/rest/statements.rb +0 -16
  38. data/spec/rest/statements_spec.rb +0 -42
  39. data/spec/support/fixtures/fake_pdf_statement.json +0 -3
@@ -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
@@ -28,6 +28,19 @@ class FakeApi < Sinatra::Base
28
28
  json_response 200, 'verix/record/create.json'
29
29
  end
30
30
 
31
+ # verix_pdf_documents
32
+ get("/#{version}/v/record/:record_id/file/:provider_id") do
33
+ pdf_response 'verix/document/document.pdf'
34
+ end
35
+
36
+ # verix_documents
37
+ get("/#{version}/v/record/:record_id/document") do
38
+ json_response 200, 'verix/document/show.json'
39
+ end
40
+ get("/#{version}/v/record/:record_id/document/:document_id") do
41
+ json_response 200, 'verix/document/list.json'
42
+ end
43
+
31
44
  # plaid_webhook/metadata
32
45
  get("/#{version}/p/metadata") do
33
46
  tenant_token = request.env['HTTP_X_TENANT_TOKEN']
@@ -189,6 +202,63 @@ class FakeApi < Sinatra::Base
189
202
  end
190
203
  end
191
204
 
205
+ # documents_orders
206
+ get("/#{version}/documents/orders") { json_response 200, 'documents_orders.json' }
207
+ get("/#{version}/documents/orders/valid_order_id") do
208
+ json_response 200, 'documents_order.json'
209
+ end
210
+ get("/#{version}/documents/orders/invalid_order_id") do
211
+ json_response 404, 'resource_not_found.json'
212
+ end
213
+ post("/#{version}/documents/orders") do
214
+ request.body.rewind
215
+ request_payload = JSON.parse request.body.read
216
+ if %w[applicant esign_documents tag].all? { |s| request_payload.key? s }
217
+ json_response 200, 'documents_order.json'
218
+ else
219
+ json_response 400, 'invalid_request_body.json'
220
+ end
221
+ end
222
+ put("/#{version}/documents/orders/valid_order_id") do
223
+ request.body.rewind
224
+ request_payload = JSON.parse request.body.read
225
+ if request_payload['tag'] == 'invalid'
226
+ json_response 400, 'invalid_request_body.json'
227
+ else
228
+ status 204
229
+ end
230
+ end
231
+ put("/#{version}/documents/orders/invalid_order_id") do
232
+ json_response 400, 'invalid_order_id.json'
233
+ end
234
+ delete("/#{version}/documents/orders/valid_order_id") { status 204 }
235
+ delete("/#{version}/documents/orders/invalid_order_id") do
236
+ json_response 404, 'resource_not_found.json'
237
+ end
238
+ get("/#{version}/documents/orders/valid_order_id/sign_url/valid_signature_id") do
239
+ json_response 200, 'sign_url.json'
240
+ end
241
+ get("/#{version}/documents/orders/invalid_order_id/sign_url/valid_signature_id") do
242
+ json_response 400, 'invalid_order_id.json'
243
+ end
244
+ get("/#{version}/documents/orders/valid_order_id/sign_url/invalid_signature_id") do
245
+ json_response 404, 'invalid_signature_id.json'
246
+ end
247
+
248
+ # documents orders notifications
249
+ post("/#{version}/documents/orders/valid_id/notify") { status 204 }
250
+ post("/#{version}/documents/orders/invalid_id/notify") do
251
+ json_response 400, 'invalid_order_id.json'
252
+ end
253
+
254
+ # signed documents downloads
255
+ get("/#{version}/consumers/:consumer_id/documents/:signature_request_id") do
256
+ pdf_response 'signed_document.pdf'
257
+ end
258
+
259
+ # esign_templates
260
+ get("/#{version}/esign_templates") { json_response 200, 'esign_templates.json' }
261
+
192
262
  # consumers
193
263
  get("/#{version}/consumers") do
194
264
  json_response 200, 'users.json'
@@ -224,14 +294,6 @@ class FakeApi < Sinatra::Base
224
294
  end
225
295
  post("/#{version}/logout") { status 204 }
226
296
 
227
- # accounts
228
- get("/#{version}/accounts/valid_id/statement/valid_id") do
229
- json_response 200, 'fake_pdf_statement.json'
230
- end
231
- get("/#{version}/accounts/invalid_id/statement/valid_id") do
232
- json_response 404, 'resource_not_found.json'
233
- end
234
-
235
297
  # operators
236
298
  get("/#{version}/operators") { json_response 200, 'operator_list.json' }
237
299
  get("/#{version}/operators/invalid_id") do
@@ -427,6 +489,10 @@ class FakeApi < Sinatra::Base
427
489
  http_response :png, 200, file_name
428
490
  end
429
491
 
492
+ def pdf_response(file_name)
493
+ http_response 'application/pdf', 200, file_name
494
+ end
495
+
430
496
  def http_response(content_type, response_code, file_name)
431
497
  content_type content_type
432
498
  status response_code
@@ -0,0 +1,75 @@
1
+ {
2
+ "order_id": "572c0ae0-bdb8-4e68-a5fd-8ac15870f2fe",
3
+ "consumer_id": "fc136a18-af0c-4d36-4743-1babb89cbbd0",
4
+ "applicant": {
5
+ "role": "patient",
6
+ "email": "validemail@financialapps.com",
7
+ "first_name": "Documents",
8
+ "last_name": "Testing"
9
+ },
10
+ "reference_no": "REFNO87687687",
11
+ "esign_documents": [
12
+ {
13
+ "document_id": "",
14
+ "template_id": "f6e9c513486c6a9468209a91ec14c25258eed515",
15
+ "name": "BH Form"
16
+ }
17
+ ],
18
+ "completed_documents": [],
19
+ "tag": "denied",
20
+ "status": 1,
21
+ "signature_requests": [
22
+ {
23
+ "signature_request_id": "b32f0073f7817f353199dcaab683d129a939e7be",
24
+ "test_mode": true,
25
+ "title": "Document for review",
26
+ "subject": "Document for review",
27
+ "message": "",
28
+ "created_at": 1588689298,
29
+ "is_complete": false,
30
+ "is_declined": false,
31
+ "has_error": false,
32
+ "signing_url": null,
33
+ "signing_redirect_url": null,
34
+ "details_url": "",
35
+ "files_url": "",
36
+ "cc_email_addresses": [],
37
+ "requester_email_address": "validemail@financialapps.com",
38
+ "custom_fields": [
39
+ {
40
+ "name": "PatientName",
41
+ "type": "text",
42
+ "value": "",
43
+ "required": true,
44
+ "editor": ""
45
+ }
46
+ ],
47
+ "response_data": [],
48
+ "signatures": [
49
+ {
50
+ "signature_id": "00b2bbdc50d4d6a6486965a921cb81f8",
51
+ "signer_email_address": "validemail@financialapps.com",
52
+ "signer_name": "Documents Testing",
53
+ "signer_role": "patient",
54
+ "order": null,
55
+ "status_code": "awaiting_signature",
56
+ "signed_at": null,
57
+ "last_viewed_at": null,
58
+ "last_reminded_at": null,
59
+ "has_pin": false,
60
+ "reassigned_by": null,
61
+ "reassignment_reason": null,
62
+ "error": null
63
+ }
64
+ ],
65
+ "metadata": {
66
+ "consumer_id": "fc136a18-af0c-4d36-4743-1babb89cbbd0",
67
+ "order_id": "572c0ae0-bdb8-4e68-a5fd-8ac15870f2fe",
68
+ "tenant_id": "4dd607b1-565f-4da4-722c-2e84c5c87f43"
69
+ }
70
+ }
71
+ ],
72
+ "reset_pwd": true,
73
+ "date_created": "2020-05-05T14:34:58.435Z",
74
+ "date_modified": "2020-05-07T14:38:08.271Z"
75
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "total_records": 1,
3
+ "page": 1,
4
+ "total_pages": 1,
5
+ "records": [
6
+ {
7
+ "order_id": "2f02be2c-0cbc-4980-bd8f-b2dee986c885",
8
+ "consumer_id": "6dadcf93-5305-4c4b-4136-465f9cd6d5e6",
9
+ "applicant": {
10
+ "role": "patient",
11
+ "email": "validemail@financialapps.com",
12
+ "first_name": "Documents",
13
+ "last_name": "Testing"
14
+ },
15
+ "reference_no": "REFNO87687687",
16
+ "esign_documents": [
17
+ {
18
+ "document_id": "",
19
+ "template_id": "f6e9c513486c6a9468209a91ec14c25258eed515",
20
+ "name": "BH Form"
21
+ }
22
+ ],
23
+ "completed_documents": [],
24
+ "tag": "approved",
25
+ "status": 1,
26
+ "signature_requests": null,
27
+ "reset_pwd": false,
28
+ "date_created": "2020-05-05T14:12:21.428Z",
29
+ "date_modified": null
30
+ }
31
+ ]
32
+ }
@@ -0,0 +1,6 @@
1
+ [
2
+ {
3
+ "template_id": "f6e9c513486c6a9468209a91ec14c25258eed515",
4
+ "name": "BH Form"
5
+ }
6
+ ]
@@ -0,0 +1,5 @@
1
+ {
2
+ "messages": [
3
+ "order id is invalid"
4
+ ]
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "messages": [
3
+ "signature id not found"
4
+ ]
5
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "sign_url": "https://sign_url.com",
3
+ "expires_at": 1588953702
4
+ }
@@ -0,0 +1,36 @@
1
+ [
2
+ {
3
+ "_id": "5e4c44a5b778c00001a81277",
4
+ "consumer_id": "1f50bddc-4cbf-4e16-6782-a2295d695d4e",
5
+ "date_synced": "2020-02-18T20:10:13.469Z",
6
+ "document": {
7
+ "form_type": "schedule_d",
8
+ "id": 34790,
9
+ "net_long_term_gain_loss": 1275,
10
+ "net_short_term_gain_loss": 2,
11
+ "tax_period_ends_at": "2017-12-31"
12
+ },
13
+ "document_id": "5e4c44a5b778c00001a81277",
14
+ "record_id": "5e4c44a46c20ec0001e3a505",
15
+ "tax_period_ends_at": "2017-12-31",
16
+ "tenant_id": "4dd607b1-565f-4da4-722c-2e84c5c87f43",
17
+ "type": "schedule_d"
18
+ },
19
+ {
20
+ "_id": "5e4c44a5b778c00001a81278",
21
+ "consumer_id": "1f50bddc-4cbf-4e16-6782-a2295d695d4e",
22
+ "date_synced": "2020-02-18T20:10:13.469Z",
23
+ "document": {
24
+ "form_type": "schedule_d",
25
+ "id": 34793,
26
+ "net_long_term_gain_loss": 5816,
27
+ "net_short_term_gain_loss": 0,
28
+ "tax_period_ends_at": "2018-12-31"
29
+ },
30
+ "document_id": "5e4c44a5b778c00001a81278",
31
+ "record_id": "5e4c44a46c20ec0001e3a505",
32
+ "tax_period_ends_at": "2018-12-31",
33
+ "tenant_id": "4dd607b1-565f-4da4-722c-2e84c5c87f43",
34
+ "type": "schedule_d"
35
+ }
36
+ ]