finapps 5.0.32 → 5.0.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +134 -61
  3. data/.rubocop_todo.yml +120 -0
  4. data/.tmuxinator.yml +1 -0
  5. data/.travis.yml +3 -1
  6. data/finapps.gemspec +3 -3
  7. data/lib/finapps/rest/alert_definitions.rb +1 -1
  8. data/lib/finapps/rest/alert_occurrences.rb +1 -1
  9. data/lib/finapps/rest/consumers.rb +5 -5
  10. data/lib/finapps/rest/consumers_portfolios.rb +1 -1
  11. data/lib/finapps/rest/documents_orders.rb +25 -24
  12. data/lib/finapps/rest/operators.rb +5 -5
  13. data/lib/finapps/rest/operators_password_resets.rb +1 -1
  14. data/lib/finapps/rest/order_assignments.rb +1 -1
  15. data/lib/finapps/rest/order_reports.rb +1 -1
  16. data/lib/finapps/rest/orders.rb +10 -10
  17. data/lib/finapps/rest/plaid/plaid_consumer_institutions.rb +1 -1
  18. data/lib/finapps/rest/portfolio_reports.rb +1 -1
  19. data/lib/finapps/rest/portfolios.rb +1 -1
  20. data/lib/finapps/rest/portfolios_available_consumers.rb +1 -1
  21. data/lib/finapps/rest/portfolios_consumers.rb +1 -1
  22. data/lib/finapps/rest/sessions.rb +1 -1
  23. data/lib/finapps/rest/signed_documents_downloads.rb +3 -1
  24. data/lib/finapps/version.rb +1 -1
  25. data/spec/rest/alert_definitions_spec.rb +10 -2
  26. data/spec/rest/alert_occurrences_spec.rb +6 -1
  27. data/spec/rest/api_request.rb +1 -0
  28. data/spec/rest/client_spec.rb +2 -2
  29. data/spec/rest/consumers_portfolios_spec.rb +7 -2
  30. data/spec/rest/consumers_spec.rb +39 -11
  31. data/spec/rest/documents_orders_notifications_spec.rb +3 -1
  32. data/spec/rest/documents_orders_spec.rb +85 -23
  33. data/spec/rest/esign_templates_spec.rb +2 -1
  34. data/spec/rest/operators_password_resets_spec.rb +6 -1
  35. data/spec/rest/operators_spec.rb +22 -2
  36. data/spec/rest/order_assignments_spec.rb +6 -1
  37. data/spec/rest/order_notifications_spec.rb +3 -1
  38. data/spec/rest/order_refreshes_spec.rb +7 -1
  39. data/spec/rest/order_reports_spec.rb +7 -1
  40. data/spec/rest/order_statuses_spec.rb +7 -3
  41. data/spec/rest/order_tokens_spec.rb +7 -1
  42. data/spec/rest/orders_spec.rb +63 -29
  43. data/spec/rest/password_resets_spec.rb +20 -10
  44. data/spec/rest/plaid/plaid_account_permissions_spec.rb +5 -4
  45. data/spec/rest/plaid/plaid_accounts_spec.rb +9 -4
  46. data/spec/rest/plaid/plaid_consumer_institutions_spec.rb +10 -10
  47. data/spec/rest/plaid/plaid_institution_logos_spec.rb +1 -1
  48. data/spec/rest/plaid/plaid_webhooks_spec.rb +3 -1
  49. data/spec/rest/portfolio_reports_spec.rb +7 -2
  50. data/spec/rest/portfolios_alerts_spec.rb +6 -1
  51. data/spec/rest/portfolios_available_consumers_spec.rb +7 -2
  52. data/spec/rest/portfolios_consumers_spec.rb +13 -2
  53. data/spec/rest/portfolios_spec.rb +20 -5
  54. data/spec/rest/products_spec.rb +3 -1
  55. data/spec/rest/sessions_spec.rb +8 -4
  56. data/spec/rest/signed_documents_downloads_spec.rb +3 -3
  57. data/spec/rest/tenant_app_settings_spec.rb +9 -3
  58. data/spec/rest/tenant_settings_spec.rb +9 -3
  59. data/spec/rest/verix/verix_documents_spec.rb +13 -20
  60. data/spec/rest/verix/verix_metadata_spec.rb +1 -1
  61. data/spec/rest/verix/verix_pdf_documents_spec.rb +14 -19
  62. data/spec/rest/verix/verix_records_spec.rb +31 -10
  63. data/spec/rest/version_spec.rb +3 -1
  64. data/spec/spec_helper.rb +2 -2
  65. data/spec/support/fake_api.rb +9 -3
  66. data/spec/support/fixtures/documents_orders_none.json +6 -0
  67. data/spec/utils/query_builder_spec.rb +40 -14
  68. metadata +17 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05c3cbe0d36260925c0a4ca37018f711a959dc0607b4d379b9adb048ef76a0c9
4
- data.tar.gz: 1a519b374d9345074573372872fcc731f7b55111adc47be50ce549f7db5b913d
3
+ metadata.gz: 7bc0442f42cabf196882b3f3d0ae8f1ae5d9f36f49884169dd34c0accafa5537
4
+ data.tar.gz: 75be45fb19c5f5fb86e67e683ff436cc7e213676112eb8c132517526d3fdafcd
5
5
  SHA512:
6
- metadata.gz: 79b1294efebc55a4eb589511df152268a6afbd135b9d06c0d159d8beecdb3d5c968cd5f1978dfac92934d8f1e8464004f21f7327631f236ee53b084ac1ac1858
7
- data.tar.gz: b333304eae828c57e73751fa1a09f5d3da6582499eab129ff4421ac8726c204cef74a6a5d90591f41e5c9a82d9dfeb5e4422cbf738b685fcdc83cf70a38a2945
6
+ metadata.gz: 34ea2347a6692389744647a4143830219b0f5d9160e6e7324724f73eba7807965cc019e7000cc7621f41c34a116e6442f1279995bfac46b318936abc26cd96fc
7
+ data.tar.gz: 071c55d0059d031bae2dafc12ed7d242de5afb49f03b49ea07552a0f877e7e1ad4278bed42769d44622ecb30231ea26a4de7dd42ade2f2618fe94ddf5c17e3b6
@@ -1,26 +1,59 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ require:
4
+ - rubocop-rspec
5
+ - rubocop-performance
6
+
1
7
  AllCops:
2
- DisplayCopNames: true
8
+ TargetRubyVersion: 2.6
3
9
  Exclude:
4
- - "finapps.gemspec"
5
- UseCache: false
10
+ - "vendor/**/*"
11
+ - "bin/**/*"
12
+ CacheRootDirectory: tmp
6
13
 
7
- # Commonly used screens these days easily fit more than 80 characters.
14
+ Layout/SpaceAroundMethodCallOperator:
15
+ Enabled: true
16
+ Layout/EmptyLinesAroundAttributeAccessor:
17
+ Enabled: true
18
+ Layout/SpaceInsideBlockBraces:
19
+ # The space here provides no real gain in readability while consuming
20
+ # horizontal space that could be used for a better parameter name.
21
+ # Also {| differentiates better from a hash than { | does.
22
+ SpaceBeforeBlockParameters: false
23
+ Layout/SpaceInsideHashLiteralBraces:
24
+ EnforcedStyle: no_space
25
+ Layout/DotPosition:
26
+ Description: Checks the position of the dot in multi-line method calls.
27
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
28
+ Enabled: true
29
+ EnforcedStyle: leading
30
+ SupportedStyles:
31
+ - leading
32
+ - trailing
8
33
  Layout/LineLength:
9
- Max: 120
34
+ Max: 110
10
35
 
11
- Style/CollectionMethods:
12
- Description: Preferred collection methods.
13
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
36
+ Lint/DeprecatedOpenSSLConstant:
14
37
  Enabled: true
15
- PreferredMethods:
16
- collect: map
17
- collect!: map!
18
- find: detect
19
- find_all: select
20
- reduce: inject
21
- Style/OptionHash:
22
- Description: Don't use option hashes when you can use keyword arguments.
23
- Enabled: false
38
+ Lint/MixedRegexpCaptureTypes:
39
+ Enabled: true
40
+ Lint/RaiseException:
41
+ Enabled: true
42
+ Lint/StructNewOverride:
43
+ Enabled: true
44
+
45
+ Metrics/ClassLength:
46
+ Exclude:
47
+ - app/controllers/orders_controller.rb
48
+ - app/models/order.rb
49
+ Metrics/BlockLength:
50
+ ExcludedMethods: ['describe', 'context']
51
+ Exclude:
52
+ - config/environments/**/**
53
+ - Guardfile
54
+ - config/routes.rb
55
+ - config/Guardfile
56
+
24
57
  Naming/PredicateName:
25
58
  Description: Check the names of predicate methods.
26
59
  StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
@@ -33,54 +66,94 @@ Naming/PredicateName:
33
66
  - is_
34
67
  Exclude:
35
68
  - spec/**/*
36
- Metrics/AbcSize:
37
- Description: A calculated magnitude based on number of assignments, branches, and
38
- conditions.
39
- Enabled: false
40
- Max: 15
41
- Metrics/BlockLength:
42
- ExcludedMethods: ['describe', 'context']
43
- Metrics/ClassLength:
44
- Description: Avoid classes longer than 100 lines of code.
45
- Enabled: false
46
- CountComments: false
47
- Max: 100
48
- Metrics/ModuleLength:
49
- CountComments: false
50
- Max: 100
51
- Description: Avoid modules longer than 100 lines of code.
52
- Enabled: false
53
- Metrics/CyclomaticComplexity:
54
- Description: A complexity metric that is strongly correlated to the number of test
55
- cases needed to validate a method.
56
- Enabled: false
57
- Max: 6
58
- Metrics/MethodLength:
59
- Description: Avoid methods longer than 10 lines of code.
60
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
69
+
70
+ RSpec/FilePath:
61
71
  Enabled: false
62
- CountComments: false
63
- Max: 10
64
- Metrics/ParameterLists:
65
- Description: Avoid parameter lists longer than three or four parameters.
66
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
72
+
73
+ Style/RedundantRegexpCharacterClass:
74
+ Enabled: true
75
+ Style/RedundantRegexpEscape:
76
+ Enabled: true
77
+ Style/CollectionMethods:
78
+ Description: Preferred collection methods.
79
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
80
+ Enabled: true
81
+ PreferredMethods:
82
+ collect: map
83
+ collect!: map!
84
+ find: detect
85
+ find_all: select
86
+ reduce: inject
87
+ Style/GuardClause:
88
+ Description: Check for conditionals that can be replaced with guard clauses
89
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
90
+ Enabled: true
91
+ MinBodyLength: 1
92
+ Style/OptionHash:
93
+ Description: Don't use option hashes when you can use keyword arguments.
67
94
  Enabled: false
68
- Max: 5
69
- CountKeywordArgs: true
70
- Metrics/PerceivedComplexity:
71
- Description: A complexity metric geared towards measuring complexity for a human
72
- reader.
95
+ Style/PercentLiteralDelimiters:
96
+ Description: Use `%`-literal delimiters consistently
97
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
73
98
  Enabled: false
74
- Max: 7
99
+ PreferredDelimiters:
100
+ "%": "()"
101
+ "%i": "()"
102
+ "%q": "()"
103
+ "%Q": "()"
104
+ "%r": "{}"
105
+ "%s": "()"
106
+ "%w": "()"
107
+ "%W": "()"
108
+ "%x": "()"
109
+ Style/SignalException:
110
+ Description: Checks for proper usage of fail and raise.
111
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
112
+ Enabled: true
113
+ EnforcedStyle: semantic
114
+ SupportedStyles:
115
+ - only_raise
116
+ - only_fail
117
+ - semantic
118
+ Style/StringLiterals:
119
+ Description: Checks if uses of quotes match the configured preference.
120
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
121
+ Enabled: true
122
+ EnforcedStyle: single_quotes
123
+ SupportedStyles:
124
+ - single_quotes
125
+ - double_quotes
126
+ Style/StringLiteralsInInterpolation:
127
+ Description: Checks if uses of quotes inside expressions in interpolated strings
128
+ match the configured preference.
129
+ Enabled: true
130
+ EnforcedStyle: single_quotes
131
+ SupportedStyles:
132
+ - single_quotes
133
+ - double_quotes
75
134
  Style/Documentation:
76
135
  Description: Document classes and non-namespace modules.
77
136
  Enabled: false
78
- Style/EmptyLiteral:
79
- Description: Prefer literals to Array.new/Hash.new/String.new.
80
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
81
- Enabled: false
82
- Style/VariableInterpolation:
83
- Description: Don't interpolate global, instance and class variables directly in
84
- strings.
85
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
137
+ Style/OneLineConditional:
138
+ Description: Favor the ternary operator(?:) over if/then/else/end constructs.
139
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
86
140
  Enabled: false
141
+ Style/ExponentialNotation:
142
+ Enabled: true
143
+ Style/HashEachMethods:
144
+ Enabled: true
145
+ Style/HashTransformKeys:
146
+ Enabled: true
147
+ Style/HashTransformValues:
148
+ Enabled: true
149
+ Style/RedundantFetchBlock:
150
+ Enabled: true
151
+ Style/SlicingWithRange:
152
+ Enabled: true
153
+
154
+ RSpec/NestedGroups:
155
+ Max: 5
156
+ RSpec/DescribeClass:
157
+ Exclude:
158
+ - spec/system/*
159
+ - spec/factories_spec.rb
@@ -0,0 +1,120 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2020-06-24 14:28:46 UTC using RuboCop version 0.86.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 12
10
+ # Cop supports --auto-correct.
11
+ # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
12
+ # URISchemes: http, https
13
+ Layout/LineLength:
14
+ Max: 119
15
+
16
+ # Offense count: 1
17
+ # Configuration parameters: IgnoredMethods.
18
+ Metrics/AbcSize:
19
+ Max: 16
20
+
21
+ # Offense count: 1
22
+ # Configuration parameters: CountComments, ExcludedMethods.
23
+ # ExcludedMethods: refine
24
+ Metrics/BlockLength:
25
+ Max: 28
26
+
27
+ # Offense count: 1
28
+ # Configuration parameters: CountComments.
29
+ Metrics/ClassLength:
30
+ Max: 431
31
+
32
+ # Offense count: 3
33
+ # Configuration parameters: CountComments, ExcludedMethods.
34
+ Metrics/MethodLength:
35
+ Max: 16
36
+
37
+ # Offense count: 29
38
+ # Configuration parameters: Prefixes.
39
+ # Prefixes: when, with, without
40
+ RSpec/ContextWording:
41
+ Exclude:
42
+ - 'spec/rest/client_spec.rb'
43
+ - 'spec/rest/consumers_spec.rb'
44
+ - 'spec/rest/documents_orders_notifications_spec.rb'
45
+ - 'spec/rest/operators_password_resets_spec.rb'
46
+ - 'spec/rest/operators_spec.rb'
47
+ - 'spec/rest/order_notifications_spec.rb'
48
+ - 'spec/rest/order_tokens_spec.rb'
49
+ - 'spec/rest/orders_spec.rb'
50
+ - 'spec/rest/portfolios_consumers_spec.rb'
51
+ - 'spec/rest/sessions_spec.rb'
52
+
53
+ # Offense count: 6
54
+ RSpec/DescribeMethod:
55
+ Exclude:
56
+ - 'spec/rest/consumers_spec.rb'
57
+ - 'spec/rest/operators_password_resets_spec.rb'
58
+ - 'spec/rest/operators_spec.rb'
59
+ - 'spec/rest/order_tokens_spec.rb'
60
+ - 'spec/rest/products_spec.rb'
61
+ - 'spec/rest/sessions_spec.rb'
62
+
63
+ # Offense count: 5
64
+ # Configuration parameters: Max.
65
+ RSpec/ExampleLength:
66
+ Exclude:
67
+ - 'spec/rest/consumers_spec.rb'
68
+ - 'spec/rest/documents_orders_spec.rb'
69
+ - 'spec/rest/orders_spec.rb'
70
+
71
+ # Offense count: 1
72
+ # Configuration parameters: .
73
+ # SupportedStyles: have_received, receive
74
+ RSpec/MessageSpies:
75
+ EnforcedStyle: receive
76
+
77
+ # Offense count: 13
78
+ RSpec/MultipleExpectations:
79
+ Max: 3
80
+
81
+ # Offense count: 114
82
+ # Configuration parameters: IgnoreSharedExamples.
83
+ RSpec/NamedSubject:
84
+ Exclude:
85
+ - 'spec/rest/client_spec.rb'
86
+ - 'spec/rest/consumers_spec.rb'
87
+ - 'spec/rest/documents_orders_spec.rb'
88
+ - 'spec/rest/order_reports_spec.rb'
89
+ - 'spec/rest/order_statuses_spec.rb'
90
+ - 'spec/rest/order_tokens_spec.rb'
91
+ - 'spec/rest/orders_spec.rb'
92
+ - 'spec/rest/password_resets_spec.rb'
93
+ - 'spec/rest/plaid/plaid_consumer_institutions_spec.rb'
94
+ - 'spec/rest/sessions_spec.rb'
95
+ - 'spec/rest/signed_documents_downloads_spec.rb'
96
+ - 'spec/rest/verix/verix_documents_spec.rb'
97
+ - 'spec/rest/verix/verix_pdf_documents_spec.rb'
98
+ - 'spec/rest/version_spec.rb'
99
+
100
+ # Offense count: 6
101
+ RSpec/RepeatedExample:
102
+ Exclude:
103
+ - 'spec/rest/signed_documents_downloads_spec.rb'
104
+ - 'spec/rest/verix/verix_documents_spec.rb'
105
+ - 'spec/rest/verix/verix_pdf_documents_spec.rb'
106
+
107
+ # Offense count: 2
108
+ RSpec/RepeatedExampleGroupBody:
109
+ Exclude:
110
+ - 'spec/rest/client_spec.rb'
111
+
112
+ # Offense count: 4
113
+ RSpec/RepeatedExampleGroupDescription:
114
+ Exclude:
115
+ - 'spec/rest/client_spec.rb'
116
+
117
+ # Offense count: 1
118
+ RSpec/SubjectStub:
119
+ Exclude:
120
+ - 'spec/rest/orders_spec.rb'
@@ -11,6 +11,7 @@ windows:
11
11
  - git pull
12
12
  - git status
13
13
  - bundle
14
+ - bundle outdated
14
15
  -
15
16
  guard:
16
17
  layout: even-horizontal
@@ -1,5 +1,7 @@
1
- sudo: false
2
1
  language: ruby
2
+ os: ["linux"]
3
+ dist: "xenial"
4
+
3
5
  cache:
4
6
  bundler: true
5
7
 
@@ -29,9 +29,9 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'guard-rspec', '~> 4.7', '>= 4.7.3'
30
30
  spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.1'
31
31
  spec.add_development_dependency 'rspec', '~> 3.9', '>= 3.9.0'
32
- spec.add_development_dependency 'rubocop', '~> 0.79', '>= 0.79.0'
33
- spec.add_development_dependency 'rubocop-performance', '~> 1.5', '>= 1.5.2'
34
- spec.add_development_dependency 'rubocop-rspec', '~> 1.37', '>= 1.37.1'
32
+ spec.add_development_dependency 'rubocop', '~> 0.86', '>= 0.86.0'
33
+ spec.add_development_dependency 'rubocop-performance', '~> 1.6', '>= 1.6.1'
34
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.40', '>= 1.40.0'
35
35
  spec.add_development_dependency 'sinatra', '~> 2.0', '>= 2.0.8'
36
36
  spec.add_development_dependency 'webmock', '~> 3.8', '>= 3.8.0'
37
37
 
@@ -8,7 +8,7 @@ module FinApps
8
8
 
9
9
  def list(params = nil)
10
10
  return super END_POINT if params.nil?
11
- raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
11
+ fail FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
12
12
 
13
13
  super build_query_path(END_POINT, params)
14
14
  end
@@ -8,7 +8,7 @@ module FinApps
8
8
 
9
9
  def list(params = nil)
10
10
  return super END_POINT if params.nil?
11
- raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
11
+ fail FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
12
12
 
13
13
  super build_query_path(END_POINT, params)
14
14
  end
@@ -15,7 +15,7 @@ module FinApps
15
15
 
16
16
  def list(params = nil)
17
17
  return super if params.nil?
18
- raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
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,15 @@ module FinApps
62
62
 
63
63
  def with_space_search(term)
64
64
  [
65
- { "email": term },
66
- { "first_name": term },
67
- { "last_name": term }
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
- if term.match(/\s/)
73
+ if /\s/.match?(term)
74
74
  term.split.each do |t|
75
75
  search_arr.append("first_name": t)
76
76
  search_arr.append("last_name": t)
@@ -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,23 +46,22 @@ 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
54
- query = with_space_search(term).concat(name_search(term))
55
- {
56
- "$or": query
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 term.match(/\s/)
64
+ if /\s/.match?(term)
66
65
  term.split.each do |t|
67
66
  search_arr.append("applicant.first_name": t)
68
67
  search_arr.append("applicant.last_name": t)
@@ -73,9 +72,9 @@ module FinApps
73
72
 
74
73
  def with_space_search(term)
75
74
  [
76
- { "applicant.email": term },
77
- { "applicant.first_name": term },
78
- { "applicant.last_name": term },
75
+ {"applicant.email": term},
76
+ {"applicant.first_name": term},
77
+ {"applicant.last_name": term},
79
78
  {
80
79
  "reference_no": {
81
80
  "$regex": "^#{term}", "$options": 'i'
@@ -85,19 +84,21 @@ module FinApps
85
84
  end
86
85
 
87
86
  def tag_query(tag)
88
- if tag
89
- { "tag": tag.empty? ? nil : tag }
90
- else
91
- {}
92
- 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}
93
96
  end
94
97
 
95
98
  def consumer_query(consumer)
96
- if consumer
97
- { "consumer_id": consumer.empty? ? nil : consumer }
98
- else
99
- {}
100
- end
99
+ return {} unless consumer
100
+
101
+ {"consumer_id": consumer.empty? ? nil : consumer}
101
102
  end
102
103
  end
103
104
  end