finapps 5.0.25 → 5.0.30
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/.codeclimate.yml +2 -1
- data/RELEASES.md +40 -0
- data/finapps.gemspec +1 -1
- data/lib/finapps.rb +6 -1
- data/lib/finapps/rest/client.rb +14 -8
- data/lib/finapps/rest/consumers.rb +3 -1
- data/lib/finapps/rest/documents_orders.rb +88 -0
- data/lib/finapps/rest/documents_orders_notifications.rb +14 -0
- data/lib/finapps/rest/esign_templates.rb +11 -0
- data/lib/finapps/rest/signed_documents_downloads.rb +15 -0
- data/lib/finapps/rest/verix/verix_documents.rb +21 -0
- data/lib/finapps/rest/verix/verix_pdf_documents.rb +15 -0
- data/lib/finapps/version.rb +1 -1
- data/spec/rest/consumers_spec.rb +24 -1
- data/spec/rest/documents_orders_notifications_spec.rb +40 -0
- data/spec/rest/documents_orders_spec.rb +272 -0
- data/spec/rest/esign_templates_spec.rb +20 -0
- data/spec/rest/signed_documents_downloads_spec.rb +35 -0
- data/spec/rest/verix/verix_documents_spec.rb +52 -0
- data/spec/rest/verix/verix_pdf_documents_spec.rb +35 -0
- data/spec/rest/verix/verix_records_spec.rb +3 -14
- data/spec/support/fake_api.rb +74 -8
- data/spec/support/fixtures/documents_order.json +75 -0
- data/spec/support/fixtures/documents_orders.json +32 -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/support/fixtures/verix/document/document.pdf +0 -0
- data/spec/support/fixtures/verix/document/list.json +36 -0
- data/spec/support/fixtures/verix/document/show.json +35 -0
- data/spec/support/fixtures/verix/record/create.json +25 -17
- data/spec/support/fixtures/verix/record/list.json +121 -45
- metadata +80 -56
- data/lib/finapps/rest/statements.rb +0 -16
- data/spec/rest/statements_spec.rb +0 -42
- data/spec/support/fixtures/fake_pdf_statement.json +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c74f2340d52ad3cd13dc2bdf8415e7cf89e48f0993dbb346456546910a69ba9
|
4
|
+
data.tar.gz: 3bdefc2032a2efa241d5cc72ab5d6b74fc44b568599f0054bf5477e473fab81f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cb6732ca1b8ba09cc84920ec7fdd086259cd339f012f72cf19c30387f877f3af1aa495bea47f019ee638e9a32eb3f76bbd0397e89b6e773e108da98e9bc8300
|
7
|
+
data.tar.gz: 5dedcdb78fa82b22011520031aae7aa55b1c6e35a7f5ccd55e16fdaa1c6d3b19bd4d17e300a00849d1768be6528b2396adff43ef96b6c6f060740af4315c857f
|
data/.codeclimate.yml
CHANGED
data/RELEASES.md
CHANGED
@@ -1,3 +1,43 @@
|
|
1
|
+
## [5.0.30] - 2020-05-28
|
2
|
+
|
3
|
+
### Added
|
4
|
+
* New esign endpoints ([#222][i222])
|
5
|
+
|
6
|
+
### Changed
|
7
|
+
* Search query for documents orders ([#221][i221])
|
8
|
+
|
9
|
+
[i221]: https://github.com/finapps/ruby-client/issues/221
|
10
|
+
[i222]: https://github.com/finapps/ruby-client/issues/222
|
11
|
+
|
12
|
+
[5.0.30]: https://github.com/finapps/ruby-client/compare/5.0.29...5.0.30
|
13
|
+
|
14
|
+
## [5.0.29] - 2020-05-08
|
15
|
+
|
16
|
+
### Added
|
17
|
+
* Document-orders endpoints ([#219][i219])
|
18
|
+
|
19
|
+
[i219]: https://github.com/finapps/ruby-client/issues/219
|
20
|
+
|
21
|
+
[5.0.29]: https://github.com/finapps/ruby-client/compare/5.0.28...5.0.29
|
22
|
+
|
23
|
+
## [5.0.28] - 2020-02-19
|
24
|
+
|
25
|
+
### Added
|
26
|
+
* Verix document endpoints ([#217][i217])
|
27
|
+
|
28
|
+
[i217]: https://github.com/finapps/ruby-client/issues/217
|
29
|
+
|
30
|
+
[5.0.28]: https://github.com/finapps/ruby-client/compare/5.0.27...5.0.28
|
31
|
+
|
32
|
+
## [5.0.27] - 2020-02-11
|
33
|
+
|
34
|
+
### Changed
|
35
|
+
* Update finapps-core gem ([#215][i215])
|
36
|
+
|
37
|
+
[i215]: https://github.com/finapps/ruby-client/issues/215
|
38
|
+
|
39
|
+
[5.0.27]: https://github.com/finapps/ruby-client/compare/5.0.26...5.0.27
|
40
|
+
|
1
41
|
## [5.0.23] - 2020-01-16
|
2
42
|
|
3
43
|
### Changed
|
data/finapps.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.test_files = Dir['spec/**/*.rb']
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
-
spec.add_runtime_dependency 'finapps_core', '~> 5.0', '>= 5.0.
|
23
|
+
spec.add_runtime_dependency 'finapps_core', '~> 5.0', '>= 5.0.7'
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 2.0', '>= 2.0.2'
|
26
26
|
spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0', '>= 1.0.9'
|
data/lib/finapps.rb
CHANGED
@@ -19,7 +19,6 @@ require 'finapps/rest/products'
|
|
19
19
|
require 'finapps/rest/order_assignments'
|
20
20
|
require 'finapps/rest/client'
|
21
21
|
require 'finapps/rest/order_refreshes'
|
22
|
-
require 'finapps/rest/statements'
|
23
22
|
require 'finapps/rest/tenant_settings'
|
24
23
|
require 'finapps/rest/tenant_app_settings'
|
25
24
|
require 'finapps/rest/portfolios'
|
@@ -30,6 +29,10 @@ require 'finapps/rest/portfolios_alerts'
|
|
30
29
|
require 'finapps/rest/portfolios_consumers'
|
31
30
|
require 'finapps/rest/consumers_portfolios'
|
32
31
|
require 'finapps/rest/portfolio_reports'
|
32
|
+
require 'finapps/rest/documents_orders'
|
33
|
+
require 'finapps/rest/esign_templates'
|
34
|
+
require 'finapps/rest/signed_documents_downloads'
|
35
|
+
require 'finapps/rest/documents_orders_notifications'
|
33
36
|
|
34
37
|
require 'finapps/rest/plaid/plaid_resources'
|
35
38
|
require 'finapps/rest/plaid/plaid_webhooks'
|
@@ -40,6 +43,8 @@ require 'finapps/rest/plaid/plaid_institution_logos'
|
|
40
43
|
|
41
44
|
require 'finapps/rest/verix/verix_metadata'
|
42
45
|
require 'finapps/rest/verix/verix_records'
|
46
|
+
require 'finapps/rest/verix/verix_pdf_documents'
|
47
|
+
require 'finapps/rest/verix/verix_documents'
|
43
48
|
|
44
49
|
require 'finapps/utils/query_builder'
|
45
50
|
require 'finapps/version' unless defined?(FinApps::VERSION)
|
data/lib/finapps/rest/client.rb
CHANGED
@@ -9,7 +9,11 @@ module FinApps
|
|
9
9
|
RESOURCES = %i[
|
10
10
|
alert_definitions
|
11
11
|
alert_occurrences
|
12
|
+
consumers
|
12
13
|
consumers_portfolios
|
14
|
+
documents_orders
|
15
|
+
documents_orders_notifications
|
16
|
+
esign_templates
|
13
17
|
orders
|
14
18
|
order_assignments
|
15
19
|
order_notifications
|
@@ -20,24 +24,26 @@ module FinApps
|
|
20
24
|
operators
|
21
25
|
operators_password_resets
|
22
26
|
password_resets
|
23
|
-
|
27
|
+
plaid_webhooks
|
28
|
+
plaid_consumer_institutions
|
29
|
+
plaid_accounts
|
30
|
+
plaid_account_permissions
|
31
|
+
plaid_institution_logos
|
24
32
|
portfolios
|
25
33
|
portfolios_alerts
|
26
34
|
portfolios_available_consumers
|
27
35
|
portfolios_consumers
|
28
36
|
portfolio_reports
|
37
|
+
products
|
29
38
|
sessions
|
30
|
-
|
39
|
+
signed_documents_downloads
|
31
40
|
tenant_settings
|
32
41
|
tenant_app_settings
|
33
|
-
version
|
34
|
-
plaid_webhooks
|
35
|
-
plaid_consumer_institutions
|
36
|
-
plaid_accounts
|
37
|
-
plaid_account_permissions
|
38
|
-
plaid_institution_logos
|
39
42
|
verix_metadata
|
40
43
|
verix_records
|
44
|
+
verix_pdf_documents
|
45
|
+
verix_documents
|
46
|
+
version
|
41
47
|
].freeze
|
42
48
|
|
43
49
|
# @param [String] tenant_token
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../utils/query_builder'
|
4
|
+
|
5
|
+
module FinApps
|
6
|
+
module REST
|
7
|
+
class DocumentsOrders < FinAppsCore::REST::Resources
|
8
|
+
include FinApps::Utils::QueryBuilder
|
9
|
+
|
10
|
+
def list(params = nil)
|
11
|
+
path = 'documents/orders'
|
12
|
+
return super(path) if params.nil?
|
13
|
+
raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
|
14
|
+
|
15
|
+
super build_query_path(path, params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def show(id)
|
19
|
+
not_blank(id, :order_id)
|
20
|
+
super(id, "documents/orders/#{id}")
|
21
|
+
end
|
22
|
+
|
23
|
+
def create(params)
|
24
|
+
not_blank(params, :params)
|
25
|
+
super(params, 'documents/orders')
|
26
|
+
end
|
27
|
+
|
28
|
+
def update(id, params = nil)
|
29
|
+
not_blank(id, :order_id)
|
30
|
+
not_blank(params, :params)
|
31
|
+
super(params, "documents/orders/#{id}")
|
32
|
+
end
|
33
|
+
|
34
|
+
def destroy(id)
|
35
|
+
not_blank(id, :order_id)
|
36
|
+
super(id, "documents/orders/#{id}")
|
37
|
+
end
|
38
|
+
|
39
|
+
def show_signing_url(order_id, signature_id)
|
40
|
+
not_blank(order_id, :order_id)
|
41
|
+
not_blank(signature_id, :signature_id)
|
42
|
+
path = "documents/orders/#{order_id}/sign_url/#{signature_id}"
|
43
|
+
send_request path, :get
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def build_filter(params)
|
49
|
+
search_query(params[:searchTerm]).merge(consumer_query(params[:consumer])).merge(tag_query(params[:tag]))
|
50
|
+
end
|
51
|
+
|
52
|
+
def search_query(term)
|
53
|
+
if term
|
54
|
+
{
|
55
|
+
"$or": [
|
56
|
+
{ "applicant.email": term },
|
57
|
+
{ "applicant.first_name": term },
|
58
|
+
{ "applicant.last_name": term },
|
59
|
+
{
|
60
|
+
"reference_no": {
|
61
|
+
"$regex": "^#{term}", "$options": 'i'
|
62
|
+
}
|
63
|
+
}
|
64
|
+
]
|
65
|
+
}
|
66
|
+
else
|
67
|
+
{}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def tag_query(tag)
|
72
|
+
if tag
|
73
|
+
{ "tag": tag.empty? ? nil : tag }
|
74
|
+
else
|
75
|
+
{}
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def consumer_query(consumer)
|
80
|
+
if consumer
|
81
|
+
{ "consumer_id": consumer.empty? ? nil : consumer }
|
82
|
+
else
|
83
|
+
{}
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FinApps
|
4
|
+
module REST
|
5
|
+
class DocumentsOrdersNotifications < FinAppsCore::REST::Resources
|
6
|
+
def create(id)
|
7
|
+
not_blank(id, :id)
|
8
|
+
|
9
|
+
path = "documents/orders/#{ERB::Util.url_encode(id)}/notify"
|
10
|
+
super nil, path
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FinApps
|
4
|
+
module REST
|
5
|
+
class SignedDocumentsDownloads < FinAppsCore::REST::Resources
|
6
|
+
def show(consumer_id, signature_request_id)
|
7
|
+
not_blank(consumer_id, :consumer_id)
|
8
|
+
not_blank(signature_request_id, :signature_request_id)
|
9
|
+
path =
|
10
|
+
"consumers/#{ERB::Util.url_encode(consumer_id)}/documents/#{ERB::Util.url_encode(signature_request_id)}"
|
11
|
+
super(nil, path)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FinApps
|
4
|
+
module REST
|
5
|
+
class VerixDocuments < FinAppsCore::REST::Resources
|
6
|
+
def list(record_id)
|
7
|
+
not_blank(record_id, :record_id)
|
8
|
+
path = "v/record/#{ERB::Util.url_encode(record_id)}/document"
|
9
|
+
super path
|
10
|
+
end
|
11
|
+
|
12
|
+
def show(record_id, document_id)
|
13
|
+
not_blank(record_id, :record_id)
|
14
|
+
not_blank(document_id, :document_id)
|
15
|
+
path =
|
16
|
+
"v/record/#{ERB::Util.url_encode(record_id)}/document/#{ERB::Util.url_encode(document_id)}"
|
17
|
+
super(nil, path)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FinApps
|
4
|
+
module REST
|
5
|
+
class VerixPdfDocuments < FinAppsCore::REST::Resources # :nodoc:
|
6
|
+
def show(record_id, provider_id)
|
7
|
+
not_blank(record_id, :record_id)
|
8
|
+
not_blank(provider_id, :provider_id)
|
9
|
+
path =
|
10
|
+
"v/record/#{ERB::Util.url_encode(record_id)}/file/#{ERB::Util.url_encode(provider_id)}"
|
11
|
+
super(nil, path)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/finapps/version.rb
CHANGED
data/spec/rest/consumers_spec.rb
CHANGED
@@ -62,7 +62,30 @@ RSpec.describe FinApps::REST::Consumers,
|
|
62
62
|
it { expect { list }.to raise_error(FinAppsCore::InvalidArgumentsError) }
|
63
63
|
end
|
64
64
|
|
65
|
-
context 'when including valid params' do
|
65
|
+
context 'when including valid params without searchTerm' do
|
66
|
+
let(:params) do
|
67
|
+
{
|
68
|
+
page: 3,
|
69
|
+
requested: 19
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
it { expect { list }.to_not raise_error }
|
74
|
+
it('returns an array') { expect(list).to be_a(Array) }
|
75
|
+
it('performs a get and returns the response') do
|
76
|
+
expect(results).to have_key(:records)
|
77
|
+
end
|
78
|
+
it('returns no error messages') do
|
79
|
+
expect(error_messages).to be_empty
|
80
|
+
end
|
81
|
+
it 'builds query and sends proper request' do
|
82
|
+
list
|
83
|
+
url = "#{versioned_api_path}/consumers?page=3&requested=19"
|
84
|
+
expect(WebMock).to have_requested(:get, url)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'when including valid params with searchTerm' do
|
66
89
|
let(:params) do
|
67
90
|
{
|
68
91
|
page: 2,
|
@@ -0,0 +1,40 @@
|
|
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) { FinApps::REST::DocumentsOrdersNotifications.new(client) }
|
10
|
+
|
11
|
+
context 'when missing id' do
|
12
|
+
let(:create) { subject.create(nil) }
|
13
|
+
it('returns missing argument error') do
|
14
|
+
expect { create }.to raise_error(FinAppsCore::MissingArgumentsError)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when invalid id is provided' do
|
19
|
+
let(:create) { subject.create(:invalid_id) }
|
20
|
+
let(:results) { create[RESULTS] }
|
21
|
+
let(:error_messages) { create[ERROR_MESSAGES] }
|
22
|
+
|
23
|
+
it { expect { create }.not_to raise_error }
|
24
|
+
it('results is nil') { expect(results).to be_nil }
|
25
|
+
it('error messages array is populated') do
|
26
|
+
expect(error_messages.first.downcase).to eq('order id is invalid')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'for valid id' do
|
31
|
+
let(:create) { subject.create(:valid_id) }
|
32
|
+
let(:results) { create[RESULTS] }
|
33
|
+
let(:error_messages) { create[ERROR_MESSAGES] }
|
34
|
+
|
35
|
+
it { expect { create }.not_to raise_error }
|
36
|
+
it('results is nil') { expect(results).to be_nil }
|
37
|
+
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,272 @@
|
|
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
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'with invalid params' do
|
67
|
+
let(:params) { ['invalid array'] }
|
68
|
+
it { expect { list }.to raise_error(FinAppsCore::InvalidArgumentsError) }
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'with missing params' do
|
72
|
+
let(:params) { nil }
|
73
|
+
it_behaves_like 'an API request'
|
74
|
+
it_behaves_like 'a successful request'
|
75
|
+
it('performs a get and returns the response') do
|
76
|
+
expect(results).to have_key(:records)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#show' do
|
82
|
+
subject(:show) { FinApps::REST::DocumentsOrders.new(client).show(id) }
|
83
|
+
let(:results) { show[0] }
|
84
|
+
let(:error_messages) { show[1] }
|
85
|
+
|
86
|
+
context 'with valid id' do
|
87
|
+
let(:id) { :valid_order_id }
|
88
|
+
it_behaves_like 'an API request'
|
89
|
+
it_behaves_like 'a successful request'
|
90
|
+
it('results is a Hash') { expect(results).to be_a(Hash) }
|
91
|
+
it('performs a get and returns the response') do
|
92
|
+
expect(results).to have_key(:order_id)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'with invalid id' do
|
97
|
+
let(:id) { :invalid_order_id }
|
98
|
+
it { expect(results).to be_nil }
|
99
|
+
it { expect(error_messages).to_not be_empty }
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'when missing id' do
|
103
|
+
let(:id) { nil }
|
104
|
+
it_behaves_like 'a request that raises an error'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe '#create' do
|
109
|
+
subject(:create) { FinApps::REST::DocumentsOrders.new(client).create(params) }
|
110
|
+
let(:results) { create[0] }
|
111
|
+
let(:error_messages) { create[1] }
|
112
|
+
|
113
|
+
context 'with valid params' do
|
114
|
+
let(:params) do
|
115
|
+
{
|
116
|
+
"applicant": {
|
117
|
+
"email": 'validemail@financialapps.com',
|
118
|
+
"first_name": 'Emily',
|
119
|
+
"last_name": 'Macs',
|
120
|
+
"role": 'patient'
|
121
|
+
},
|
122
|
+
"esign_documents": [
|
123
|
+
'temp-id'
|
124
|
+
],
|
125
|
+
"reference_no": 'REFNO',
|
126
|
+
"tag": 'new'
|
127
|
+
}
|
128
|
+
end
|
129
|
+
it_behaves_like 'an API request'
|
130
|
+
it_behaves_like 'a successful request'
|
131
|
+
it('results is a Hash') { expect(results).to be_a(Hash) }
|
132
|
+
it('performs a post and returns the response') do
|
133
|
+
expect(results).to have_key(:order_id)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context 'with invalid params' do
|
138
|
+
let(:params) do
|
139
|
+
{
|
140
|
+
"applicant": {
|
141
|
+
"email": 'validemail@financialapps.com',
|
142
|
+
"first_name": 'Emily',
|
143
|
+
"last_name": 'Macs',
|
144
|
+
"role": 'patient'
|
145
|
+
},
|
146
|
+
"reference_no": 'REFNO'
|
147
|
+
}
|
148
|
+
end
|
149
|
+
it { expect { create }.not_to raise_error }
|
150
|
+
it('results is nil') { expect(results).to be_nil }
|
151
|
+
it('error messages array is populated') do
|
152
|
+
expect(error_messages.first.downcase).to eq('invalid request body')
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
context 'with missing params' do
|
157
|
+
let(:params) { nil }
|
158
|
+
it_behaves_like 'a request that raises an error'
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe '#update' do
|
163
|
+
subject(:update) { FinApps::REST::DocumentsOrders.new(client).update(id, params) }
|
164
|
+
let(:params) { {} }
|
165
|
+
let(:results) { update[0] }
|
166
|
+
let(:error_messages) { update[1] }
|
167
|
+
|
168
|
+
context 'with valid id' do
|
169
|
+
let(:id) { :valid_order_id }
|
170
|
+
|
171
|
+
context 'with valid params' do
|
172
|
+
let(:params) { { "tag": 'pending' } }
|
173
|
+
it_behaves_like 'an API request'
|
174
|
+
it_behaves_like 'a successful request'
|
175
|
+
it('results is nil') { expect(results).to be_nil }
|
176
|
+
end
|
177
|
+
|
178
|
+
context 'with invalid params' do
|
179
|
+
let(:params) { { "tag": 'invalid' } }
|
180
|
+
it_behaves_like 'an API request'
|
181
|
+
it('results is nil') { expect(results).to be_nil }
|
182
|
+
it('error messages array is populated') do
|
183
|
+
expect(error_messages.first.downcase).to eq('invalid request body')
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
context 'with invalid id' do
|
189
|
+
let(:id) { :invalid_order_id }
|
190
|
+
let(:params) { { applicant: { first_name: 'Quasar' } } }
|
191
|
+
it_behaves_like 'an API request'
|
192
|
+
it('results is nil') { expect(results).to be_nil }
|
193
|
+
it('error messages array is populated') do
|
194
|
+
expect(error_messages.first.downcase).to eq(
|
195
|
+
'order id is invalid'
|
196
|
+
)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
context 'with missing id' do
|
201
|
+
let(:id) { nil }
|
202
|
+
it_behaves_like 'a request that raises an error'
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
describe '#destroy' do
|
207
|
+
subject(:destroy) { FinApps::REST::DocumentsOrders.new(client).destroy(id) }
|
208
|
+
let(:results) { destroy[0] }
|
209
|
+
let(:error_messages) { destroy[1] }
|
210
|
+
|
211
|
+
context 'with valid id' do
|
212
|
+
let(:id) { :valid_order_id }
|
213
|
+
it_behaves_like 'an API request'
|
214
|
+
it_behaves_like 'a successful request'
|
215
|
+
it('results is nil') { expect(results).to be_nil }
|
216
|
+
end
|
217
|
+
|
218
|
+
context 'with invalid id' do
|
219
|
+
let(:id) { :invalid_order_id }
|
220
|
+
it_behaves_like 'an API request'
|
221
|
+
it('results is nil') { expect(results).to be_nil }
|
222
|
+
it('error messages array is populated') do
|
223
|
+
expect(error_messages.first.downcase).to eq('resource not found')
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
context 'with missing id' do
|
228
|
+
let(:id) { nil }
|
229
|
+
it_behaves_like 'a request that raises an error'
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
describe '#show_signing_url' do
|
234
|
+
subject(:sign_url) { FinApps::REST::DocumentsOrders.new(client).show_signing_url(order_id, signature_id) }
|
235
|
+
let(:results) { sign_url[0] }
|
236
|
+
let(:error_messages) { sign_url[1] }
|
237
|
+
let(:order_id) { :valid_order_id }
|
238
|
+
let(:signature_id) { :valid_signature_id }
|
239
|
+
|
240
|
+
context 'with valid order id' do
|
241
|
+
context 'with valid signature id' do
|
242
|
+
it_behaves_like 'an API request'
|
243
|
+
it_behaves_like 'a successful request'
|
244
|
+
it('performs a get and returns the response') do
|
245
|
+
expect(results).to have_key(:sign_url)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
context 'with invalid signature id' do
|
250
|
+
let(:signature_id) { :invalid_signature_id }
|
251
|
+
it { expect(results).to be_nil }
|
252
|
+
it { expect(error_messages).to_not be_empty }
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
context 'with invalid order id' do
|
257
|
+
let(:order_id) { :invalid_order_id }
|
258
|
+
it { expect(results).to be_nil }
|
259
|
+
it { expect(error_messages).to_not be_empty }
|
260
|
+
end
|
261
|
+
|
262
|
+
context 'with missing order id' do
|
263
|
+
let(:order_id) { nil }
|
264
|
+
it_behaves_like 'a request that raises an error'
|
265
|
+
end
|
266
|
+
|
267
|
+
context 'with missing signature id' do
|
268
|
+
let(:signature_id) { nil }
|
269
|
+
it_behaves_like 'a request that raises an error'
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|