finapps 5.0.3 → 5.0.4

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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rubocop.yml +1 -7
  4. data/.tmuxinator.yml +19 -0
  5. data/Guardfile +42 -0
  6. data/finapps.gemspec +3 -1
  7. data/lib/finapps.rb +1 -7
  8. data/lib/finapps/rest/client.rb +5 -10
  9. data/lib/finapps/rest/consumers.rb +2 -1
  10. data/lib/finapps/rest/operators.rb +8 -2
  11. data/lib/finapps/rest/order_reports.rb +2 -1
  12. data/lib/finapps/rest/orders.rb +11 -9
  13. data/lib/finapps/rest/plaid/plaid_consumer_institutions.rb +15 -0
  14. data/lib/finapps/rest/portfolios_alerts.rb +2 -1
  15. data/lib/finapps/rest/portfolios_available_consumers.rb +2 -1
  16. data/lib/finapps/rest/portfolios_consumers.rb +6 -1
  17. data/lib/finapps/rest/products.rb +1 -2
  18. data/lib/finapps/rest/sessions.rb +8 -2
  19. data/lib/finapps/rest/statements.rb +2 -1
  20. data/lib/finapps/version.rb +1 -1
  21. data/spec/rest/alert_definitions_spec.rb +12 -7
  22. data/spec/rest/alert_occurrences_spec.rb +17 -5
  23. data/spec/rest/client_spec.rb +115 -57
  24. data/spec/rest/consumers_portfolios_spec.rb +9 -4
  25. data/spec/rest/consumers_spec.rb +76 -20
  26. data/spec/rest/operators_password_resets_spec.rb +19 -10
  27. data/spec/rest/operators_spec.rb +60 -22
  28. data/spec/rest/order_assignments_spec.rb +11 -5
  29. data/spec/rest/order_notifications_spec.rb +6 -2
  30. data/spec/rest/order_refreshes_spec.rb +11 -5
  31. data/spec/rest/order_reports_spec.rb +15 -5
  32. data/spec/rest/order_statuses_spec.rb +12 -4
  33. data/spec/rest/order_tokens_spec.rb +17 -5
  34. data/spec/rest/orders_spec.rb +80 -34
  35. data/spec/rest/password_resets_spec.rb +51 -14
  36. data/spec/rest/plaid/plaid_webhooks_spec.rb +7 -3
  37. data/spec/rest/portfolio_reports_spec.rb +9 -4
  38. data/spec/rest/portfolios_alerts_spec.rb +18 -10
  39. data/spec/rest/portfolios_available_consumers_spec.rb +9 -4
  40. data/spec/rest/portfolios_consumers_spec.rb +29 -11
  41. data/spec/rest/portfolios_spec.rb +51 -22
  42. data/spec/rest/products_spec.rb +5 -2
  43. data/spec/rest/sessions_spec.rb +36 -14
  44. data/spec/rest/statements_spec.rb +6 -2
  45. data/spec/rest/tenant_app_settings_spec.rb +13 -5
  46. data/spec/rest/tenant_settings_spec.rb +13 -5
  47. data/spec/rest/version_spec.rb +3 -1
  48. data/spec/spec_helper.rb +6 -4
  49. data/spec/spec_helpers/client.rb +2 -1
  50. data/spec/support/fake_api.rb +253 -119
  51. data/spec/utils/query_builder_spec.rb +8 -3
  52. data/tags +6 -0
  53. metadata +48 -25
  54. data/lib/finapps/rest/consumer_institution_refresh.rb +0 -14
  55. data/lib/finapps/rest/consumer_institution_refreshes.rb +0 -12
  56. data/lib/finapps/rest/institutions.rb +0 -34
  57. data/lib/finapps/rest/institutions_forms.rb +0 -14
  58. data/lib/finapps/rest/user_institutions.rb +0 -54
  59. data/lib/finapps/rest/user_institutions_forms.rb +0 -14
  60. data/lib/finapps/rest/user_institutions_statuses.rb +0 -19
  61. data/spec/rest/consumer_institution_refresh_spec.rb +0 -44
  62. data/spec/rest/consumer_institution_refreshes_spec.rb +0 -20
  63. data/spec/rest/institutions_forms_spec.rb +0 -29
  64. data/spec/rest/institutions_spec.rb +0 -55
  65. data/spec/rest/user_institutions_forms_spec.rb +0 -30
  66. data/spec/rest/user_institutions_spec.rb +0 -144
  67. data/spec/rest/user_institutions_statuses_spec.rb +0 -43
@@ -11,7 +11,7 @@ RSpec.describe FinApps::REST::TenantSettings do
11
11
 
12
12
  it { expect { show }.not_to raise_error }
13
13
  it('performs a get and returns the response') do
14
- expect(show[RESULTS]).to respond_to(:iav_default_product)
14
+ expect(show[RESULTS]).to have_key(:iav_default_product)
15
15
  end
16
16
  it('returns no error messages') { expect(show[ERROR_MESSAGES]).to be_empty }
17
17
  end
@@ -21,15 +21,21 @@ RSpec.describe FinApps::REST::TenantSettings do
21
21
 
22
22
  context 'when missing params' do
23
23
  let(:params) { nil }
24
- it { expect { update }.to raise_error(FinAppsCore::MissingArgumentsError) }
24
+ it do
25
+ expect { update }.to raise_error(FinAppsCore::MissingArgumentsError)
26
+ end
25
27
  end
26
28
 
27
29
  context 'when valid params are provided' do
28
30
  let(:params) { { iav_default_product: 'valid' } }
29
31
 
30
32
  it { expect { update }.not_to raise_error }
31
- it('performs put and returns no content') { expect(update[RESULTS]).to be_nil }
32
- it('error_messages array is empty') { expect(update[ERROR_MESSAGES]).to be_empty }
33
+ it('performs put and returns no content') do
34
+ expect(update[RESULTS]).to be_nil
35
+ end
36
+ it('error_messages array is empty') do
37
+ expect(update[ERROR_MESSAGES]).to be_empty
38
+ end
33
39
  end
34
40
 
35
41
  context 'when invalid params are provided' do
@@ -37,7 +43,9 @@ RSpec.describe FinApps::REST::TenantSettings do
37
43
 
38
44
  it { expect { update }.not_to raise_error }
39
45
  it('results is nil') { expect(update[RESULTS]).to be_nil }
40
- it('error_messages array is populated') { expect(update[ERROR_MESSAGES]).not_to be_empty }
46
+ it('error_messages array is populated') do
47
+ expect(update[ERROR_MESSAGES]).not_to be_empty
48
+ end
41
49
  end
42
50
  end
43
51
  end
@@ -7,6 +7,8 @@ RSpec.describe FinApps::REST::Version do
7
7
  describe '#show' do
8
8
  it { expect { subject.show }.not_to raise_error }
9
9
  it('returns a string') { expect(subject.show[0]).to be_a(String) }
10
- it('starts with the words "Version =>"') { expect(subject.show[0]).to start_with('Version =>') }
10
+ it('starts with the words "Version =>"') do
11
+ expect(subject.show[0]).to start_with('Version =>')
12
+ end
11
13
  end
12
14
  end
data/spec/spec_helper.rb CHANGED
@@ -21,7 +21,7 @@ RSpec.configure do |config|
21
21
  expectations.include_chain_clauses_in_custom_matcher_descriptions = true
22
22
  expectations.syntax = :expect
23
23
  end
24
- config.mock_with(:rspec) {|mocks| mocks.verify_partial_doubles = true }
24
+ config.mock_with(:rspec) { |mocks| mocks.verify_partial_doubles = true }
25
25
  # config.filter_run_including :focus => true
26
26
  config.default_formatter = 'doc' if config.files_to_run.one?
27
27
  config.order = :random
@@ -30,14 +30,16 @@ RSpec.configure do |config|
30
30
  Kernel.srand config.seed
31
31
 
32
32
  config.before(:each) do
33
- base_url = "#{FinAppsCore::REST::Defaults::DEFAULTS[:host]}/v#{FinAppsCore::REST::Defaults::API_VERSION}/"
33
+ base_url =
34
+ "#{FinAppsCore::REST::Defaults::DEFAULTS[:host]}/v#{FinAppsCore::REST::Defaults::API_VERSION}/"
34
35
  stub_request(:any, /#{base_url}/).to_rack(::FakeApi)
35
36
  end
36
37
  WebMock.disable_net_connect!(allow: 'codeclimate.com')
37
38
  end
38
39
 
39
- VALID_CREDENTIALS = { identifier: '49fb918d-7e71-44dd-7378-58f19606df2a',
40
- token: 'hohoho=' }.freeze
40
+ VALID_CREDENTIALS = {
41
+ identifier: '49fb918d-7e71-44dd-7378-58f19606df2a', token: 'hohoho='
42
+ }.freeze
41
43
 
42
44
  RESULTS = 0
43
45
  ERROR_MESSAGES = 1
@@ -3,7 +3,8 @@
3
3
  module SpecHelpers
4
4
  module Client
5
5
  def client(tenant_token = :tenant_token)
6
- FinApps::REST::Client.new tenant_token, rashify: true
6
+ logger = Logger.new(IO::NULL)
7
+ FinApps::REST::Client.new tenant_token, {}, logger
7
8
  end
8
9
  end
9
10
  end
@@ -4,19 +4,19 @@ require 'sinatra/base'
4
4
 
5
5
  # the FakeApi class is used to mock API requests while testing.
6
6
  class FakeApi < Sinatra::Base
7
- def self.version_path
7
+ def self.version
8
8
  "v#{FinAppsCore::REST::Defaults::API_VERSION}"
9
9
  end
10
10
 
11
11
  # resource
12
- post("/#{version_path}/resources") { json_response 201, 'resource.json' }
13
- get("/#{version_path}/resources/:id") { json_response 200, 'resource.json' }
14
- get("/#{version_path}/resources") { json_response 200, 'resources.json' }
15
- put("/#{version_path}/resources") { json_response 201, 'resource.json' }
16
- delete("/#{version_path}/resources/:id") { status 202 }
12
+ post("/#{version}/resources") { json_response 201, 'resource.json' }
13
+ get("/#{version}/resources/:id") { json_response 200, 'resource.json' }
14
+ get("/#{version}/resources") { json_response 200, 'resources.json' }
15
+ put("/#{version}/resources") { json_response 201, 'resource.json' }
16
+ delete("/#{version}/resources/:id") { status 202 }
17
17
 
18
18
  # plaid
19
- post("/#{version_path}/p/webhook") do
19
+ post("/#{version}/p/webhook") do
20
20
  tenant_token = request.env['HTTP_X_TENANT_TOKEN']
21
21
  if tenant_token == 'invalid_tenant_token'
22
22
  json_response 404, 'resource_not_found.json'
@@ -26,11 +26,13 @@ class FakeApi < Sinatra::Base
26
26
  end
27
27
 
28
28
  # version
29
- get("/#{version_path}/version") { 'Version => 2.1.29-.20161208.172810' }
29
+ get("/#{version}/version") { 'Version => 2.1.29-.20161208.172810' }
30
30
 
31
31
  # tenants
32
- get("/#{version_path}/settings/tenant") { json_response 200, 'tenant_settings.json' }
33
- put("/#{version_path}/settings/tenant") do
32
+ get("/#{version}/settings/tenant") do
33
+ json_response 200, 'tenant_settings.json'
34
+ end
35
+ put("/#{version}/settings/tenant") do
34
36
  request.body.rewind
35
37
  request_payload = JSON.parse request.body.read
36
38
  if request_payload['bad_params']
@@ -39,8 +41,10 @@ class FakeApi < Sinatra::Base
39
41
  status 204
40
42
  end
41
43
  end
42
- get("/#{version_path}/settings/app") { json_response 200, 'tenant_app_settings.json' }
43
- put("/#{version_path}/settings/app") do
44
+ get("/#{version}/settings/app") do
45
+ json_response 200, 'tenant_app_settings.json'
46
+ end
47
+ put("/#{version}/settings/app") do
44
48
  request.body.rewind
45
49
  request_payload = JSON.parse request.body.read
46
50
  if request_payload['pdf_statement_months']
@@ -51,22 +55,44 @@ class FakeApi < Sinatra::Base
51
55
  end
52
56
 
53
57
  # orders
54
- post("/#{version_path}/orders/valid_token") { json_response 200, 'order_token.json' }
55
- post("/#{version_path}/orders/invalid_token") { json_response 404, 'resource_not_found.json' }
56
- get("/#{version_path}/orders/valid_id") { json_response 200, 'order.json' }
57
- get("/#{version_path}/orders") { json_response 200, 'orders.json' }
58
- get("/#{version_path}/orders/valid_id/report.:format") { json_response 200, 'order_report.json' }
59
- get("/#{version_path}/orders/invalid_id/report.:format") { json_response 404, 'resource_not_found.json' }
60
- get("/#{version_path}/orders/valid_id/status") { json_response 200, 'order_status.json' }
61
- get("/#{version_path}/orders/invalid_id/status") { json_response 404, 'resource_not_found.json' }
62
- put("/#{version_path}/orders/valid_id/cancel") { status 204 }
63
- put("/#{version_path}/orders/invalid_id/cancel") { json_response 404, 'resource_not_found.json' }
64
- put("/#{version_path}/orders/valid_id/notify") { status 204 }
65
- put("/#{version_path}/orders/invalid_id/notify") { json_response 404, 'resource_not_found.json' }
66
- put("/#{version_path}/orders/valid_id/refresh") { json_response 200, 'order_refresh.json' }
67
- put("/#{version_path}/orders/invalid_id/refresh") { json_response 404, 'resource_not_found.json' }
68
- put("/#{version_path}/orders/invalid_id") { json_response 404, 'resource_not_found.json' }
69
- put("/#{version_path}/orders/valid_id") do
58
+ post("/#{version}/orders/valid_token") do
59
+ json_response 200, 'order_token.json'
60
+ end
61
+ post("/#{version}/orders/invalid_token") do
62
+ json_response 404, 'resource_not_found.json'
63
+ end
64
+ get("/#{version}/orders/valid_id") { json_response 200, 'order.json' }
65
+ get("/#{version}/orders") { json_response 200, 'orders.json' }
66
+ get("/#{version}/orders/valid_id/report.:format") do
67
+ json_response 200, 'order_report.json'
68
+ end
69
+ get("/#{version}/orders/invalid_id/report.:format") do
70
+ json_response 404, 'resource_not_found.json'
71
+ end
72
+ get("/#{version}/orders/valid_id/status") do
73
+ json_response 200, 'order_status.json'
74
+ end
75
+ get("/#{version}/orders/invalid_id/status") do
76
+ json_response 404, 'resource_not_found.json'
77
+ end
78
+ put("/#{version}/orders/valid_id/cancel") { status 204 }
79
+ put("/#{version}/orders/invalid_id/cancel") do
80
+ json_response 404, 'resource_not_found.json'
81
+ end
82
+ put("/#{version}/orders/valid_id/notify") { status 204 }
83
+ put("/#{version}/orders/invalid_id/notify") do
84
+ json_response 404, 'resource_not_found.json'
85
+ end
86
+ put("/#{version}/orders/valid_id/refresh") do
87
+ json_response 200, 'order_refresh.json'
88
+ end
89
+ put("/#{version}/orders/invalid_id/refresh") do
90
+ json_response 404, 'resource_not_found.json'
91
+ end
92
+ put("/#{version}/orders/invalid_id") do
93
+ json_response 404, 'resource_not_found.json'
94
+ end
95
+ put("/#{version}/orders/valid_id") do
70
96
  request.body.rewind
71
97
  request_payload = JSON.parse request.body.read
72
98
  if request_payload['accounts'] == 'valid_account'
@@ -75,10 +101,10 @@ class FakeApi < Sinatra::Base
75
101
  json_response 400, 'invalid_request_body.json'
76
102
  end
77
103
  end
78
- post("/#{version_path}/orders") do
104
+ post("/#{version}/orders") do
79
105
  request.body.rewind
80
106
  request_payload = JSON.parse request.body.read
81
- if %w[applicant institutions product].all? {|s| request_payload.key? s }
107
+ if %w[applicant institutions product].all? { |s| request_payload.key? s }
82
108
  json_response 200, 'order_token.json'
83
109
  else
84
110
  json_response 400, 'invalid_request_body.json'
@@ -86,34 +112,72 @@ class FakeApi < Sinatra::Base
86
112
  end
87
113
 
88
114
  # institutions
89
- get("/#{version_path}/institutions/site/valid_site_id/form") { json_response 200, 'institution_login_form.json' }
90
- get("/#{version_path}/institutions/site/invalid_site_id/form") { json_response 400, 'invalid_institution_id.json' }
91
- post("/#{version_path}/institutions/site/valid_site_id/add") { json_response 200, 'institution_add.json' }
92
- get("/#{version_path}/institutions/search/:search_term") { json_response 200, 'institutions_search_list.json' }
93
- get("/#{version_path}/institutions/routing/:routing_number") { json_response 200, 'institutions_routing_number.json' }
94
- get("/#{version_path}/institutions/site/:site_id") { json_response 200, 'institutions_routing_number.json' }
115
+ get("/#{version}/institutions/site/valid_site_id/form") do
116
+ json_response 200, 'institution_login_form.json'
117
+ end
118
+ get("/#{version}/institutions/site/invalid_site_id/form") do
119
+ json_response 400, 'invalid_institution_id.json'
120
+ end
121
+ post("/#{version}/institutions/site/valid_site_id/add") do
122
+ json_response 200, 'institution_add.json'
123
+ end
124
+ get("/#{version}/institutions/search/:search_term") do
125
+ json_response 200, 'institutions_search_list.json'
126
+ end
127
+ get("/#{version}/institutions/routing/:routing_number") do
128
+ json_response 200, 'institutions_routing_number.json'
129
+ end
130
+ get("/#{version}/institutions/site/:site_id") do
131
+ json_response 200, 'institutions_routing_number.json'
132
+ end
95
133
 
96
134
  # user institutions
97
- get("/#{version_path}/institutions/consumer/valid_id/status") { json_response 200, 'user_institution_status.json' }
98
- get("/#{version_path}/institutions/consumer/invalid_id/status") do
135
+ get("/#{version}/institutions/consumer/valid_id/status") do
136
+ json_response 200, 'user_institution_status.json'
137
+ end
138
+ get("/#{version}/institutions/consumer/invalid_id/status") do
99
139
  json_response 400, 'invalid_user_institution_id.json'
100
140
  end
101
- get("/#{version_path}/institutions/consumer") { json_response 200, 'user_institutions_list.json' }
102
- get("/#{version_path}/institutions/consumer/valid_id") { json_response 200, 'user_institutions_show.json' }
103
- get("/#{version_path}/institutions/consumer/invalid_id") { json_response 400, 'invalid_user_institution_id.json' }
104
- put("/#{version_path}/institutions/consumer/refresh") { json_response 200, 'user_institutions_refresh_all.json' }
105
- put("/#{version_path}/institutions/consumer/valid_id/credentials") { json_response 200, 'institution_add.json' }
106
- put("/#{version_path}/institutions/consumer/invalid_id/credentials") do
141
+ get("/#{version}/institutions/consumer") do
142
+ json_response 200, 'user_institutions_list.json'
143
+ end
144
+ get("/#{version}/institutions/consumer/valid_id") do
145
+ json_response 200, 'user_institutions_show.json'
146
+ end
147
+ get("/#{version}/institutions/consumer/invalid_id") do
107
148
  json_response 400, 'invalid_user_institution_id.json'
108
149
  end
109
- put("/#{version_path}/institutions/consumer/valid_id/mfa") { json_response 200, 'institution_add.json' }
110
- put("/#{version_path}/institutions/consumer/invalid_id/mfa") { json_response 400, 'invalid_user_institution_id.json' }
111
- delete("/#{version_path}/institutions/consumer/valid_id") { status 204 }
112
- delete("/#{version_path}/institutions/consumer/invalid_id") { json_response 400, 'invalid_user_institution_id.json' }
113
- get("/#{version_path}/institutions/consumer/valid_id/form") { json_response 200, 'institution_login_form.json' }
114
- get("/#{version_path}/institutions/consumer/invalid_id/form") { json_response 400, 'invalid_institution_id.json' }
115
- put("/#{version_path}/institutions/refresh") { json_response 200, 'user_institution_refresh.json' }
116
- put("/#{version_path}/institutions/consumer/valid_consumer_institution_id/refresh") do
150
+ put("/#{version}/institutions/consumer/refresh") do
151
+ json_response 200, 'user_institutions_refresh_all.json'
152
+ end
153
+ put("/#{version}/institutions/consumer/valid_id/credentials") do
154
+ json_response 200, 'institution_add.json'
155
+ end
156
+ put("/#{version}/institutions/consumer/invalid_id/credentials") do
157
+ json_response 400, 'invalid_user_institution_id.json'
158
+ end
159
+ put("/#{version}/institutions/consumer/valid_id/mfa") do
160
+ json_response 200, 'institution_add.json'
161
+ end
162
+ put("/#{version}/institutions/consumer/invalid_id/mfa") do
163
+ json_response 400, 'invalid_user_institution_id.json'
164
+ end
165
+ delete("/#{version}/institutions/consumer/valid_id") { status 204 }
166
+ delete("/#{version}/institutions/consumer/invalid_id") do
167
+ json_response 400, 'invalid_user_institution_id.json'
168
+ end
169
+ get("/#{version}/institutions/consumer/valid_id/form") do
170
+ json_response 200, 'institution_login_form.json'
171
+ end
172
+ get("/#{version}/institutions/consumer/invalid_id/form") do
173
+ json_response 400, 'invalid_institution_id.json'
174
+ end
175
+ put("/#{version}/institutions/refresh") do
176
+ json_response 200, 'user_institution_refresh.json'
177
+ end
178
+ put(
179
+ "/#{version}/institutions/consumer/valid_consumer_institution_id/refresh"
180
+ ) do
117
181
  request.body.rewind
118
182
  request_payload = JSON.parse request.body.read
119
183
  if request_payload['token'] == 'invalid_token'
@@ -124,9 +188,13 @@ class FakeApi < Sinatra::Base
124
188
  end
125
189
 
126
190
  # consumers
127
- get("/#{version_path}/consumers/valid_public_id") { json_response 200, 'user.json' }
128
- get("/#{version_path}/consumers/invalid_public_id") { json_response 404, 'resource_not_found.json' }
129
- post("/#{version_path}/consumers") do
191
+ get("/#{version}/consumers/valid_public_id") do
192
+ json_response 200, 'user.json'
193
+ end
194
+ get("/#{version}/consumers/invalid_public_id") do
195
+ json_response 404, 'resource_not_found.json'
196
+ end
197
+ post("/#{version}/consumers") do
130
198
  request.body.rewind
131
199
  request_payload = JSON.parse request.body.read
132
200
  if request_payload['password']
@@ -135,31 +203,55 @@ class FakeApi < Sinatra::Base
135
203
  json_response 400, 'invalid_request_body.json'
136
204
  end
137
205
  end
138
- put("/#{version_path}/consumers/valid_public_id") { status 204 }
139
- put("/#{version_path}/consumers/invalid_public_id") { json_response 400, 'invalid_user_id.json' }
140
- put("/#{version_path}/consumers/valid_public_id/password") { json_response 200, 'user.json' }
141
- put("/#{version_path}/consumers/invalid_public_id/password") { json_response 404, 'resource_not_found.json' }
142
- delete("/#{version_path}/consumers/valid_public_id") { status 204 }
143
- delete("/#{version_path}/consumers/invalid_public_id") { json_response 404, 'resource_not_found.json' }
144
- post("/#{version_path}/logout") { status 204 }
206
+ put("/#{version}/consumers/valid_public_id") { status 204 }
207
+ put("/#{version}/consumers/invalid_public_id") do
208
+ json_response 400, 'invalid_user_id.json'
209
+ end
210
+ put("/#{version}/consumers/valid_public_id/password") do
211
+ json_response 200, 'user.json'
212
+ end
213
+ put("/#{version}/consumers/invalid_public_id/password") do
214
+ json_response 404, 'resource_not_found.json'
215
+ end
216
+ delete("/#{version}/consumers/valid_public_id") { status 204 }
217
+ delete("/#{version}/consumers/invalid_public_id") do
218
+ json_response 404, 'resource_not_found.json'
219
+ end
220
+ post("/#{version}/logout") { status 204 }
145
221
 
146
222
  # accounts
147
- get("/#{version_path}/accounts/valid_id/statement/valid_id") { json_response 200, 'fake_pdf_statement.json' }
148
- get("/#{version_path}/accounts/invalid_id/statement/valid_id") { json_response 404, 'resource_not_found.json' }
223
+ get("/#{version}/accounts/valid_id/statement/valid_id") do
224
+ json_response 200, 'fake_pdf_statement.json'
225
+ end
226
+ get("/#{version}/accounts/invalid_id/statement/valid_id") do
227
+ json_response 404, 'resource_not_found.json'
228
+ end
149
229
 
150
230
  # operators
151
- get("/#{version_path}/operators") { json_response 200, 'operator_list.json' }
152
- get("/#{version_path}/operators/invalid_id") { json_response 404, 'resource_not_found.json' }
153
- get("/#{version_path}/operators/valid_id") { json_response 200, 'operator.json' }
154
- delete("/#{version_path}/operators/invalid_id") { json_response 404, 'resource_not_found.json' }
155
- delete("/#{version_path}/operators/valid_id") { status 204 }
156
- post("/#{version_path}/operators/password/change") { json_response 200, 'operator.json' }
157
- put("/#{version_path}/operators/invalid_id") { json_response 404, 'resource_not_found.json' }
158
- put("/#{version_path}/operators/valid_id") { json_response 200, 'operator.json' }
159
- put("/#{version_path}/operators/valid_id/assign") { status 204 }
160
- put("/#{version_path}/operators/invalid_id/assign") { json_response 404, 'resource_not_found.json' }
161
- post("/#{version_path}/operators/password/forgot") { json_response 200, 'operator_forgot_password.json' }
162
- post("/#{version_path}/operators/password/reset") do
231
+ get("/#{version}/operators") { json_response 200, 'operator_list.json' }
232
+ get("/#{version}/operators/invalid_id") do
233
+ json_response 404, 'resource_not_found.json'
234
+ end
235
+ get("/#{version}/operators/valid_id") { json_response 200, 'operator.json' }
236
+ delete("/#{version}/operators/invalid_id") do
237
+ json_response 404, 'resource_not_found.json'
238
+ end
239
+ delete("/#{version}/operators/valid_id") { status 204 }
240
+ post("/#{version}/operators/password/change") do
241
+ json_response 200, 'operator.json'
242
+ end
243
+ put("/#{version}/operators/invalid_id") do
244
+ json_response 404, 'resource_not_found.json'
245
+ end
246
+ put("/#{version}/operators/valid_id") { json_response 200, 'operator.json' }
247
+ put("/#{version}/operators/valid_id/assign") { status 204 }
248
+ put("/#{version}/operators/invalid_id/assign") do
249
+ json_response 404, 'resource_not_found.json'
250
+ end
251
+ post("/#{version}/operators/password/forgot") do
252
+ json_response 200, 'operator_forgot_password.json'
253
+ end
254
+ post("/#{version}/operators/password/reset") do
163
255
  request.body.rewind
164
256
  request_payload = JSON.parse request.body.read
165
257
  if request_payload['params'] == 'valid'
@@ -168,7 +260,7 @@ class FakeApi < Sinatra::Base
168
260
  json_response 400, 'invalid_request_body.json'
169
261
  end
170
262
  end
171
- post("/#{version_path}/operators") do
263
+ post("/#{version}/operators") do
172
264
  request.body.rewind
173
265
  request_payload = JSON.parse request.body.read
174
266
  if request_payload['params'] == 'valid'
@@ -179,7 +271,7 @@ class FakeApi < Sinatra::Base
179
271
  end
180
272
 
181
273
  # session
182
- post("/#{version_path}/login") do
274
+ post("/#{version}/login") do
183
275
  request.body.rewind
184
276
  request_payload = JSON.parse request.body.read
185
277
  if request_payload['password'] == 'valid_password'
@@ -188,12 +280,16 @@ class FakeApi < Sinatra::Base
188
280
  json_response(401, 'unauthorized.json')
189
281
  end
190
282
  end
191
- post("/#{version_path}/operators/login") { json_response 200, 'operator.json' }
283
+ post("/#{version}/operators/login") { json_response 200, 'operator.json' }
192
284
 
193
285
  # password resets
194
- post("/#{version_path}/tenant/valid_user_id/password") { json_response 200, 'password_reset_token.json' }
195
- post("/#{version_path}/tenant/invalid_user_id/password") { json_response 404, 'resource_not_found.json' }
196
- put("/#{version_path}/tenant/valid_user_id/password") do
286
+ post("/#{version}/tenant/valid_user_id/password") do
287
+ json_response 200, 'password_reset_token.json'
288
+ end
289
+ post("/#{version}/tenant/invalid_user_id/password") do
290
+ json_response 404, 'resource_not_found.json'
291
+ end
292
+ put("/#{version}/tenant/valid_user_id/password") do
197
293
  request.body.rewind
198
294
  request_payload = JSON.parse request.body.read
199
295
  if request_payload['token'] == 'valid_token'
@@ -202,16 +298,20 @@ class FakeApi < Sinatra::Base
202
298
  json_response(400, 'invalid_request_body.json')
203
299
  end
204
300
  end
205
- put("/#{version_path}/tenant/invalid_user_id/password") { json_response 404, 'resource_not_found.json' }
301
+ put("/#{version}/tenant/invalid_user_id/password") do
302
+ json_response 404, 'resource_not_found.json'
303
+ end
206
304
 
207
305
  # products
208
- get("/#{version_path}/products") { json_response 200, 'products.json' }
306
+ get("/#{version}/products") { json_response 200, 'products.json' }
209
307
 
210
308
  # portfolios
211
- get("/#{version_path}/portfolios") { json_response 200, 'portfolios.json' }
212
- get("/#{version_path}/portfolios/valid_id") { json_response 200, 'portfolio.json' }
213
- get("/#{version_path}/portfolios/invalid_id") { json_response 404, 'resource_not_found.json' }
214
- post("/#{version_path}/portfolios") do
309
+ get("/#{version}/portfolios") { json_response 200, 'portfolios.json' }
310
+ get("/#{version}/portfolios/valid_id") { json_response 200, 'portfolio.json' }
311
+ get("/#{version}/portfolios/invalid_id") do
312
+ json_response 404, 'resource_not_found.json'
313
+ end
314
+ post("/#{version}/portfolios") do
215
315
  request.body.rewind
216
316
  request_payload = JSON.parse request.body.read
217
317
  if request_payload['product'] == 'invalid'
@@ -220,63 +320,97 @@ class FakeApi < Sinatra::Base
220
320
  json_response(200, 'portfolio.json')
221
321
  end
222
322
  end
223
- put("/#{version_path}/portfolios/valid_id") { json_response 200, 'portfolio.json' }
224
- put("/#{version_path}/portfolios/invalid_id") { json_response 404, 'resource_not_found.json' }
225
- delete("/#{version_path}/portfolios/valid_id") { status 204 }
226
- delete("/#{version_path}/portfolios/invalid_id") { json_response 404, 'resource_not_found.json' }
323
+ put("/#{version}/portfolios/valid_id") { json_response 200, 'portfolio.json' }
324
+ put("/#{version}/portfolios/invalid_id") do
325
+ json_response 404, 'resource_not_found.json'
326
+ end
327
+ delete("/#{version}/portfolios/valid_id") { status 204 }
328
+ delete("/#{version}/portfolios/invalid_id") do
329
+ json_response 404, 'resource_not_found.json'
330
+ end
227
331
 
228
332
  # alert definitions
229
- get("/#{version_path}/portfolio/alerts/definitions") { json_response 200, 'alert_definitions.json' }
230
- get("/#{version_path}/portfolio/alerts/definitions/valid_id") { json_response 200, 'alert_definition.json' }
231
- get("/#{version_path}/portfolio/alerts/definitions/invalid_id") { json_response 404, 'resource_not_found.json' }
333
+ get("/#{version}/portfolio/alerts/definitions") do
334
+ json_response 200, 'alert_definitions.json'
335
+ end
336
+ get("/#{version}/portfolio/alerts/definitions/valid_id") do
337
+ json_response 200, 'alert_definition.json'
338
+ end
339
+ get("/#{version}/portfolio/alerts/definitions/invalid_id") do
340
+ json_response 404, 'resource_not_found.json'
341
+ end
232
342
 
233
343
  # alert occurrences
234
- get("/#{version_path}/portfolio/alerts/occurrences") { json_response 200, 'alert_occurrences.json' }
344
+ get("/#{version}/portfolio/alerts/occurrences") do
345
+ json_response 200, 'alert_occurrences.json'
346
+ end
235
347
 
236
348
  # portfolios alerts
237
- get("/#{version_path}/portfolios/valid_id/alerts") { json_response 200, 'portfolios_alerts.json' }
238
- get("/#{version_path}/portfolios/invalid_id/alerts") { json_response 404, 'resource_not_found.json' }
239
- put("/#{version_path}/portfolios/valid_id/alerts/valid_id") { status 204 }
240
- put("/#{version_path}/portfolios/invalid_id/alerts/invalid_id") { json_response 404, 'resource_not_found.json' }
241
- delete("/#{version_path}/portfolios/valid_id/alerts/valid_id") { status 204 }
242
- delete("/#{version_path}/portfolios/invalid_id/alerts/invalid_id") { json_response 404, 'resource_not_found.json' }
349
+ get("/#{version}/portfolios/valid_id/alerts") do
350
+ json_response 200, 'portfolios_alerts.json'
351
+ end
352
+ get("/#{version}/portfolios/invalid_id/alerts") do
353
+ json_response 404, 'resource_not_found.json'
354
+ end
355
+ put("/#{version}/portfolios/valid_id/alerts/valid_id") { status 204 }
356
+ put("/#{version}/portfolios/invalid_id/alerts/invalid_id") do
357
+ json_response 404, 'resource_not_found.json'
358
+ end
359
+ delete("/#{version}/portfolios/valid_id/alerts/valid_id") { status 204 }
360
+ delete("/#{version}/portfolios/invalid_id/alerts/invalid_id") do
361
+ json_response 404, 'resource_not_found.json'
362
+ end
243
363
 
244
364
  # portfolios consumers
245
- get("/#{version_path}/portfolios/valid_id/consumers") { json_response 200, 'portfolios_consumers.json' }
246
- get("/#{version_path}/portfolios/invalid_id/consumers") { json_response 404, 'resource_not_found.json' }
247
- post("/#{version_path}/portfolios/valid_id/consumers") { status 204 }
248
- post("/#{version_path}/portfolios/invalid_id/consumers") do
365
+ get("/#{version}/portfolios/valid_id/consumers") do
366
+ json_response 200, 'portfolios_consumers.json'
367
+ end
368
+ get("/#{version}/portfolios/invalid_id/consumers") do
369
+ json_response 404, 'resource_not_found.json'
370
+ end
371
+ post("/#{version}/portfolios/valid_id/consumers") { status 204 }
372
+ post("/#{version}/portfolios/invalid_id/consumers") do
249
373
  json_response 400, 'multiple_consumer_subscribe_error.json'
250
374
  end
251
- post("/#{version_path}/portfolios/valid_id/consumers/valid_id") { status 204 }
252
- post("/#{version_path}/portfolios/invalid_id/consumers/invalid_id") do
375
+ post("/#{version}/portfolios/valid_id/consumers/valid_id") { status 204 }
376
+ post("/#{version}/portfolios/invalid_id/consumers/invalid_id") do
253
377
  json_response 400, 'single_consumer_subscribe_error.json'
254
378
  end
255
- delete("/#{version_path}/portfolios/valid_id/consumers/valid_id") { status 204 }
256
- delete("/#{version_path}/portfolios/invalid_id/consumers/invalid_id") { json_response 404, 'resource_not_found.json' }
379
+ delete("/#{version}/portfolios/valid_id/consumers/valid_id") { status 204 }
380
+ delete("/#{version}/portfolios/invalid_id/consumers/invalid_id") do
381
+ json_response 404, 'resource_not_found.json'
382
+ end
257
383
 
258
384
  # portfolios available consumers
259
- get("/#{version_path}/portfolios/:id/consumers/available") do
385
+ get("/#{version}/portfolios/:id/consumers/available") do
260
386
  json_response 200, 'portfolios_available_consumers.json'
261
387
  end
262
388
 
263
389
  # consumers portfolios
264
- get("/#{version_path}/consumers/valid_id/portfolios") { json_response 200, 'portfolios.json' }
265
- get("/#{version_path}/consumers/invalid_id/portfolios") { json_response 404, 'resource_not_found.json' }
390
+ get("/#{version}/consumers/valid_id/portfolios") do
391
+ json_response 200, 'portfolios.json'
392
+ end
393
+ get("/#{version}/consumers/invalid_id/portfolios") do
394
+ json_response 404, 'resource_not_found.json'
395
+ end
266
396
 
267
397
  # portfolio reports
268
- get("/#{version_path}/portfolio/reports") { json_response 200, 'portfolio_reports.json' }
398
+ get("/#{version}/portfolio/reports") do
399
+ json_response 200, 'portfolio_reports.json'
400
+ end
269
401
 
270
402
  # relevance
271
- get("/#{version_path}/relevance/ruleset/names") { json_response 200, 'relevance_ruleset_names.json' }
403
+ get("/#{version}/relevance/ruleset/names") do
404
+ json_response 200, 'relevance_ruleset_names.json'
405
+ end
272
406
 
273
407
  # errors
274
- get("/#{version_path}/client_error") { json_response 400, 'error.json' }
275
- get("/#{version_path}/server_error") { status 500 }
276
- get("/#{version_path}/proxy_error") { status 407 }
408
+ get("/#{version}/client_error") { json_response 400, 'error.json' }
409
+ get("/#{version}/server_error") { status 500 }
410
+ get("/#{version}/proxy_error") { status 407 }
277
411
 
278
412
  # timeout
279
- get("/#{version_path}/orders/timeout") { status 419 }
413
+ get("/#{version}/orders/timeout") { status 419 }
280
414
 
281
415
  private
282
416