finapps 5.0.43 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yaml +47 -0
  3. data/.github/workflows/release.yml +42 -42
  4. data/.rubocop.yml +1 -1
  5. data/.ruby-version +1 -1
  6. data/Guardfile +1 -1
  7. data/README.md +6 -4
  8. data/finapps.gemspec +8 -7
  9. data/lib/finapps.rb +1 -0
  10. data/lib/finapps/rest/client.rb +2 -1
  11. data/lib/finapps/rest/consumers.rb +5 -5
  12. data/lib/finapps/rest/documents_orders.rb +23 -4
  13. data/lib/finapps/rest/documents_orders_notifications.rb +2 -2
  14. data/lib/finapps/rest/documents_uploads.rb +8 -0
  15. data/lib/finapps/rest/operators.rb +3 -3
  16. data/lib/finapps/rest/orders.rb +6 -6
  17. data/lib/finapps/rest/screenings.rb +64 -0
  18. data/lib/finapps/version.rb +1 -1
  19. data/spec/rest/api_request.rb +8 -0
  20. data/spec/rest/documents_orders_notifications_spec.rb +2 -2
  21. data/spec/rest/documents_orders_spec.rb +37 -31
  22. data/spec/rest/documents_uploads_spec.rb +53 -0
  23. data/spec/rest/screenings_spec.rb +235 -0
  24. data/spec/rest/signed_documents_downloads_spec.rb +4 -7
  25. data/spec/rest/verix/verix_documents_spec.rb +4 -4
  26. data/spec/spec_helper.rb +1 -1
  27. data/spec/support/documents_uploads_routes.rb +39 -0
  28. data/spec/support/fake_api.rb +457 -456
  29. data/spec/support/fixtures/documents/retrieve_order.json +97 -0
  30. data/spec/support/fixtures/screening.json +26 -0
  31. data/spec/support/fixtures/screening_invalid_update.json +5 -0
  32. data/spec/support/fixtures/screening_list.json +25 -0
  33. data/spec/support/fixtures/session_not_found.json +5 -0
  34. data/spec/support/screenings_routes.rb +73 -0
  35. metadata +111 -79
  36. data/.github/workflows/main.yaml +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25bea095f4796915e3b73d50300279a31fd052ca797da34c91a41078f9eecc2b
4
- data.tar.gz: 2f4123341bbc2703a26d8ad361428fb050a06c797390d7b57f2b67f07bef90de
3
+ metadata.gz: 376f28da5e635a8ad2bb605ed938fd3c27d06d826818a8b050e0bcc5cf3ffb62
4
+ data.tar.gz: e1a10a00165e243ce8b8558efcc3e666f9f06c6f1a2344004c5f5f0182b15bd8
5
5
  SHA512:
6
- metadata.gz: 03c8eccc181f51654a07bad7769ce759707d6f6a54a21a806ce0b924ef7bce7ee17c1f27751a86f9659d83e6e7005988dd48bad3d51127bc1957f6764a392116
7
- data.tar.gz: 01205c7a1e01a4267d5dd9ad4e10789872a2e6bf47e29c354ed2c9939c806e01bdfa00b1a1c1c36012397cbc6b235760c99486f8b3f71f17c912ad6e458cf059
6
+ metadata.gz: b26f301279eefa97fbf482adb264d403de9978146513519916b6cfd7f7d2b8f16a85bc7abddc2254b33ee0de9e5e92897546f4c16e799d6e91374863a9636457
7
+ data.tar.gz: d2c9335df63d6021e1e825bbfd5605dcbf3c969b691d0ac991d68dcbcffb2a0c10cf0c3a21f6c5ab2a4b678bf77603771f80a1161e8d36889e1f171ea8963d80
@@ -0,0 +1,47 @@
1
+ name: Continuous Integration
2
+
3
+ on:
4
+ push:
5
+ paths-ignore:
6
+ - ".github/**"
7
+ - ".VERSION"
8
+ pull_request:
9
+ paths-ignore:
10
+ - ".github/**"
11
+ - ".VERSION"
12
+ jobs:
13
+ tests:
14
+ if: "!contains(github.event.head_commit.message, 'skip ci')"
15
+ runs-on: ubuntu-latest
16
+
17
+ strategy:
18
+ fail-fast: true
19
+
20
+ steps:
21
+ - name: Checkout source code
22
+ uses: actions/checkout@v2
23
+
24
+ - name: Install required ruby
25
+ uses: ruby/setup-ruby@v1
26
+
27
+ - name: Setup cache key and directory for gems cache
28
+ uses: actions/cache@v2
29
+ with:
30
+ path: vendor/bundle
31
+ key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
32
+ restore-keys: |
33
+ ${{ runner.os }}-gems-
34
+
35
+ - name: Bundle install
36
+ run: |
37
+ bundle config path vendor/bundle
38
+ bundle config set jobs 4
39
+ bundle config set retry 3
40
+ bundle install
41
+
42
+ - name: Run rubocop
43
+ run: |
44
+ bundle exec rubocop --parallel
45
+
46
+ - name: Run tests
47
+ run: bundle exec rspec
@@ -2,53 +2,53 @@ name: Bump version and Release
2
2
  on:
3
3
  release:
4
4
  types: [published]
5
-
5
+
6
6
  jobs:
7
7
  release:
8
8
  runs-on: ubuntu-latest
9
9
  strategy:
10
10
  fail-fast: true
11
11
 
12
- steps:
13
- - uses: actions/checkout@master
14
- with:
15
- persist-credentials: false
16
- fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
12
+ steps:
13
+ - name: Checkout source code
14
+ uses: actions/checkout@v2
15
+ with:
16
+ persist-credentials: false
17
+ fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
18
+
19
+ - name: Install required ruby version
20
+ uses: ruby/setup-ruby@v1
21
+
22
+ - name: Get version from latest tag
23
+ id: get_version
24
+ uses: battila7/get-version-action@v2
25
+
26
+ - name: Bump version
27
+ run: |
28
+ gem install -N gem-release
29
+ git config --local user.email "action@github.com"
30
+ git config --local user.name "GitHub Action"
31
+ gem bump --skip-ci --version ${{ steps.get_version.outputs.version-without-v }}
17
32
 
18
- - uses: actions/setup-ruby@v1
19
- with:
20
- ruby-version: '2.6'
21
-
22
- - name: Get version from latest tag
23
- id: get_version
24
- uses: battila7/get-version-action@v2
33
+ - name: Push changes
34
+ uses: ad-m/github-push-action@master
35
+ with:
36
+ # GitHub Actions token does not support pushing to protected branches.
37
+ # github_token: ${{ secrets.GITHUB_TOKEN }}
38
+ #
39
+ # A manually populated`PERSONAL_ACCESS_TOKEN` environment variable
40
+ # with permissions to push to a protected branch must be used.
41
+ # not ideal - keep eyes open for a better solution
42
+ github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
25
43
 
26
- - name: Bump version
27
- run: |
28
- gem install -N gem-release
29
- git config --local user.email "action@github.com"
30
- git config --local user.name "GitHub Action"
31
- gem bump --skip-ci --version ${{ steps.get_version.outputs.version-without-v }}
32
-
33
- - name: Push changes
34
- uses: ad-m/github-push-action@master
35
- with:
36
- # GitHub Actions token does not support pushing to protected branches.
37
- # github_token: ${{ secrets.GITHUB_TOKEN }}
38
- #
39
- # A manually populated`PERSONAL_ACCESS_TOKEN` environment variable
40
- # with permissions to push to a protected branch must be used.
41
- # not ideal - keep eyes open for a better solution
42
- github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
43
-
44
- - name: Release gem to rubygems.org
45
- run: |
46
- set +x
47
- mkdir -p ~/.gem
48
- cat << EOF > ~/.gem/credentials
49
- ---
50
- :rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}
51
- EOF
52
- chmod 0600 ~/.gem/credentials
53
- set -x
54
- gem release
44
+ - name: Release gem to rubygems.org
45
+ run: |
46
+ set +x
47
+ mkdir -p ~/.gem
48
+ cat << EOF > ~/.gem/credentials
49
+ ---
50
+ :rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}
51
+ EOF
52
+ chmod 0600 ~/.gem/credentials
53
+ set -x
54
+ gem release
data/.rubocop.yml CHANGED
@@ -48,7 +48,7 @@ Metrics/ClassLength:
48
48
  - app/controllers/orders_controller.rb
49
49
  - app/models/order.rb
50
50
  Metrics/BlockLength:
51
- ExcludedMethods: ['describe', 'context']
51
+ IgnoredMethods: ['describe', 'context']
52
52
  Exclude:
53
53
  - config/environments/**/**
54
54
  - Guardfile
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.6.3
1
+ ruby-2.7.2
data/Guardfile CHANGED
@@ -17,7 +17,7 @@
17
17
  #
18
18
  # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
19
19
 
20
- # Note: The cmd option is now required due to the increasing number of ways
20
+ # NOTE: The cmd option is now required due to the increasing number of ways
21
21
  # rspec may be run, below are examples of the most common uses.
22
22
  # * bundler: 'bundle exec rspec'
23
23
  # * bundler binstubs: 'bin/rspec'
data/README.md CHANGED
@@ -60,18 +60,20 @@ company_token = 'my-company-token'
60
60
  @client = FinApps::REST::Client.new company_identifier, company_token
61
61
  ```
62
62
 
63
- ## More Information
63
+ ### Release
64
64
 
65
- Please check the [FinApps wiki][wiki] for extended documentation.
65
+ For approved Pull Requests against the master branch, an aggregated release draft will be generated. This draft by default bumps the patch number of previous version.
66
+ Please refer to the [Release Drafter] action documentation for information on this process, specifically how to bump the major or minor numbers of the gem version.
66
67
 
68
+ As soon as this draft is converted into an actual release, an automated process also running on GitHub actions will be triggered to build the gem and release it to rubygems.org.
67
69
 
68
- [FinancialApps.com][financialapps]
69
70
 
71
+ [FinancialApps.com][financialapps]
70
72
 
71
73
  [bundler]: http://bundler.io
72
74
  [financialapps]: https://financialapps.com
73
- [wiki]: https://github.com/finapps/ruby-client/wiki
74
75
  [builder]: http://builder.rubyforge.org/
75
76
  [bundler]: http://bundler.io
76
77
  [rubygems]: http://rubygems.org
77
78
  [build_status]: http://teamciti.powerwallet.com/viewType.html?buildTypeId=FaRuby_BuildMaster&guest=1
79
+ [Release Drafter]: https://github.com/release-drafter/release-drafter
data/finapps.gemspec CHANGED
@@ -20,19 +20,20 @@ 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.10'
23
+ spec.add_runtime_dependency 'finapps_core', '~> 5.0', '>= 5.0.15'
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'
27
27
  spec.add_development_dependency 'guard', '~> 2.16', '>= 2.16.1'
28
28
  spec.add_development_dependency 'guard-rspec', '~> 4.7', '>= 4.7.3'
29
29
  spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.1'
30
- spec.add_development_dependency 'rspec', '~> 3.9', '>= 3.9.0'
31
- spec.add_development_dependency 'rubocop', '~> 0.86', '>= 0.86.0'
32
- spec.add_development_dependency 'rubocop-performance', '~> 1.6', '>= 1.6.1'
33
- spec.add_development_dependency 'rubocop-rspec', '~> 1.40', '>= 1.40.0'
34
- spec.add_development_dependency 'sinatra', '~> 2.0', '>= 2.0.8'
35
- spec.add_development_dependency 'webmock', '~> 3.8', '>= 3.8.0'
30
+ spec.add_development_dependency 'rspec', '~> 3.10', '>= 3.10.0'
31
+ spec.add_development_dependency 'rubocop', '~> 1.9', '>= 1.9.1'
32
+ spec.add_development_dependency 'rubocop-performance', '~> 1.9', '>= 1.9.2'
33
+ spec.add_development_dependency 'rubocop-rake', '~> 0.5', '>= 0.5.1'
34
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.2', '>= 2.2.0'
35
+ spec.add_development_dependency 'sinatra', '~> 2.1', '>= 2.1.0'
36
+ spec.add_development_dependency 'webmock', '~> 3.11', '>= 3.11.2'
36
37
 
37
38
  spec.extra_rdoc_files = %w[README.md LICENSE.txt]
38
39
  spec.rdoc_options = %w[--line-numbers --inline-source --title finapps-ruby --main README.md]
data/lib/finapps.rb CHANGED
@@ -35,6 +35,7 @@ require 'finapps/rest/esign_templates'
35
35
  require 'finapps/rest/documents_upload_types'
36
36
  require 'finapps/rest/signed_documents_downloads'
37
37
  require 'finapps/rest/documents_orders_notifications'
38
+ require 'finapps/rest/screenings'
38
39
 
39
40
  require 'finapps/rest/plaid/plaid_resources'
40
41
  require 'finapps/rest/plaid/plaid_webhooks'
@@ -37,6 +37,7 @@ module FinApps
37
37
  portfolios_consumers
38
38
  portfolio_reports
39
39
  products
40
+ screenings
40
41
  sessions
41
42
  signed_documents_downloads
42
43
  tenant_settings
@@ -82,7 +83,7 @@ module FinApps
82
83
 
83
84
  def camelize(term)
84
85
  string = term.to_s
85
- string = string.sub(/^[a-z\d]*/) { $&.capitalize }
86
+ string = string.sub(/^[a-z\d]*/) { Regexp.last_match(0).capitalize }
86
87
  string.gsub(%r{(?:_|(/))([a-z\d]*)}) do
87
88
  Regexp.last_match(2).capitalize.to_s
88
89
  end
@@ -62,9 +62,9 @@ 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
 
@@ -72,8 +72,8 @@ module FinApps
72
72
  search_arr = []
73
73
  if /\s/.match?(term)
74
74
  term.split.each do |t|
75
- search_arr.append("first_name": t)
76
- search_arr.append("last_name": t)
75
+ search_arr.append(first_name: t)
76
+ search_arr.append(last_name: t)
77
77
  end
78
78
  end
79
79
  search_arr
@@ -17,7 +17,12 @@ module FinApps
17
17
 
18
18
  def show(id)
19
19
  not_blank(id, :order_id)
20
- super(id, "documents/orders/#{id}")
20
+
21
+ if matches_token_format?(id)
22
+ show_by_token id
23
+ else
24
+ show_by_id id
25
+ end
21
26
  end
22
27
 
23
28
  def create(params)
@@ -45,6 +50,20 @@ module FinApps
45
50
 
46
51
  private
47
52
 
53
+ def show_by_id(id)
54
+ path = "documents/orders/#{id}"
55
+ send_request path, :get
56
+ end
57
+
58
+ def show_by_token(jwt)
59
+ path = "documents/retrieve_order?token=#{jwt}"
60
+ send_request path, :get
61
+ end
62
+
63
+ def matches_token_format?(str)
64
+ str.match(/^.+\..+\..+$/)
65
+ end
66
+
48
67
  def build_filter(params)
49
68
  search_query(params[:searchTerm])
50
69
  .merge(consumer_query(params[:consumer]))
@@ -76,7 +95,7 @@ module FinApps
76
95
  {"applicant.first_name": term},
77
96
  {"applicant.last_name": term},
78
97
  {
79
- "reference_no": {
98
+ reference_no: {
80
99
  "$regex": "^#{term}", "$options": 'i'
81
100
  }
82
101
  }
@@ -86,7 +105,7 @@ module FinApps
86
105
  def tag_query(tag)
87
106
  return {} unless tag
88
107
 
89
- {"tag": tag.empty? ? nil : tag}
108
+ {tag: tag.empty? ? nil : tag}
90
109
  end
91
110
 
92
111
  def status_query(status)
@@ -98,7 +117,7 @@ module FinApps
98
117
  def consumer_query(consumer)
99
118
  return {} unless consumer
100
119
 
101
- {"consumer_id": consumer.empty? ? nil : consumer}
120
+ {consumer_id: consumer.empty? ? nil : consumer}
102
121
  end
103
122
  end
104
123
  end
@@ -3,11 +3,11 @@
3
3
  module FinApps
4
4
  module REST
5
5
  class DocumentsOrdersNotifications < FinAppsCore::REST::Resources
6
- def create(id)
6
+ def create(id, params = [])
7
7
  not_blank(id, :id)
8
8
 
9
9
  path = "documents/orders/#{ERB::Util.url_encode(id)}/notify"
10
- super nil, path
10
+ super params, path
11
11
  end
12
12
  end
13
13
  end
@@ -18,6 +18,14 @@ module FinApps
18
18
  not_blank(doc_id, :doc_id)
19
19
  super(nil, "documents/orders/#{order_id}/#{doc_id}")
20
20
  end
21
+
22
+ def destroy_by_consumer(consumer_id, document_id)
23
+ not_blank(consumer_id, :consumer_id)
24
+ not_blank(document_id, :document_id)
25
+
26
+ path = "consumers/#{consumer_id}/documents/#{document_id}"
27
+ send_request path, :delete
28
+ end
21
29
  end
22
30
  end
23
31
  end
@@ -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
@@ -81,7 +81,7 @@ module FinApps
81
81
  end
82
82
 
83
83
  def search_query_object(term)
84
- [{"public_id": {"$regex": "^#{term}", "$options": 'i'}},
84
+ [{public_id: {"$regex": "^#{term}", "$options": 'i'}},
85
85
  {"assignment.last_name": term},
86
86
  {"applicant.first_name": term},
87
87
  {"applicant.last_name": term},
@@ -95,9 +95,9 @@ module FinApps
95
95
  def status_query(status)
96
96
  if status
97
97
  if status.is_a?(Array)
98
- {"status": {"$in": status.map(&:to_i)}}
98
+ {status: {"$in": status.map(&:to_i)}}
99
99
  else
100
- {"status": status.to_i}
100
+ {status: status.to_i}
101
101
  end
102
102
  else
103
103
  {}
@@ -115,7 +115,7 @@ module FinApps
115
115
 
116
116
  def consumer_query(consumer)
117
117
  if consumer
118
- {"consumer_id": consumer.empty? ? nil : consumer}
118
+ {consumer_id: consumer.empty? ? nil : consumer}
119
119
  else
120
120
  {}
121
121
  end
@@ -125,8 +125,8 @@ module FinApps
125
125
  if !search_term && !nil_or_empty?(relation)
126
126
  {
127
127
  "$or": [
128
- {"public_id": {"$in": relation}},
129
- {"original_order_id": {"$in": relation}}
128
+ {public_id: {"$in": relation}},
129
+ {original_order_id: {"$in": relation}}
130
130
  ]
131
131
  }
132
132
  else
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../utils/query_builder'
4
+
5
+ module FinApps
6
+ module REST
7
+ class Screenings < FinAppsCore::REST::Resources # :nodoc:
8
+ include FinApps::Utils::QueryBuilder
9
+
10
+ def show(id)
11
+ not_blank(id, :session_id)
12
+
13
+ path = "#{end_point}/#{ERB::Util.url_encode(id)}/resume"
14
+ super(nil, path)
15
+ end
16
+
17
+ def create(params)
18
+ not_blank(params, :params)
19
+ super params
20
+ end
21
+
22
+ def list(params = nil)
23
+ return super if params.nil?
24
+ fail FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
25
+
26
+ super build_query_path(end_point, params)
27
+ end
28
+
29
+ def update(id, params)
30
+ not_blank(id, :session_id)
31
+ not_blank(params, :params)
32
+
33
+ path = "#{end_point}/#{ERB::Util.url_encode(id)}"
34
+ super params, path
35
+ end
36
+
37
+ def destroy(id)
38
+ not_blank(id, :session_id)
39
+
40
+ super
41
+ end
42
+
43
+ private
44
+
45
+ def build_filter(params)
46
+ search_query(params[:searchTerm])
47
+ end
48
+
49
+ def search_query(term)
50
+ return {} unless term
51
+
52
+ query = search_query_object(term)
53
+ {"$or": query}
54
+ end
55
+
56
+ def search_query_object(term)
57
+ [
58
+ {"consumer.public_id": term},
59
+ {"consumer.email": term}
60
+ ]
61
+ end
62
+ end
63
+ end
64
+ end