finapps 4.0.6 → 4.0.7
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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/lib/finapps.rb +8 -0
- data/lib/finapps/rest/alert_definitions.rb +24 -0
- data/lib/finapps/rest/alert_occurrences.rb +25 -0
- data/lib/finapps/rest/client.rb +8 -0
- data/lib/finapps/rest/consumers_portfolios.rb +20 -0
- data/lib/finapps/rest/portfolio_reports.rb +18 -0
- data/lib/finapps/rest/portfolios.rb +43 -0
- data/lib/finapps/rest/portfolios_alerts.rb +34 -0
- data/lib/finapps/rest/portfolios_available_consumers.rb +20 -0
- data/lib/finapps/rest/portfolios_consumers.rb +45 -0
- data/lib/finapps/utils/query_builder.rb +5 -0
- data/lib/finapps/version.rb +1 -1
- data/spec/rest/alert_definitions_spec.rb +78 -0
- data/spec/rest/alert_occurrences_spec.rb +44 -0
- data/spec/rest/client_spec.rb +34 -0
- data/spec/rest/consumers_portfolios_spec.rb +54 -0
- data/spec/rest/portfolio_reports_spec.rb +44 -0
- data/spec/rest/portfolios_alerts_spec.rb +125 -0
- data/spec/rest/portfolios_available_consumers_spec.rb +54 -0
- data/spec/rest/portfolios_consumers_spec.rb +183 -0
- data/spec/rest/portfolios_spec.rb +181 -0
- data/spec/support/fake_api.rb +54 -0
- data/spec/support/fixtures/alert_definition.json +17 -0
- data/spec/support/fixtures/alert_definitions.json +24 -0
- data/spec/support/fixtures/alert_occurrences.json +32 -0
- data/spec/support/fixtures/multiple_consumer_subscribe_error.json +7 -0
- data/spec/support/fixtures/portfolio.json +9 -0
- data/spec/support/fixtures/portfolio_reports.json +38 -0
- data/spec/support/fixtures/portfolios.json +16 -0
- data/spec/support/fixtures/portfolios_alerts.json +19 -0
- data/spec/support/fixtures/portfolios_available_consumers.json +20 -0
- data/spec/support/fixtures/portfolios_consumers.json +14 -0
- data/spec/support/fixtures/single_consumer_subscribe_error.json +5 -0
- metadata +58 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3374db10baa1952267135d60010f5a68566349af848c02675b56f5690ae73fd
|
4
|
+
data.tar.gz: 9bdd765359d184a02c2d52a55f2a270c7ca1a3060ef0633bb50c2034c4f1a45e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4bfa0fd0777d1f3c28537a13cf16f0ff4d57a3a849406fc7b51ddc76a3afe0e24f72632bf5c5e2393c932bf12d2fc12798eb1b6940a439a24b207cc8899f6f1
|
7
|
+
data.tar.gz: fd8d2d0168f5c559d3eae6b0f1a5411f18c500e2f43ffb8be7370af406fb680a65703aa9e1be8457d39bb07914541ccb649675990433bc541b2418aeacf89803
|
data/.travis.yml
CHANGED
data/lib/finapps.rb
CHANGED
@@ -28,6 +28,14 @@ require 'finapps/rest/order_refreshes'
|
|
28
28
|
require 'finapps/rest/statements'
|
29
29
|
require 'finapps/rest/tenant_settings'
|
30
30
|
require 'finapps/rest/tenant_app_settings'
|
31
|
+
require 'finapps/rest/portfolios'
|
32
|
+
require 'finapps/rest/alert_definitions'
|
33
|
+
require 'finapps/rest/alert_occurrences'
|
34
|
+
require 'finapps/rest/portfolios_available_consumers'
|
35
|
+
require 'finapps/rest/portfolios_alerts'
|
36
|
+
require 'finapps/rest/portfolios_consumers'
|
37
|
+
require 'finapps/rest/consumers_portfolios'
|
38
|
+
require 'finapps/rest/portfolio_reports'
|
31
39
|
|
32
40
|
require 'finapps/utils/query_builder'
|
33
41
|
require 'finapps/version' unless defined?(FinApps::VERSION)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FinApps
|
4
|
+
module REST
|
5
|
+
class AlertDefinitions < FinAppsCore::REST::Resources
|
6
|
+
include FinApps::Utils::QueryBuilder
|
7
|
+
END_POINT = 'portfolio/alerts/definitions'
|
8
|
+
|
9
|
+
def list(params = nil)
|
10
|
+
return super END_POINT if params.nil?
|
11
|
+
raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
|
12
|
+
|
13
|
+
super build_query_path(END_POINT, params)
|
14
|
+
end
|
15
|
+
|
16
|
+
def show(id)
|
17
|
+
not_blank(id, :id)
|
18
|
+
path = "#{END_POINT}/#{ERB::Util.url_encode(id)}"
|
19
|
+
|
20
|
+
super nil, path
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FinApps
|
4
|
+
module REST
|
5
|
+
class AlertOccurrences < FinAppsCore::REST::Resources
|
6
|
+
include FinApps::Utils::QueryBuilder
|
7
|
+
END_POINT = 'portfolio/alerts/occurrences'
|
8
|
+
|
9
|
+
def list(params = nil)
|
10
|
+
return super END_POINT if params.nil?
|
11
|
+
raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
|
12
|
+
|
13
|
+
super build_query_path(END_POINT, params)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def build_filter(params)
|
19
|
+
filter = {}
|
20
|
+
filter[:"portfolio.id"] = params[:portfolio_id] if params[:portfolio_id]
|
21
|
+
filter
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/finapps/rest/client.rb
CHANGED
@@ -7,6 +7,9 @@ module FinApps
|
|
7
7
|
module REST
|
8
8
|
class Client < FinAppsCore::REST::BaseClient # :nodoc:
|
9
9
|
RESOURCES = %i[
|
10
|
+
alert_definitions
|
11
|
+
alert_occurrences
|
12
|
+
consumers_portfolios
|
10
13
|
institutions
|
11
14
|
institutions_forms
|
12
15
|
orders
|
@@ -20,6 +23,11 @@ module FinApps
|
|
20
23
|
operators_password_resets
|
21
24
|
password_resets
|
22
25
|
products
|
26
|
+
portfolios
|
27
|
+
portfolios_alerts
|
28
|
+
portfolios_available_consumers
|
29
|
+
portfolios_consumers
|
30
|
+
portfolio_reports
|
23
31
|
sessions
|
24
32
|
statements
|
25
33
|
consumers
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FinApps
|
4
|
+
module REST
|
5
|
+
class ConsumersPortfolios < FinAppsCore::REST::Resources
|
6
|
+
include FinApps::Utils::QueryBuilder
|
7
|
+
|
8
|
+
def list(id, params = nil)
|
9
|
+
not_blank(id)
|
10
|
+
|
11
|
+
path = "consumers/#{ERB::Util.url_encode(id)}/portfolios"
|
12
|
+
return super path if params.nil?
|
13
|
+
|
14
|
+
raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
|
15
|
+
|
16
|
+
super build_query_path(path, params)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FinApps
|
4
|
+
module REST
|
5
|
+
class PortfolioReports < FinAppsCore::REST::Resources
|
6
|
+
include FinApps::Utils::QueryBuilder
|
7
|
+
|
8
|
+
def list(params = nil)
|
9
|
+
path = 'portfolio/reports'
|
10
|
+
|
11
|
+
return super path if params.nil?
|
12
|
+
raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
|
13
|
+
|
14
|
+
super build_query_path(path, params)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FinApps
|
4
|
+
module REST
|
5
|
+
class Portfolios < FinAppsCore::REST::Resources
|
6
|
+
include FinApps::Utils::QueryBuilder
|
7
|
+
|
8
|
+
def list(params = nil)
|
9
|
+
return super if params.nil?
|
10
|
+
raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
|
11
|
+
|
12
|
+
super build_query_path(end_point, params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def show(id)
|
16
|
+
not_blank(id, :id)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def create(params)
|
21
|
+
not_blank(params, :params)
|
22
|
+
super params
|
23
|
+
end
|
24
|
+
|
25
|
+
def update(id, params)
|
26
|
+
not_blank(id, :id)
|
27
|
+
not_blank(params, :params)
|
28
|
+
|
29
|
+
path = "#{end_point}/#{ERB::Util.url_encode(id)}"
|
30
|
+
|
31
|
+
super params, path
|
32
|
+
end
|
33
|
+
|
34
|
+
def destroy(id)
|
35
|
+
not_blank(id, :id)
|
36
|
+
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
40
|
+
# need to populate build_filter method
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FinApps
|
4
|
+
module REST
|
5
|
+
class PortfoliosAlerts < FinAppsCore::REST::Resources
|
6
|
+
def list(portfolio_id)
|
7
|
+
not_blank(portfolio_id, :portfolio_id)
|
8
|
+
|
9
|
+
super build_path(portfolio_id)
|
10
|
+
end
|
11
|
+
|
12
|
+
def create(portfolio_id, alert_id, params = nil)
|
13
|
+
not_blank(portfolio_id, :portfolio_id)
|
14
|
+
not_blank(alert_id, :alert_id)
|
15
|
+
|
16
|
+
update params, build_path(portfolio_id, alert_id)
|
17
|
+
end
|
18
|
+
|
19
|
+
def destroy(portfolio_id, alert_id)
|
20
|
+
not_blank(portfolio_id, :portfolio_id)
|
21
|
+
not_blank(alert_id, :alert_id)
|
22
|
+
|
23
|
+
super nil, build_path(portfolio_id, alert_id)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def build_path(portfolio_id, alert_id = nil)
|
29
|
+
alert_path = alert_id ? "alerts/#{ERB::Util.url_encode(alert_id)}" : 'alerts'
|
30
|
+
"portfolios/#{ERB::Util.url_encode(portfolio_id)}/" + alert_path
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FinApps
|
4
|
+
module REST
|
5
|
+
class PortfoliosAvailableConsumers < FinAppsCore::REST::Resources
|
6
|
+
include FinApps::Utils::QueryBuilder
|
7
|
+
|
8
|
+
def list(portfolio_id, params = nil)
|
9
|
+
not_blank(portfolio_id, :portfolio_id)
|
10
|
+
|
11
|
+
path = "portfolios/#{ERB::Util.url_encode(portfolio_id)}/consumers/available"
|
12
|
+
return super path if params.nil?
|
13
|
+
|
14
|
+
raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
|
15
|
+
|
16
|
+
super build_query_path(path, params)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FinApps
|
4
|
+
module REST
|
5
|
+
class PortfoliosConsumers < FinAppsCore::REST::Resources
|
6
|
+
include FinApps::Utils::QueryBuilder
|
7
|
+
|
8
|
+
def list(portfolio_id, params = nil)
|
9
|
+
not_blank(portfolio_id, :portfolio_id)
|
10
|
+
|
11
|
+
path = build_path(portfolio_id)
|
12
|
+
return super path if params.nil?
|
13
|
+
|
14
|
+
raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params' unless params.is_a? Hash
|
15
|
+
|
16
|
+
super build_query_path(path, params)
|
17
|
+
end
|
18
|
+
|
19
|
+
def create(portfolio_id, params)
|
20
|
+
not_blank(portfolio_id, :portfolio_id)
|
21
|
+
not_blank(params, :params)
|
22
|
+
|
23
|
+
return super nil, build_path(portfolio_id, params) if params.is_a?(String) # Single Consumer Subscribe
|
24
|
+
|
25
|
+
# Array Consumer Subscribe
|
26
|
+
super params, build_path(portfolio_id)
|
27
|
+
end
|
28
|
+
|
29
|
+
def destroy(portfolio_id, consumer_id)
|
30
|
+
not_blank(portfolio_id, :portfolio_id)
|
31
|
+
not_blank(consumer_id, :consumer_id)
|
32
|
+
|
33
|
+
# Single Consumer Unsubscribe Only
|
34
|
+
super nil, build_path(portfolio_id, consumer_id)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def build_path(portfolio_id, consumer_id = nil)
|
40
|
+
consumer_path = consumer_id ? "consumers/#{ERB::Util.url_encode(consumer_id)}" : 'consumers'
|
41
|
+
"portfolios/#{ERB::Util.url_encode(portfolio_id)}/" + consumer_path
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -18,6 +18,11 @@ module FinApps
|
|
18
18
|
query_string = params_array.compact.join('&')
|
19
19
|
!query_string.empty? ? [root_url, query_string].join('?') : nil
|
20
20
|
end
|
21
|
+
|
22
|
+
def build_filter(_params)
|
23
|
+
# stub, to be overwritten by classes that include this module
|
24
|
+
{}
|
25
|
+
end
|
21
26
|
end
|
22
27
|
end
|
23
28
|
end
|
data/lib/finapps/version.rb
CHANGED
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helpers/client'
|
4
|
+
|
5
|
+
RSpec.describe FinApps::REST::AlertDefinitions do
|
6
|
+
include SpecHelpers::Client
|
7
|
+
subject { FinApps::REST::AlertDefinitions.new(client) }
|
8
|
+
|
9
|
+
describe '#list' do
|
10
|
+
let(:list) { subject.list(params) }
|
11
|
+
let(:results) { list[RESULTS] }
|
12
|
+
let(:errors) { list[ERROR_MESSAGES] }
|
13
|
+
|
14
|
+
context 'when missing params' do
|
15
|
+
let(:params) { nil }
|
16
|
+
|
17
|
+
it { expect { list }.not_to raise_error }
|
18
|
+
it('returns an array') { expect(list).to be_a(Array) }
|
19
|
+
it('performs a get and returns the response') { expect(results).to respond_to(:records) }
|
20
|
+
it('returns no error messages') { expect(errors).to be_empty }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when invalid params are provided' do
|
24
|
+
let(:params) { %w[this is an array] }
|
25
|
+
|
26
|
+
it { expect { list }.to raise_error(FinAppsCore::InvalidArgumentsError) }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when including valid params' do
|
30
|
+
let(:params) { { page: 2, sort: '-created_date', requested: 25 } }
|
31
|
+
|
32
|
+
it { expect { list }.not_to raise_error }
|
33
|
+
it('returns an array') { expect(list).to be_a(Array) }
|
34
|
+
it('performs a get and returns the response') { expect(results).to respond_to(:records) }
|
35
|
+
it('returns no error messages') { expect(errors).to be_empty }
|
36
|
+
it 'builds query and sends proper request' do
|
37
|
+
list
|
38
|
+
url = "#{FinAppsCore::REST::Defaults::DEFAULTS[:host]}/v3/portfolio/alerts/definitions?page=2&requested=25&" \
|
39
|
+
'sort=-created_date'
|
40
|
+
expect(WebMock).to have_requested(:get, url)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#show' do
|
46
|
+
let(:show) { subject.show(id) }
|
47
|
+
let(:results) { show[RESULTS] }
|
48
|
+
let(:errors) { show[ERROR_MESSAGES] }
|
49
|
+
|
50
|
+
context 'when missing params' do
|
51
|
+
let(:id) { nil }
|
52
|
+
|
53
|
+
it { expect { show }.to raise_error(FinAppsCore::MissingArgumentsError) }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when valid id is provided' do
|
57
|
+
let(:id) { 'valid_id' }
|
58
|
+
|
59
|
+
it { expect { show }.not_to raise_error(FinAppsCore::MissingArgumentsError) }
|
60
|
+
it('returns an array') { expect(show).to be_a(Array) }
|
61
|
+
it('performs a get and returns the response') do
|
62
|
+
expect(results).to respond_to(:_id)
|
63
|
+
expect(results).to respond_to(:rule_name)
|
64
|
+
end
|
65
|
+
it('returns no error messages') { expect(errors).to be_empty }
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when invalid id is provided' do
|
69
|
+
let(:id) { 'invalid_id' }
|
70
|
+
|
71
|
+
it { expect { show }.not_to raise_error }
|
72
|
+
it('results is nil') { expect(results).to be_nil }
|
73
|
+
it('error messages array is populated') do
|
74
|
+
expect(errors.first.downcase).to eq('resource not found')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helpers/client'
|
4
|
+
|
5
|
+
RSpec.describe FinApps::REST::AlertOccurrences do
|
6
|
+
include SpecHelpers::Client
|
7
|
+
subject { FinApps::REST::AlertOccurrences.new(client) }
|
8
|
+
|
9
|
+
describe '#list' do
|
10
|
+
let(:list) { subject.list(params) }
|
11
|
+
let(:results) { list[RESULTS] }
|
12
|
+
let(:errors) { list[ERROR_MESSAGES] }
|
13
|
+
|
14
|
+
context 'when missing params' do
|
15
|
+
let(:params) { nil }
|
16
|
+
|
17
|
+
it { expect { list }.not_to raise_error }
|
18
|
+
it('returns an array') { expect(list).to be_a(Array) }
|
19
|
+
it('performs a get and returns the response') { expect(results).to respond_to(:records) }
|
20
|
+
it('returns no error messages') { expect(errors).to be_empty }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when invalid params are provided' do
|
24
|
+
let(:params) { %w[this is an array] }
|
25
|
+
|
26
|
+
it { expect { list }.to raise_error(FinAppsCore::InvalidArgumentsError) }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when including valid params' do
|
30
|
+
let(:params) { { page: 2, sort: '-created_date', requested: 25, portfolio_id: 'valid_id' } }
|
31
|
+
|
32
|
+
it { expect { list }.not_to raise_error }
|
33
|
+
it('returns an array') { expect(list).to be_a(Array) }
|
34
|
+
it('performs a get and returns the response') { expect(results).to respond_to(:records) }
|
35
|
+
it('returns no error messages') { expect(errors).to be_empty }
|
36
|
+
it 'builds query and sends proper request' do
|
37
|
+
list
|
38
|
+
url = "#{FinAppsCore::REST::Defaults::DEFAULTS[:host]}/v3/portfolio/alerts/occurrences?" \
|
39
|
+
'filter=%7B%22portfolio.id%22:%22valid_id%22%7D&page=2&requested=25&sort=-created_date'
|
40
|
+
expect(WebMock).to have_requested(:get, url)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|