finapps 5.0.41 → 5.0.47

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b293938018fe5cdcccba1a161ca630d5d1e602a634483c5b1281adf4611c76f
4
- data.tar.gz: 2ede0f7dfe44afe57006c8d685f0b550104d3c1395e98d1cf75538f870fbd6bc
3
+ metadata.gz: 487960017ebcda19c22179e090cb9328708a57dd5e54e0d05cc27e5660251d57
4
+ data.tar.gz: 95abe37a2a66f36f973eb453d2302df92a9d1208c2ad5f20b4b6caf21737c358
5
5
  SHA512:
6
- metadata.gz: e14eb4bc25a190d5803163b9cb60c2440be01b1172779c4a16d54f538a76b85e1c4650c7c98776b0185ffa5292e536142a4f899023f5fb6340ba0906f4ca2797
7
- data.tar.gz: 0b7fe2a98897d7908657cf9579312449f236ed8611db113b5c88b46a00450ea1ffdfb9d43a2ae155c60197748ffa5a2081702caffc8b4e4a433b25a7d40e9edc
6
+ metadata.gz: 5df1695cc14dc3a96d47867786a7f564806b5f58d56511c9e08482e3e9ce4767ac03257c055f644b2517d25666a70d0b6312f43fd218607258c642d967061a98
7
+ data.tar.gz: 9f063fed1bafb02f77ed3b10230c77d757e0ae09c0f7d202f9d78d699dc1d7ba5f0809d59591f608c32aa9c81d86795b932ab5220d0adc13fcea07b2583c4d26
@@ -13,12 +13,10 @@ jobs:
13
13
  steps:
14
14
  - uses: actions/checkout@v1
15
15
 
16
- - name: Use Ruby 2.6
17
- uses: actions/setup-ruby@v1
18
- with:
19
- ruby-version: '2.6'
16
+ - name: Install required ruby
17
+ uses: ruby/setup-ruby@v1
20
18
 
21
- - uses: actions/cache@v1
19
+ - uses: actions/cache@v2
22
20
  with:
23
21
  path: vendor/bundle
24
22
  key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
@@ -27,7 +25,7 @@ jobs:
27
25
 
28
26
  - name: Install gems
29
27
  run: |
30
- gem install bundler
28
+ gem install -N bundler
31
29
  bundle config path vendor/bundle
32
30
  bundle install --jobs 4 --retry 3
33
31
 
@@ -12,6 +12,7 @@ jobs:
12
12
  steps:
13
13
  - uses: actions/checkout@master
14
14
  with:
15
+ persist-credentials: false
15
16
  fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
16
17
 
17
18
  - uses: actions/setup-ruby@v1
@@ -22,13 +23,23 @@ jobs:
22
23
  id: get_version
23
24
  uses: battila7/get-version-action@v2
24
25
 
25
- - name: Bump version
26
+ - name: Bump version
26
27
  run: |
27
28
  gem install -N gem-release
28
29
  git config --local user.email "action@github.com"
29
30
  git config --local user.name "GitHub Action"
30
31
  gem bump --skip-ci --version ${{ steps.get_version.outputs.version-without-v }}
31
- git push origin HEAD:master
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 }}
32
43
 
33
44
  - name: Release gem to rubygems.org
34
45
  run: |
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
@@ -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.10'
23
+ spec.add_runtime_dependency 'finapps_core', '~> 5.0', '>= 5.0.13'
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'
@@ -28,9 +28,9 @@ Gem::Specification.new do |spec|
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
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'
31
+ spec.add_development_dependency 'rubocop', '~> 0.87', '>= 0.87.0'
32
+ spec.add_development_dependency 'rubocop-performance', '~> 1.7', '>= 1.7.0'
33
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.41', '>= 1.41.0'
34
34
  spec.add_development_dependency 'sinatra', '~> 2.0', '>= 2.0.8'
35
35
  spec.add_development_dependency 'webmock', '~> 3.8', '>= 3.8.0'
36
36
 
@@ -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
@@ -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]))
@@ -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
@@ -0,0 +1,58 @@
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
+ private
38
+
39
+ def build_filter(params)
40
+ search_query(params[:searchTerm])
41
+ end
42
+
43
+ def search_query(term)
44
+ return {} unless term
45
+
46
+ query = search_query_object(term)
47
+ {"$or": query}
48
+ end
49
+
50
+ def search_query_object(term)
51
+ [
52
+ {"consumer.public_id": term},
53
+ {"consumer.email": term}
54
+ ]
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FinApps
4
- VERSION = '5.0.41'
4
+ VERSION = '5.0.47'
5
5
  end
@@ -16,3 +16,11 @@ RSpec.shared_examples 'a successful request' do |_parameter|
16
16
  expect(subject[ERROR_MESSAGES]).to be_empty
17
17
  end
18
18
  end
19
+
20
+ RSpec.shared_examples 'a request that raises an error' do |_parameter|
21
+ it do
22
+ expect { subject }.to raise_error(
23
+ FinAppsCore::MissingArgumentsError
24
+ )
25
+ end
26
+ end
@@ -17,7 +17,7 @@ RSpec.describe FinApps::REST::DocumentsOrdersNotifications do
17
17
  end
18
18
 
19
19
  context 'when invalid id is provided' do
20
- let(:create) { subject.create(:invalid_id) }
20
+ let(:create) { subject.create(:invalid_id, ['1234']) }
21
21
  let(:results) { create[RESULTS] }
22
22
  let(:error_messages) { create[ERROR_MESSAGES] }
23
23
 
@@ -30,7 +30,7 @@ RSpec.describe FinApps::REST::DocumentsOrdersNotifications do
30
30
  end
31
31
 
32
32
  context 'with valid id' do
33
- let(:create) { subject.create(:valid_id) }
33
+ let(:create) { subject.create(:valid_id, ['1234']) }
34
34
  let(:results) { create[RESULTS] }
35
35
  let(:error_messages) { create[ERROR_MESSAGES] }
36
36
 
@@ -6,14 +6,6 @@ require 'rest/api_request'
6
6
  RSpec.describe FinApps::REST::DocumentsOrders do
7
7
  include SpecHelpers::Client
8
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
9
  describe '#list' do
18
10
  subject(:list) { described_class.new(client).list(params) }
19
11
 
@@ -134,14 +126,28 @@ RSpec.describe FinApps::REST::DocumentsOrders do
134
126
  let(:error_messages) { show[1] }
135
127
 
136
128
  context 'with valid id' do
137
- let(:id) { :valid_order_id }
129
+ context 'when id is an identifier' do
130
+ let(:id) { :valid_order_id }
138
131
 
139
- it_behaves_like 'an API request'
140
- it_behaves_like 'a successful request'
141
- it('results is a Hash') { expect(results).to be_a(Hash) }
132
+ it_behaves_like 'an API request'
133
+ it_behaves_like 'a successful request'
134
+ it('has an order_id node in the response') do
135
+ expect(results).to have_key(:order_id)
136
+ end
137
+ end
142
138
 
143
- it('performs a get and returns the response') do
144
- expect(results).to have_key(:order_id)
139
+ context 'when id is a token' do
140
+ let(:id) { '0123456abc.0123456abc.0123456abc' }
141
+
142
+ it_behaves_like 'an API request'
143
+ it_behaves_like 'a successful request'
144
+ it('has an order node in the response') do
145
+ expect(results).to have_key(:order)
146
+ end
147
+
148
+ it('has a consumer node in the response') do
149
+ expect(results).to have_key(:consumer)
150
+ end
145
151
  end
146
152
  end
147
153
 
@@ -101,4 +101,57 @@ RSpec.describe FinApps::REST::DocumentsUploads do
101
101
  end
102
102
  end
103
103
  end
104
+
105
+ describe '#destroy_by_consumer' do
106
+ subject(:destroy_by_consumer) do
107
+ described_class.new(client).destroy_by_consumer(consumer_id, document_id)
108
+ end
109
+
110
+ let(:results) { destroy_by_consumer[0] }
111
+ let(:error_messages) { destroy_by_consumer[1] }
112
+
113
+ context 'with valid params' do
114
+ let(:consumer_id) { :valid_consumer_id }
115
+ let(:document_id) { :valid_document_id }
116
+
117
+ it_behaves_like 'an API request'
118
+ it_behaves_like 'a successful request'
119
+ it('results is nil') { expect(results).to be_nil }
120
+ end
121
+
122
+ context 'with invalid consumer_id' do
123
+ let(:consumer_id) { :invalid_consumer_id }
124
+ let(:document_id) { :valid_document_id }
125
+
126
+ it_behaves_like 'an API request'
127
+ it('results is nil') { expect(results).to be_nil }
128
+
129
+ it('error messages array is populated') do
130
+ expect(error_messages.first.downcase).to eq('resource not found')
131
+ end
132
+ end
133
+
134
+ context 'with invalid document id' do
135
+ let(:consumer_id) { :valid_consumer_id }
136
+ let(:document_id) { :invalid_document_id }
137
+
138
+ it_behaves_like 'an API request'
139
+ it('results is nil') { expect(results).to be_nil }
140
+
141
+ it('error messages array is populated') do
142
+ expect(error_messages.first.downcase).to eq('resource not found')
143
+ end
144
+ end
145
+
146
+ context 'with missing id' do
147
+ let(:consumer_id) { nil }
148
+ let(:document_id) { nil }
149
+
150
+ it do
151
+ expect { destroy_by_consumer }.to raise_error(
152
+ FinAppsCore::MissingArgumentsError
153
+ )
154
+ end
155
+ end
156
+ end
104
157
  end
@@ -0,0 +1,198 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helpers/client'
4
+ require 'rest/api_request'
5
+
6
+ RSpec.describe FinApps::REST::Screenings do
7
+ include SpecHelpers::Client
8
+
9
+ describe '#list' do
10
+ subject(:list) { described_class.new(client).list(params) }
11
+
12
+ let(:results) { list[0] }
13
+ let(:error_messages) { list[1] }
14
+
15
+ context 'with valid params' do
16
+ let(:params) do
17
+ {
18
+ page: 2,
19
+ sort: 'date_created',
20
+ requested: 25,
21
+ searchTerm: 'term'
22
+ }
23
+ end
24
+
25
+ context 'without searchTerm' do
26
+ let(:params) { {searchTerm: nil, page: 2} }
27
+
28
+ it_behaves_like 'an API request'
29
+ it_behaves_like 'a successful request'
30
+ it 'performs a get and returns the response' do
31
+ expect(results).to have_key(:records)
32
+ end
33
+
34
+ it 'builds query and sends proper request' do
35
+ list
36
+ url = "#{versioned_api_path}/screenings?page=2"
37
+ expect(WebMock).to have_requested(:get, url)
38
+ end
39
+ end
40
+
41
+ # rubocop:disable RSpec/ExampleLength
42
+ context 'with searchTerm' do
43
+ it_behaves_like 'an API request'
44
+ it_behaves_like 'a successful request'
45
+ it 'performs a get and returns the response' do
46
+ expect(results).to have_key(:records)
47
+ end
48
+
49
+ it 'builds query and sends proper request' do
50
+ list
51
+ url =
52
+ "#{versioned_api_path}/screenings?filter=%7B%22$or%22:%5B%7B%22" \
53
+ 'consumer.public_id%22:%22term%22%7D,%7B%22consumer.email%22:%22' \
54
+ 'term%22%7D%5D%7D&page=2&requested=25&sort=date_created'
55
+
56
+ expect(WebMock).to have_requested(:get, url)
57
+ end
58
+ end
59
+ # rubocop:enable RSpec/ExampleLength
60
+ end
61
+
62
+ context 'with invalid params' do
63
+ let(:params) { ['invalid array'] }
64
+
65
+ it { expect { list }.to raise_error(FinAppsCore::InvalidArgumentsError) }
66
+ end
67
+
68
+ context 'with missing params' do
69
+ let(:params) { nil }
70
+
71
+ it_behaves_like 'an API request'
72
+ it_behaves_like 'a successful request'
73
+ it('performs a get and returns the response') do
74
+ expect(results).to have_key(:records)
75
+ end
76
+ end
77
+ end
78
+
79
+ describe '#show' do
80
+ subject(:show) { described_class.new(client).show(id) }
81
+
82
+ let(:results) { show[0] }
83
+ let(:error_messages) { show[1] }
84
+
85
+ context 'with valid id' do
86
+ let(:id) { :valid_id }
87
+
88
+ it_behaves_like 'an API request'
89
+ it_behaves_like 'a successful request'
90
+ it('performs a get and returns the response') do
91
+ expect(results).to have_key(:session)
92
+ end
93
+ end
94
+
95
+ context 'with invalid id' do
96
+ let(:id) { :invalid_id }
97
+
98
+ it { expect(results).to be_nil }
99
+ it { expect(error_messages).not_to be_empty }
100
+ end
101
+
102
+ context 'when missing id' do
103
+ let(:id) { nil }
104
+
105
+ it_behaves_like 'a request that raises an error'
106
+ end
107
+ end
108
+
109
+ describe '#create' do
110
+ subject(:create) { described_class.new(client).create(params) }
111
+
112
+ let(:results) { create[0] }
113
+ let(:error_messages) { create[1] }
114
+
115
+ context 'with valid params' do
116
+ let(:params) do
117
+ {
118
+ "email": 'validemail@financialapps.com',
119
+ "first_name": 'Geo',
120
+ "last_name": 'Metric',
121
+ "public_id": '1234'
122
+ }
123
+ end
124
+
125
+ it_behaves_like 'an API request'
126
+ it_behaves_like 'a successful request'
127
+ it('results is a Hash') { expect(results).to be_a(Hash) }
128
+
129
+ it('performs a post and returns the response') do
130
+ expect(results).to have_key(:question)
131
+ end
132
+ end
133
+
134
+ context 'with invalid params' do
135
+ let(:params) { {"params": 'invalid'} }
136
+
137
+ it { expect { create }.not_to raise_error }
138
+ it('results is nil') { expect(results).to be_nil }
139
+
140
+ it('error messages array is populated') do
141
+ expect(error_messages.first.downcase).to eq('invalid request body')
142
+ end
143
+ end
144
+
145
+ context 'with missing params' do
146
+ let(:params) { nil }
147
+
148
+ it_behaves_like 'a request that raises an error'
149
+ end
150
+ end
151
+
152
+ describe '#update' do
153
+ subject(:update) { described_class.new(client).update(id, params) }
154
+
155
+ let(:params) { {} }
156
+ let(:results) { update[0] }
157
+ let(:error_messages) { update[1] }
158
+
159
+ context 'with valid session id' do
160
+ let(:id) { :valid_id }
161
+
162
+ context 'with valid params' do
163
+ let(:params) { {"question_id": '1234'} }
164
+
165
+ it_behaves_like 'an API request'
166
+ it_behaves_like 'a successful request'
167
+ it('returns the next question') do
168
+ expect(results).to have_key(:question)
169
+ end
170
+ end
171
+
172
+ context 'with invalid params' do
173
+ let(:params) { {"question_id": 'invalid'} }
174
+
175
+ it_behaves_like 'an API request'
176
+ it('results is nil') { expect(results).to be_nil }
177
+
178
+ it('error messages array is populated') do
179
+ expect(error_messages.first.downcase).to eq('question with id (invalid) not found ')
180
+ end
181
+ end
182
+ end
183
+
184
+ context 'with invalid session id' do
185
+ let(:id) { :invalid_id }
186
+ let(:params) { {"question_id": '1234'} }
187
+
188
+ it_behaves_like 'an API request'
189
+ it('results is nil') { expect(results).to be_nil }
190
+
191
+ it('error messages array is populated') do
192
+ expect(error_messages.first.downcase).to eq(
193
+ 'resource not found'
194
+ )
195
+ end
196
+ end
197
+ end
198
+ end