finapps 5.0.31 → 5.0.36
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yaml +37 -0
- data/.rubocop.yml +139 -59
- data/.rubocop_todo.yml +29 -0
- data/.tmuxinator.yml +1 -0
- data/.travis.yml +3 -1
- data/README.md +1 -0
- data/RELEASES.md +29 -0
- data/finapps.gemspec +4 -4
- data/lib/finapps.rb +2 -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 +8 -5
- data/lib/finapps/rest/consumers.rb +10 -5
- data/lib/finapps/rest/consumers_portfolios.rb +1 -1
- data/lib/finapps/rest/documents_orders.rb +30 -26
- data/lib/finapps/rest/documents_upload_types.rb +11 -0
- data/lib/finapps/rest/documents_uploads.rb +23 -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 +33 -22
- 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 +11 -9
- data/lib/finapps/rest/signed_documents_downloads.rb +3 -1
- data/lib/finapps/utils/query_builder.rb +13 -4
- data/lib/finapps/version.rb +1 -1
- data/spec/rest/alert_definitions_spec.rb +10 -6
- data/spec/rest/alert_occurrences_spec.rb +6 -1
- data/spec/rest/api_request.rb +1 -0
- data/spec/rest/client_spec.rb +33 -41
- data/spec/rest/consumers_portfolios_spec.rb +7 -2
- data/spec/rest/consumers_spec.rb +236 -207
- data/spec/rest/documents_orders_notifications_spec.rb +4 -2
- data/spec/rest/documents_orders_spec.rb +85 -23
- data/spec/rest/documents_upload_types_spec.rb +21 -0
- data/spec/rest/documents_uploads_spec.rb +104 -0
- data/spec/rest/esign_templates_spec.rb +2 -1
- data/spec/rest/operators_password_resets_spec.rb +50 -52
- data/spec/rest/operators_spec.rb +181 -172
- data/spec/rest/order_assignments_spec.rb +6 -1
- data/spec/rest/order_notifications_spec.rb +4 -2
- data/spec/rest/order_refreshes_spec.rb +8 -5
- data/spec/rest/order_reports_spec.rb +21 -15
- data/spec/rest/order_statuses_spec.rb +14 -10
- data/spec/rest/order_tokens_spec.rb +37 -30
- data/spec/rest/orders_spec.rb +121 -73
- data/spec/rest/password_resets_spec.rb +46 -36
- 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 +11 -11
- 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 +9 -4
- data/spec/rest/portfolios_available_consumers_spec.rb +7 -2
- data/spec/rest/portfolios_consumers_spec.rb +15 -4
- data/spec/rest/portfolios_spec.rb +20 -17
- data/spec/rest/products_spec.rb +17 -14
- data/spec/rest/sessions_spec.rb +63 -58
- data/spec/rest/signed_documents_downloads_spec.rb +10 -6
- 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 +15 -22
- 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 +6 -4
- data/spec/spec_helper.rb +2 -2
- data/spec/support/fake_api.rb +24 -3
- data/spec/support/fixtures/documents_orders_none.json +6 -0
- data/spec/support/fixtures/upload_types.json +9 -0
- data/spec/utils/query_builder_spec.rb +40 -14
- metadata +26 -16
@@ -15,7 +15,7 @@ module FinApps
|
|
15
15
|
|
16
16
|
def list(params = nil)
|
17
17
|
return super if params.nil?
|
18
|
-
|
18
|
+
fail FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
|
19
19
|
|
20
20
|
super build_query_path(end_point, params)
|
21
21
|
end
|
@@ -62,15 +62,20 @@ module FinApps
|
|
62
62
|
|
63
63
|
def with_space_search(term)
|
64
64
|
[
|
65
|
-
{
|
66
|
-
{
|
67
|
-
{
|
65
|
+
{"email": term},
|
66
|
+
{"first_name": term},
|
67
|
+
{"last_name": term}
|
68
68
|
]
|
69
69
|
end
|
70
70
|
|
71
71
|
def name_search(term)
|
72
72
|
search_arr = []
|
73
|
-
|
73
|
+
if /\s/.match?(term)
|
74
|
+
term.split.each do |t|
|
75
|
+
search_arr.append("first_name": t)
|
76
|
+
search_arr.append("last_name": t)
|
77
|
+
end
|
78
|
+
end
|
74
79
|
search_arr
|
75
80
|
end
|
76
81
|
end
|
@@ -11,7 +11,7 @@ module FinApps
|
|
11
11
|
path = "consumers/#{ERB::Util.url_encode(id)}/portfolios"
|
12
12
|
return super path if params.nil?
|
13
13
|
|
14
|
-
|
14
|
+
fail FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
|
15
15
|
|
16
16
|
super build_query_path(path, params)
|
17
17
|
end
|
@@ -10,7 +10,7 @@ module FinApps
|
|
10
10
|
def list(params = nil)
|
11
11
|
path = 'documents/orders'
|
12
12
|
return super(path) if params.nil?
|
13
|
-
|
13
|
+
fail FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
|
14
14
|
|
15
15
|
super build_query_path(path, params)
|
16
16
|
end
|
@@ -33,7 +33,7 @@ module FinApps
|
|
33
33
|
|
34
34
|
def destroy(id)
|
35
35
|
not_blank(id, :order_id)
|
36
|
-
super(
|
36
|
+
super(nil, "documents/orders/#{id}")
|
37
37
|
end
|
38
38
|
|
39
39
|
def show_signing_url(order_id, signature_id)
|
@@ -46,33 +46,35 @@ module FinApps
|
|
46
46
|
private
|
47
47
|
|
48
48
|
def build_filter(params)
|
49
|
-
search_query(params[:searchTerm])
|
49
|
+
search_query(params[:searchTerm])
|
50
|
+
.merge(consumer_query(params[:consumer]))
|
51
|
+
.merge(tag_query(params[:tag]))
|
52
|
+
.merge(status_query(params[:status]))
|
50
53
|
end
|
51
54
|
|
52
55
|
def search_query(term)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
}
|
58
|
-
else
|
59
|
-
{}
|
60
|
-
end
|
56
|
+
return {} unless term
|
57
|
+
|
58
|
+
query = with_space_search(term).concat(name_search(term))
|
59
|
+
{"$or": query}
|
61
60
|
end
|
62
61
|
|
63
62
|
def name_search(term)
|
64
63
|
search_arr = []
|
65
|
-
if
|
66
|
-
term.split.each
|
64
|
+
if /\s/.match?(term)
|
65
|
+
term.split.each do |t|
|
66
|
+
search_arr.append("applicant.first_name": t)
|
67
|
+
search_arr.append("applicant.last_name": t)
|
68
|
+
end
|
67
69
|
end
|
68
70
|
search_arr
|
69
71
|
end
|
70
72
|
|
71
73
|
def with_space_search(term)
|
72
74
|
[
|
73
|
-
{
|
74
|
-
{
|
75
|
-
{
|
75
|
+
{"applicant.email": term},
|
76
|
+
{"applicant.first_name": term},
|
77
|
+
{"applicant.last_name": term},
|
76
78
|
{
|
77
79
|
"reference_no": {
|
78
80
|
"$regex": "^#{term}", "$options": 'i'
|
@@ -82,19 +84,21 @@ module FinApps
|
|
82
84
|
end
|
83
85
|
|
84
86
|
def tag_query(tag)
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
return {} unless tag
|
88
|
+
|
89
|
+
{"tag": tag.empty? ? nil : tag}
|
90
|
+
end
|
91
|
+
|
92
|
+
def status_query(status)
|
93
|
+
return {} unless status
|
94
|
+
|
95
|
+
{status: status}
|
90
96
|
end
|
91
97
|
|
92
98
|
def consumer_query(consumer)
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
{}
|
97
|
-
end
|
99
|
+
return {} unless consumer
|
100
|
+
|
101
|
+
{"consumer_id": consumer.empty? ? nil : consumer}
|
98
102
|
end
|
99
103
|
end
|
100
104
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FinApps
|
4
|
+
module REST
|
5
|
+
class DocumentsUploads < FinAppsCore::REST::Resources
|
6
|
+
def show(consumer_id, doc_id, thumbnail = false)
|
7
|
+
not_blank(consumer_id, :consumer_id)
|
8
|
+
not_blank(doc_id, :doc_id)
|
9
|
+
|
10
|
+
path =
|
11
|
+
"consumers/#{ERB::Util.url_encode(consumer_id)}/"\
|
12
|
+
"documents/#{ERB::Util.url_encode(doc_id)}?thumbnail=#{thumbnail}"
|
13
|
+
super(nil, path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def destroy(order_id, doc_id)
|
17
|
+
not_blank(order_id, :order_id)
|
18
|
+
not_blank(doc_id, :doc_id)
|
19
|
+
super(nil, "documents/orders/#{order_id}/#{doc_id}")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -9,7 +9,7 @@ module FinApps
|
|
9
9
|
|
10
10
|
def list(params = nil)
|
11
11
|
return super if params.nil?
|
12
|
-
|
12
|
+
fail FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
|
13
13
|
|
14
14
|
super build_query_path(end_point, params)
|
15
15
|
end
|
@@ -36,7 +36,7 @@ module FinApps
|
|
36
36
|
def update_password(params)
|
37
37
|
# update password for current operator, need authorization session in header
|
38
38
|
not_blank(params, :params)
|
39
|
-
|
39
|
+
fail FinAppsCore::InvalidArgumentsError, 'Invalid argument: params.' unless validates params
|
40
40
|
|
41
41
|
path = "#{end_point}/password/change"
|
42
42
|
|
@@ -64,14 +64,14 @@ module FinApps
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def search_query(term)
|
67
|
-
{
|
67
|
+
{"last_name": term}
|
68
68
|
end
|
69
69
|
|
70
70
|
def role_query(role)
|
71
71
|
if role.is_a?(Array)
|
72
|
-
{
|
72
|
+
{"role": {"$in": role.map(&:to_i)}}
|
73
73
|
else
|
74
|
-
{
|
74
|
+
{"role": role.to_i}
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -22,7 +22,7 @@ module FinApps
|
|
22
22
|
private
|
23
23
|
|
24
24
|
def validates_email(params)
|
25
|
-
|
25
|
+
fail FinAppsCore::InvalidArgumentsError, 'Invalid argument: params.' unless email_exists? params
|
26
26
|
end
|
27
27
|
|
28
28
|
def email_exists?(params)
|
@@ -6,7 +6,7 @@ module FinApps
|
|
6
6
|
def update(id, orders_array)
|
7
7
|
not_blank(id, :operator_id)
|
8
8
|
not_blank(orders_array, :params)
|
9
|
-
|
9
|
+
fail FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless orders_array.is_a? Array
|
10
10
|
|
11
11
|
path = "operators/#{ERB::Util.url_encode(id)}/assign"
|
12
12
|
super orders_array, path
|
@@ -6,7 +6,7 @@ module FinApps
|
|
6
6
|
def show(id, format)
|
7
7
|
not_blank(id, :id)
|
8
8
|
not_blank(format, :format)
|
9
|
-
|
9
|
+
fail FinAppsCore::InvalidArgumentsError, 'Invalid argument: format' unless accepted_format?(format)
|
10
10
|
|
11
11
|
path =
|
12
12
|
"orders/#{ERB::Util.url_encode(id)}/report.#{ERB::Util.url_encode(format)}"
|
data/lib/finapps/rest/orders.rb
CHANGED
@@ -28,7 +28,7 @@ module FinApps
|
|
28
28
|
#
|
29
29
|
def list(params = nil)
|
30
30
|
return super if params.nil?
|
31
|
-
|
31
|
+
fail FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
|
32
32
|
|
33
33
|
super build_query_path(end_point, params)
|
34
34
|
end
|
@@ -63,30 +63,41 @@ module FinApps
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def search_query(term)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
else
|
80
|
-
{}
|
66
|
+
return {} unless term
|
67
|
+
|
68
|
+
query = search_query_object(term).concat(consumer_name_query(term))
|
69
|
+
{"$or": query}
|
70
|
+
end
|
71
|
+
|
72
|
+
def consumer_name_query(term)
|
73
|
+
search_arr = []
|
74
|
+
if /\s/.match?(term)
|
75
|
+
term.split.each do |t|
|
76
|
+
search_arr.append("applicant.first_name": t)
|
77
|
+
search_arr.append("applicant.last_name": t)
|
78
|
+
end
|
81
79
|
end
|
80
|
+
search_arr
|
81
|
+
end
|
82
|
+
|
83
|
+
def search_query_object(term)
|
84
|
+
[{"public_id": {"$regex": "^#{term}", "$options": 'i'}},
|
85
|
+
{"assignment.last_name": term},
|
86
|
+
{"applicant.first_name": term},
|
87
|
+
{"applicant.last_name": term},
|
88
|
+
{
|
89
|
+
"requestor.reference_no": {
|
90
|
+
"$regex": "^#{term}", "$options": 'i'
|
91
|
+
}
|
92
|
+
}]
|
82
93
|
end
|
83
94
|
|
84
95
|
def status_query(status)
|
85
96
|
if status
|
86
97
|
if status.is_a?(Array)
|
87
|
-
{
|
98
|
+
{"status": {"$in": status.map(&:to_i)}}
|
88
99
|
else
|
89
|
-
{
|
100
|
+
{"status": status.to_i}
|
90
101
|
end
|
91
102
|
else
|
92
103
|
{}
|
@@ -96,7 +107,7 @@ module FinApps
|
|
96
107
|
def assignment_query(assignment)
|
97
108
|
# translate "" to null assignment
|
98
109
|
if assignment
|
99
|
-
{
|
110
|
+
{"assignment.operator_id": assignment.empty? ? nil : assignment}
|
100
111
|
else
|
101
112
|
{}
|
102
113
|
end
|
@@ -104,7 +115,7 @@ module FinApps
|
|
104
115
|
|
105
116
|
def consumer_query(consumer)
|
106
117
|
if consumer
|
107
|
-
{
|
118
|
+
{"consumer_id": consumer.empty? ? nil : consumer}
|
108
119
|
else
|
109
120
|
{}
|
110
121
|
end
|
@@ -114,8 +125,8 @@ module FinApps
|
|
114
125
|
if !search_term && !nil_or_empty?(relation)
|
115
126
|
{
|
116
127
|
"$or": [
|
117
|
-
{
|
118
|
-
{
|
128
|
+
{"public_id": {"$in": relation}},
|
129
|
+
{"original_order_id": {"$in": relation}}
|
119
130
|
]
|
120
131
|
}
|
121
132
|
else
|
@@ -9,7 +9,7 @@ module FinApps
|
|
9
9
|
super(params, 'p/institution/consumer')
|
10
10
|
end
|
11
11
|
|
12
|
-
def show(id, options = {
|
12
|
+
def show(id, options = {show_accounts: false})
|
13
13
|
results, error_messages = super(nil, "p/institution/consumer/#{id}")
|
14
14
|
|
15
15
|
if error_messages.empty? && options[:show_accounts]
|
@@ -9,7 +9,7 @@ module FinApps
|
|
9
9
|
path = 'portfolio/reports'
|
10
10
|
|
11
11
|
return super path if params.nil?
|
12
|
-
|
12
|
+
fail FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
|
13
13
|
|
14
14
|
super build_query_path(path, params)
|
15
15
|
end
|
@@ -7,7 +7,7 @@ module FinApps
|
|
7
7
|
|
8
8
|
def list(params = nil)
|
9
9
|
return super if params.nil?
|
10
|
-
|
10
|
+
fail FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
|
11
11
|
|
12
12
|
super build_query_path(end_point, params)
|
13
13
|
end
|
@@ -12,7 +12,7 @@ module FinApps
|
|
12
12
|
"portfolios/#{ERB::Util.url_encode(portfolio_id)}/consumers/available"
|
13
13
|
return super path if params.nil?
|
14
14
|
|
15
|
-
|
15
|
+
fail FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
|
16
16
|
|
17
17
|
super build_query_path(path, params)
|
18
18
|
end
|
@@ -11,7 +11,7 @@ module FinApps
|
|
11
11
|
path = build_path(portfolio_id)
|
12
12
|
return super path if params.nil?
|
13
13
|
|
14
|
-
|
14
|
+
fail FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
|
15
15
|
|
16
16
|
super build_query_path(path, params)
|
17
17
|
end
|
@@ -8,21 +8,14 @@ module FinApps
|
|
8
8
|
|
9
9
|
def create(params, path = nil)
|
10
10
|
return super nil, path if path == LOGOUT
|
11
|
-
|
11
|
+
fail FinAppsCore::InvalidArgumentsError, 'Invalid argument: params.' unless validates params
|
12
12
|
|
13
13
|
path ||= CONSUMER_LOGIN
|
14
14
|
|
15
15
|
begin
|
16
16
|
super params, path
|
17
17
|
rescue FinAppsCore::ApiUnauthenticatedError
|
18
|
-
(
|
19
|
-
[
|
20
|
-
nil,
|
21
|
-
[
|
22
|
-
"Invalid #{path == CONSUMER_LOGIN ? 'Consumer' : 'Operator'} Identifier or Credentials"
|
23
|
-
]
|
24
|
-
]
|
25
|
-
)
|
18
|
+
login_error(path)
|
26
19
|
end
|
27
20
|
end
|
28
21
|
|
@@ -36,6 +29,15 @@ module FinApps
|
|
36
29
|
params.key?(:email) && params[:email] && params.key?(:password) &&
|
37
30
|
params[:password]
|
38
31
|
end
|
32
|
+
|
33
|
+
def login_error(path)
|
34
|
+
[
|
35
|
+
nil,
|
36
|
+
[
|
37
|
+
"Invalid #{path == CONSUMER_LOGIN ? 'Consumer' : 'Operator'} Identifier or Credentials"
|
38
|
+
]
|
39
|
+
]
|
40
|
+
end
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
@@ -6,8 +6,10 @@ module FinApps
|
|
6
6
|
def show(consumer_id, signature_request_id)
|
7
7
|
not_blank(consumer_id, :consumer_id)
|
8
8
|
not_blank(signature_request_id, :signature_request_id)
|
9
|
+
|
9
10
|
path =
|
10
|
-
"consumers/#{ERB::Util.url_encode(consumer_id)}/
|
11
|
+
"consumers/#{ERB::Util.url_encode(consumer_id)}/"\
|
12
|
+
"documents/#{ERB::Util.url_encode(signature_request_id)}"
|
11
13
|
super(nil, path)
|
12
14
|
end
|
13
15
|
end
|
@@ -5,15 +5,24 @@ module FinApps
|
|
5
5
|
module QueryBuilder
|
6
6
|
def build_query_path(root_url, params)
|
7
7
|
filter_obj = build_filter(params)
|
8
|
-
page = "page=#{params[:page].to_i}" if params[:page]
|
9
|
-
requested = "requested=#{params[:requested].to_i}" if params[:requested]
|
10
|
-
sort = "sort=#{ERB::Util.url_encode(params[:sort])}" if params[:sort]
|
11
8
|
filter = "filter=#{ERB::Util.url_encode(filter_obj.to_json)}" unless filter_obj.empty?
|
12
|
-
query_join(root_url, [page, requested, sort, filter])
|
9
|
+
query_join(root_url, [page(params), requested(params), sort(params), filter])
|
13
10
|
end
|
14
11
|
|
15
12
|
private
|
16
13
|
|
14
|
+
def page(params)
|
15
|
+
"page=#{params[:page].to_i}" if params[:page]
|
16
|
+
end
|
17
|
+
|
18
|
+
def requested(params)
|
19
|
+
"requested=#{params[:requested].to_i}" if params[:requested]
|
20
|
+
end
|
21
|
+
|
22
|
+
def sort(params)
|
23
|
+
"sort=#{ERB::Util.url_encode(params[:sort])}" if params[:sort]
|
24
|
+
end
|
25
|
+
|
17
26
|
def query_join(root_url, params_array)
|
18
27
|
query_string = params_array.compact.join('&')
|
19
28
|
[root_url, query_string].reject(&:empty?).join('?')
|