finapps 5.0.30 → 5.0.35

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.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yaml +37 -0
  3. data/.rubocop.yml +134 -61
  4. data/.rubocop_todo.yml +29 -0
  5. data/.tmuxinator.yml +1 -0
  6. data/.travis.yml +3 -1
  7. data/README.md +1 -0
  8. data/RELEASES.md +29 -0
  9. data/finapps.gemspec +4 -4
  10. data/lib/finapps/rest/alert_definitions.rb +1 -1
  11. data/lib/finapps/rest/alert_occurrences.rb +1 -1
  12. data/lib/finapps/rest/client.rb +6 -5
  13. data/lib/finapps/rest/consumers.rb +22 -6
  14. data/lib/finapps/rest/consumers_portfolios.rb +1 -1
  15. data/lib/finapps/rest/documents_orders.rb +43 -26
  16. data/lib/finapps/rest/operators.rb +5 -5
  17. data/lib/finapps/rest/operators_password_resets.rb +1 -1
  18. data/lib/finapps/rest/order_assignments.rb +1 -1
  19. data/lib/finapps/rest/order_reports.rb +1 -1
  20. data/lib/finapps/rest/orders.rb +33 -22
  21. data/lib/finapps/rest/plaid/plaid_consumer_institutions.rb +1 -1
  22. data/lib/finapps/rest/portfolio_reports.rb +1 -1
  23. data/lib/finapps/rest/portfolios.rb +1 -1
  24. data/lib/finapps/rest/portfolios_available_consumers.rb +1 -1
  25. data/lib/finapps/rest/portfolios_consumers.rb +1 -1
  26. data/lib/finapps/rest/sessions.rb +11 -9
  27. data/lib/finapps/rest/signed_documents_downloads.rb +3 -1
  28. data/lib/finapps/utils/query_builder.rb +13 -4
  29. data/lib/finapps/version.rb +1 -1
  30. data/spec/rest/alert_definitions_spec.rb +10 -6
  31. data/spec/rest/alert_occurrences_spec.rb +6 -1
  32. data/spec/rest/api_request.rb +1 -0
  33. data/spec/rest/client_spec.rb +33 -41
  34. data/spec/rest/consumers_portfolios_spec.rb +7 -2
  35. data/spec/rest/consumers_spec.rb +240 -192
  36. data/spec/rest/documents_orders_notifications_spec.rb +4 -2
  37. data/spec/rest/documents_orders_spec.rb +94 -17
  38. data/spec/rest/esign_templates_spec.rb +2 -1
  39. data/spec/rest/operators_password_resets_spec.rb +50 -52
  40. data/spec/rest/operators_spec.rb +181 -172
  41. data/spec/rest/order_assignments_spec.rb +6 -1
  42. data/spec/rest/order_notifications_spec.rb +4 -2
  43. data/spec/rest/order_refreshes_spec.rb +8 -5
  44. data/spec/rest/order_reports_spec.rb +21 -15
  45. data/spec/rest/order_statuses_spec.rb +14 -10
  46. data/spec/rest/order_tokens_spec.rb +37 -30
  47. data/spec/rest/orders_spec.rb +121 -73
  48. data/spec/rest/password_resets_spec.rb +46 -36
  49. data/spec/rest/plaid/plaid_account_permissions_spec.rb +5 -4
  50. data/spec/rest/plaid/plaid_accounts_spec.rb +9 -4
  51. data/spec/rest/plaid/plaid_consumer_institutions_spec.rb +11 -11
  52. data/spec/rest/plaid/plaid_institution_logos_spec.rb +1 -1
  53. data/spec/rest/plaid/plaid_webhooks_spec.rb +3 -1
  54. data/spec/rest/portfolio_reports_spec.rb +7 -2
  55. data/spec/rest/portfolios_alerts_spec.rb +9 -4
  56. data/spec/rest/portfolios_available_consumers_spec.rb +7 -2
  57. data/spec/rest/portfolios_consumers_spec.rb +15 -4
  58. data/spec/rest/portfolios_spec.rb +20 -17
  59. data/spec/rest/products_spec.rb +17 -14
  60. data/spec/rest/sessions_spec.rb +63 -58
  61. data/spec/rest/signed_documents_downloads_spec.rb +10 -6
  62. data/spec/rest/tenant_app_settings_spec.rb +9 -3
  63. data/spec/rest/tenant_settings_spec.rb +9 -3
  64. data/spec/rest/verix/verix_documents_spec.rb +15 -22
  65. data/spec/rest/verix/verix_metadata_spec.rb +1 -1
  66. data/spec/rest/verix/verix_pdf_documents_spec.rb +14 -19
  67. data/spec/rest/verix/verix_records_spec.rb +31 -10
  68. data/spec/rest/version_spec.rb +6 -4
  69. data/spec/spec_helper.rb +2 -2
  70. data/spec/support/fake_api.rb +9 -3
  71. data/spec/support/fixtures/documents_orders_none.json +6 -0
  72. data/spec/utils/query_builder_spec.rb +40 -14
  73. metadata +20 -17
@@ -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
- raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
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
- raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
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
@@ -46,42 +46,59 @@ module FinApps
46
46
  private
47
47
 
48
48
  def build_filter(params)
49
- search_query(params[:searchTerm]).merge(consumer_query(params[:consumer])).merge(tag_query(params[:tag]))
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
- if term
56
+ return {} unless term
57
+
58
+ query = with_space_search(term).concat(name_search(term))
59
+ {"$or": query}
60
+ end
61
+
62
+ def name_search(term)
63
+ search_arr = []
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
69
+ end
70
+ search_arr
71
+ end
72
+
73
+ def with_space_search(term)
74
+ [
75
+ {"applicant.email": term},
76
+ {"applicant.first_name": term},
77
+ {"applicant.last_name": term},
54
78
  {
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
- ]
79
+ "reference_no": {
80
+ "$regex": "^#{term}", "$options": 'i'
81
+ }
65
82
  }
66
- else
67
- {}
68
- end
83
+ ]
69
84
  end
70
85
 
71
86
  def tag_query(tag)
72
- if tag
73
- { "tag": tag.empty? ? nil : tag }
74
- else
75
- {}
76
- end
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}
77
96
  end
78
97
 
79
98
  def consumer_query(consumer)
80
- if consumer
81
- { "consumer_id": consumer.empty? ? nil : consumer }
82
- else
83
- {}
84
- end
99
+ return {} unless consumer
100
+
101
+ {"consumer_id": consumer.empty? ? nil : consumer}
85
102
  end
86
103
  end
87
104
  end
@@ -9,7 +9,7 @@ module FinApps
9
9
 
10
10
  def list(params = nil)
11
11
  return super if params.nil?
12
- raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
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
- raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params.' unless validates params
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
- { "last_name": term }
67
+ {"last_name": term}
68
68
  end
69
69
 
70
70
  def role_query(role)
71
71
  if role.is_a?(Array)
72
- { "role": { "$in": role.map(&:to_i) } }
72
+ {"role": {"$in": role.map(&:to_i)}}
73
73
  else
74
- { "role": role.to_i }
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
- raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params.' unless email_exists? params
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
- raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless orders_array.is_a? Array
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
- raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: format' unless accepted_format?(format)
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)}"
@@ -28,7 +28,7 @@ module FinApps
28
28
  #
29
29
  def list(params = nil)
30
30
  return super if params.nil?
31
- raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
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
- if term
67
- {
68
- "$or": [
69
- { "public_id": { "$regex": "^#{term}", "$options": 'i' } },
70
- { "applicant.last_name": term },
71
- { "assignment.last_name": term },
72
- {
73
- "requestor.reference_no": {
74
- "$regex": "^#{term}", "$options": 'i'
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
- { "status": { "$in": status.map(&:to_i) } }
98
+ {"status": {"$in": status.map(&:to_i)}}
88
99
  else
89
- { "status": status.to_i }
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
- { "assignment.operator_id": assignment.empty? ? nil : assignment }
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
- { "consumer_id": consumer.empty? ? nil : consumer }
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
- { "public_id": { "$in": relation } },
118
- { "original_order_id": { "$in": relation } }
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 = { show_accounts: false })
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
- raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
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
- raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
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
- raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
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
- raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
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
- raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params.' unless validates params
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)}/documents/#{ERB::Util.url_encode(signature_request_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('?')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FinApps
4
- VERSION = '5.0.30'
4
+ VERSION = '5.0.35'
5
5
  end
@@ -4,7 +4,7 @@ require 'spec_helpers/client'
4
4
 
5
5
  RSpec.describe FinApps::REST::AlertDefinitions do
6
6
  include SpecHelpers::Client
7
- subject { FinApps::REST::AlertDefinitions.new(client) }
7
+ subject { described_class.new(client) }
8
8
 
9
9
  describe '#list' do
10
10
  let(:list) { subject.list(params) }
@@ -16,9 +16,11 @@ RSpec.describe FinApps::REST::AlertDefinitions do
16
16
 
17
17
  it { expect { list }.not_to raise_error }
18
18
  it('returns an array') { expect(list).to be_a(Array) }
19
+
19
20
  it('performs a get and returns the response') do
20
21
  expect(results).to have_key(:records)
21
22
  end
23
+
22
24
  it('returns no error messages') { expect(errors).to be_empty }
23
25
  end
24
26
 
@@ -29,14 +31,17 @@ RSpec.describe FinApps::REST::AlertDefinitions do
29
31
  end
30
32
 
31
33
  context 'when including valid params' do
32
- let(:params) { { page: 2, sort: '-created_date', requested: 25 } }
34
+ let(:params) { {page: 2, sort: '-created_date', requested: 25} }
33
35
 
34
36
  it { expect { list }.not_to raise_error }
35
37
  it('returns an array') { expect(list).to be_a(Array) }
38
+
36
39
  it('performs a get and returns the response') do
37
40
  expect(results).to have_key(:records)
38
41
  end
42
+
39
43
  it('returns no error messages') { expect(errors).to be_empty }
44
+
40
45
  it 'builds query and sends proper request' do
41
46
  list
42
47
  url =
@@ -63,10 +68,8 @@ RSpec.describe FinApps::REST::AlertDefinitions do
63
68
 
64
69
  it { expect { show }.not_to raise_error }
65
70
  it('returns an array') { expect(show).to be_a(Array) }
66
- it('performs a get and returns the response') do
67
- expect(results).to have_key(:_id)
68
- expect(results).to have_key(:rule_name)
69
- end
71
+ it { expect(results).to have_key(:_id) }
72
+ it { expect(results).to have_key(:rule_name) }
70
73
  it('returns no error messages') { expect(errors).to be_empty }
71
74
  end
72
75
 
@@ -75,6 +78,7 @@ RSpec.describe FinApps::REST::AlertDefinitions do
75
78
 
76
79
  it { expect { show }.not_to raise_error }
77
80
  it('results is nil') { expect(results).to be_nil }
81
+
78
82
  it('error messages array is populated') do
79
83
  expect(errors.first.downcase).to eq('resource not found')
80
84
  end