finapps 1.0.8 → 2.0.2
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/.gitignore +1 -1
- data/.rspec +1 -2
- data/.rubocop.yml +102 -0
- data/.ruby-gemset +1 -1
- data/.ruby-version +1 -1
- data/Rakefile +1 -1
- data/finapps.gemspec +10 -10
- data/lib/finapps/core_extensions/hash/compact.rb +22 -0
- data/lib/finapps/core_extensions/integerable.rb +14 -0
- data/lib/finapps/core_extensions/object/blank.rb +145 -0
- data/lib/finapps/error.rb +7 -0
- data/lib/finapps/hash_constructable.rb +9 -0
- data/lib/finapps/middleware/raise_error.rb +46 -0
- data/lib/finapps/middleware/tenant_authentication.rb +19 -0
- data/lib/finapps/rest/base_client.rb +96 -0
- data/lib/finapps/rest/client.rb +11 -199
- data/lib/finapps/rest/configuration.rb +55 -0
- data/lib/finapps/rest/connection.rb +14 -33
- data/lib/finapps/rest/defaults.rb +55 -64
- data/lib/finapps/rest/resource.rb +3 -6
- data/lib/finapps/rest/resources.rb +11 -6
- data/lib/finapps/rest/users.rb +17 -57
- data/lib/finapps/utils/loggeable.rb +13 -0
- data/lib/finapps/version.rb +1 -1
- data/lib/finapps.rb +11 -23
- data/lib/tasks/releaser.rake +2 -2
- data/spec/middleware/tenant_authentication_spec.rb +29 -0
- data/spec/rest/base_client_spec.rb +89 -0
- data/spec/rest/client_spec.rb +16 -102
- data/spec/rest/configuration_spec.rb +75 -0
- data/spec/spec_helper.rb +10 -7
- data/spec/support/fake_api.rb +9 -2
- data/spec/support/fixtures/error.json +5 -0
- data/spec/support/fixtures/relevance_ruleset_names.json +47 -0
- metadata +49 -57
- data/lib/finapps/middleware/api_token.rb +0 -26
- data/lib/finapps/middleware/raise_http_exceptions.rb +0 -92
- data/lib/finapps/middleware/response_logger.rb +0 -37
- data/lib/finapps/rest/alert.rb +0 -62
- data/lib/finapps/rest/alert_definition.rb +0 -40
- data/lib/finapps/rest/alert_preferences.rb +0 -40
- data/lib/finapps/rest/alert_settings.rb +0 -40
- data/lib/finapps/rest/budget_calculation.rb +0 -45
- data/lib/finapps/rest/budget_models.rb +0 -42
- data/lib/finapps/rest/budgets.rb +0 -103
- data/lib/finapps/rest/cashflows.rb +0 -87
- data/lib/finapps/rest/categories.rb +0 -21
- data/lib/finapps/rest/errors.rb +0 -155
- data/lib/finapps/rest/institutions.rb +0 -47
- data/lib/finapps/rest/relevance/rulesets.rb +0 -64
- data/lib/finapps/rest/transactions.rb +0 -45
- data/lib/finapps/rest/user_institutions.rb +0 -138
- data/lib/finapps/utils/logging.rb +0 -95
- data/lib/finapps/utils/utils.rb +0 -57
- data/spec/middleware/api_token_spec.rb +0 -32
- data/spec/rest/connection_spec.rb +0 -40
- data/spec/rest/users_spec.rb +0 -24
- data/spec/utils/logging_spec.rb +0 -28
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finapps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erich Quintero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
version: '1.0'
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 1.0.
|
62
|
+
version: 1.0.2
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -69,7 +69,7 @@ dependencies:
|
|
69
69
|
version: '1.0'
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: 1.0.
|
72
|
+
version: 1.0.2
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: rash
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,100 +116,100 @@ dependencies:
|
|
116
116
|
requirements:
|
117
117
|
- - "~>"
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version: '11.
|
119
|
+
version: '11.2'
|
120
120
|
- - ">="
|
121
121
|
- !ruby/object:Gem::Version
|
122
|
-
version: 11.
|
122
|
+
version: 11.2.2
|
123
123
|
type: :development
|
124
124
|
prerelease: false
|
125
125
|
version_requirements: !ruby/object:Gem::Requirement
|
126
126
|
requirements:
|
127
127
|
- - "~>"
|
128
128
|
- !ruby/object:Gem::Version
|
129
|
-
version: '11.
|
129
|
+
version: '11.2'
|
130
130
|
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: 11.
|
132
|
+
version: 11.2.2
|
133
133
|
- !ruby/object:Gem::Dependency
|
134
|
-
name:
|
134
|
+
name: rspec
|
135
135
|
requirement: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: '
|
139
|
+
version: '3.4'
|
140
140
|
- - ">="
|
141
141
|
- !ruby/object:Gem::Version
|
142
|
-
version:
|
142
|
+
version: 3.4.0
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
145
|
version_requirements: !ruby/object:Gem::Requirement
|
146
146
|
requirements:
|
147
147
|
- - "~>"
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: '
|
149
|
+
version: '3.4'
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
152
|
+
version: 3.4.0
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
154
|
+
name: webmock
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
159
|
+
version: '2.1'
|
160
160
|
- - ">="
|
161
161
|
- !ruby/object:Gem::Version
|
162
|
-
version:
|
162
|
+
version: 2.1.0
|
163
163
|
type: :development
|
164
164
|
prerelease: false
|
165
165
|
version_requirements: !ruby/object:Gem::Requirement
|
166
166
|
requirements:
|
167
167
|
- - "~>"
|
168
168
|
- !ruby/object:Gem::Version
|
169
|
-
version: '
|
169
|
+
version: '2.1'
|
170
170
|
- - ">="
|
171
171
|
- !ruby/object:Gem::Version
|
172
|
-
version:
|
172
|
+
version: 2.1.0
|
173
173
|
- !ruby/object:Gem::Dependency
|
174
|
-
name:
|
174
|
+
name: sinatra
|
175
175
|
requirement: !ruby/object:Gem::Requirement
|
176
176
|
requirements:
|
177
177
|
- - "~>"
|
178
178
|
- !ruby/object:Gem::Version
|
179
|
-
version: '1.
|
179
|
+
version: '1.4'
|
180
180
|
- - ">="
|
181
181
|
- !ruby/object:Gem::Version
|
182
|
-
version: 1.
|
182
|
+
version: 1.4.7
|
183
183
|
type: :development
|
184
184
|
prerelease: false
|
185
185
|
version_requirements: !ruby/object:Gem::Requirement
|
186
186
|
requirements:
|
187
187
|
- - "~>"
|
188
188
|
- !ruby/object:Gem::Version
|
189
|
-
version: '1.
|
189
|
+
version: '1.4'
|
190
190
|
- - ">="
|
191
191
|
- !ruby/object:Gem::Version
|
192
|
-
version: 1.
|
192
|
+
version: 1.4.7
|
193
193
|
- !ruby/object:Gem::Dependency
|
194
|
-
name:
|
194
|
+
name: simplecov
|
195
195
|
requirement: !ruby/object:Gem::Requirement
|
196
196
|
requirements:
|
197
197
|
- - "~>"
|
198
198
|
- !ruby/object:Gem::Version
|
199
|
-
version: '
|
199
|
+
version: '0.11'
|
200
200
|
- - ">="
|
201
201
|
- !ruby/object:Gem::Version
|
202
|
-
version:
|
202
|
+
version: 0.11.2
|
203
203
|
type: :development
|
204
204
|
prerelease: false
|
205
205
|
version_requirements: !ruby/object:Gem::Requirement
|
206
206
|
requirements:
|
207
207
|
- - "~>"
|
208
208
|
- !ruby/object:Gem::Version
|
209
|
-
version: '
|
209
|
+
version: '0.11'
|
210
210
|
- - ">="
|
211
211
|
- !ruby/object:Gem::Version
|
212
|
-
version:
|
212
|
+
version: 0.11.2
|
213
213
|
description: A simple library for communicating with the FinApps REST API.
|
214
214
|
email:
|
215
215
|
- erich@financialapps.com
|
@@ -221,6 +221,7 @@ extra_rdoc_files:
|
|
221
221
|
files:
|
222
222
|
- ".gitignore"
|
223
223
|
- ".rspec"
|
224
|
+
- ".rubocop.yml"
|
224
225
|
- ".ruby-gemset"
|
225
226
|
- ".ruby-version"
|
226
227
|
- ".travis.yml"
|
@@ -230,42 +231,34 @@ files:
|
|
230
231
|
- Rakefile
|
231
232
|
- finapps.gemspec
|
232
233
|
- lib/finapps.rb
|
233
|
-
- lib/finapps/
|
234
|
-
- lib/finapps/
|
235
|
-
- lib/finapps/
|
236
|
-
- lib/finapps/
|
237
|
-
- lib/finapps/
|
238
|
-
- lib/finapps/
|
239
|
-
- lib/finapps/
|
240
|
-
- lib/finapps/rest/
|
241
|
-
- lib/finapps/rest/budget_models.rb
|
242
|
-
- lib/finapps/rest/budgets.rb
|
243
|
-
- lib/finapps/rest/cashflows.rb
|
244
|
-
- lib/finapps/rest/categories.rb
|
234
|
+
- lib/finapps/core_extensions/hash/compact.rb
|
235
|
+
- lib/finapps/core_extensions/integerable.rb
|
236
|
+
- lib/finapps/core_extensions/object/blank.rb
|
237
|
+
- lib/finapps/error.rb
|
238
|
+
- lib/finapps/hash_constructable.rb
|
239
|
+
- lib/finapps/middleware/raise_error.rb
|
240
|
+
- lib/finapps/middleware/tenant_authentication.rb
|
241
|
+
- lib/finapps/rest/base_client.rb
|
245
242
|
- lib/finapps/rest/client.rb
|
243
|
+
- lib/finapps/rest/configuration.rb
|
246
244
|
- lib/finapps/rest/connection.rb
|
247
245
|
- lib/finapps/rest/defaults.rb
|
248
|
-
- lib/finapps/rest/errors.rb
|
249
|
-
- lib/finapps/rest/institutions.rb
|
250
|
-
- lib/finapps/rest/relevance/rulesets.rb
|
251
246
|
- lib/finapps/rest/resource.rb
|
252
247
|
- lib/finapps/rest/resources.rb
|
253
|
-
- lib/finapps/rest/transactions.rb
|
254
|
-
- lib/finapps/rest/user_institutions.rb
|
255
248
|
- lib/finapps/rest/users.rb
|
256
|
-
- lib/finapps/utils/
|
257
|
-
- lib/finapps/utils/utils.rb
|
249
|
+
- lib/finapps/utils/loggeable.rb
|
258
250
|
- lib/finapps/version.rb
|
259
251
|
- lib/tasks/releaser.rake
|
260
|
-
- spec/middleware/
|
252
|
+
- spec/middleware/tenant_authentication_spec.rb
|
253
|
+
- spec/rest/base_client_spec.rb
|
261
254
|
- spec/rest/client_spec.rb
|
262
|
-
- spec/rest/
|
263
|
-
- spec/rest/users_spec.rb
|
255
|
+
- spec/rest/configuration_spec.rb
|
264
256
|
- spec/spec_helper.rb
|
265
257
|
- spec/support/fake_api.rb
|
258
|
+
- spec/support/fixtures/error.json
|
259
|
+
- spec/support/fixtures/relevance_ruleset_names.json
|
266
260
|
- spec/support/fixtures/user.json
|
267
|
-
|
268
|
-
homepage: http://github.com/finapps/finapps-ruby
|
261
|
+
homepage: https://github.com/finapps/ruby-client
|
269
262
|
licenses:
|
270
263
|
- MIT
|
271
264
|
metadata: {}
|
@@ -291,15 +284,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
291
284
|
version: '0'
|
292
285
|
requirements: []
|
293
286
|
rubyforge_project:
|
294
|
-
rubygems_version: 2.
|
287
|
+
rubygems_version: 2.5.1
|
295
288
|
signing_key:
|
296
289
|
specification_version: 4
|
297
290
|
summary: FinApps REST API ruby client.
|
298
291
|
test_files:
|
299
292
|
- spec/spec_helper.rb
|
300
293
|
- spec/support/fake_api.rb
|
301
|
-
- spec/
|
302
|
-
- spec/middleware/api_token_spec.rb
|
303
|
-
- spec/rest/connection_spec.rb
|
294
|
+
- spec/middleware/tenant_authentication_spec.rb
|
304
295
|
- spec/rest/client_spec.rb
|
305
|
-
- spec/rest/
|
296
|
+
- spec/rest/base_client_spec.rb
|
297
|
+
- spec/rest/configuration_spec.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module FinApps
|
2
|
-
module Middleware
|
3
|
-
|
4
|
-
class ApiToken < Faraday::Middleware
|
5
|
-
include FinApps::Logging
|
6
|
-
|
7
|
-
def initialize(app, options={})
|
8
|
-
@app = app
|
9
|
-
@options = options
|
10
|
-
end
|
11
|
-
|
12
|
-
def call(env)
|
13
|
-
company_identifier = @options[:company_identifier].trim
|
14
|
-
raise FinApps::REST::MissingArgumentsError.new 'Missing argument: company_identifier.' if company_identifier.blank?
|
15
|
-
|
16
|
-
company_token = @options[:company_token].trim
|
17
|
-
raise FinApps::REST::MissingArgumentsError.new 'Missing argument: company_token.' if company_token.blank?
|
18
|
-
|
19
|
-
env[:request_headers]['X-FinApps-Token'] = "#{company_identifier}=#{company_token}"
|
20
|
-
@app.call(env)
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
@@ -1,92 +0,0 @@
|
|
1
|
-
module FinApps
|
2
|
-
module Middleware
|
3
|
-
|
4
|
-
class RaiseHttpExceptions < Faraday::Response::Middleware
|
5
|
-
include FinApps::Logging
|
6
|
-
|
7
|
-
CLIENT_ERROR_STATUSES = 400...600
|
8
|
-
|
9
|
-
def on_complete(env)
|
10
|
-
|
11
|
-
case env[:status]
|
12
|
-
when 400
|
13
|
-
raise FinApps::REST::BadRequest, response_values(env, 'The request could not be understood by the server due to malformed syntax.')
|
14
|
-
when 401
|
15
|
-
raise FinApps::REST::Unauthorized, response_values(env, 'The request requires user authentication.')
|
16
|
-
when 403
|
17
|
-
raise FinApps::REST::Forbidden, response_values(env, 'Forbidden.')
|
18
|
-
when 404
|
19
|
-
raise FinApps::REST::NotFound, response_values(env, 'Page not found.')
|
20
|
-
when 405
|
21
|
-
raise FinApps::REST::MethodNotAllowed, response_values(env, 'The method specified in the Request-Line is not allowed for the resource identified by the Request-URI.')
|
22
|
-
when 406
|
23
|
-
raise FinApps::REST::NotAcceptable, response_values(env, 'The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request')
|
24
|
-
when 407
|
25
|
-
raise Faraday::Error::ConnectionFailed, response_values(env, 'Proxy Authentication Required.')
|
26
|
-
when 409
|
27
|
-
raise FinApps::REST::Conflict, response_values(env, 'The request could not be completed due to a conflict with the current state of the resource.')
|
28
|
-
|
29
|
-
when 500
|
30
|
-
raise FinApps::REST::InternalServerError, response_values(env, 'Unexpected technical condition was encountered.')
|
31
|
-
when 502
|
32
|
-
raise FinApps::REST::BadGateway, response_values(env, 'The server returned an invalid or incomplete response.')
|
33
|
-
when 503
|
34
|
-
raise FinApps::REST::ServiceUnavailable, response_values(env, 'The server is currently unavailable.')
|
35
|
-
when 504
|
36
|
-
raise FinApps::REST::GatewayTimeout, response_values(env, 'Gateway Time-out')
|
37
|
-
when 505
|
38
|
-
raise FinApps::REST::VersionNotSupported, response_values(env, 'The Web server does not support the specified HTTP protocol version.')
|
39
|
-
|
40
|
-
when CLIENT_ERROR_STATUSES
|
41
|
-
raise FinApps::REST::Error, response_values(env, 'Unexpected error.')
|
42
|
-
|
43
|
-
else
|
44
|
-
# 200..206 Success codes
|
45
|
-
# all good!
|
46
|
-
logger.debug "##{__method__} => Status code: [#{env[:status]}]."
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def error_messages(body)
|
54
|
-
error_array = Array.new
|
55
|
-
|
56
|
-
if body.present? && body.kind_of?(String)
|
57
|
-
begin
|
58
|
-
parsed = ::JSON.parse(body)
|
59
|
-
if parsed
|
60
|
-
parsed.each do |key, value|
|
61
|
-
value.each do |message|
|
62
|
-
logger.debug "#{key} => #{message}"
|
63
|
-
error_array.push message.to_s
|
64
|
-
end
|
65
|
-
end
|
66
|
-
logger.info "##{__method__} => Extracted errors: #{error_array.inspect}."
|
67
|
-
else
|
68
|
-
logger.info "##{__method__} => Cannot extract errors: unexpected error while parsing response."
|
69
|
-
end
|
70
|
-
rescue ::JSON::ParserError => e
|
71
|
-
logger.error "##{__method__} => Unable to parse JSON response."
|
72
|
-
logger.error e
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
error_array
|
77
|
-
end
|
78
|
-
|
79
|
-
def response_values(env, status_message = nil)
|
80
|
-
{
|
81
|
-
:status => env.status,
|
82
|
-
:status_message => status_message,
|
83
|
-
:headers => env.response_headers,
|
84
|
-
:body => env.body,
|
85
|
-
:error_messages => error_messages(env.body)
|
86
|
-
}
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|
92
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module FinApps
|
2
|
-
module Middleware
|
3
|
-
|
4
|
-
class ResponseLogger < Faraday::Response::Middleware
|
5
|
-
include FinApps::Logging
|
6
|
-
|
7
|
-
def call(env)
|
8
|
-
logger.info "##{__method__} => ##{env.method} #{env.url.to_s}"
|
9
|
-
logger.debug "##{__method__} => Request Headers: #{dump_headers env.request_headers}"
|
10
|
-
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
|
-
def on_complete(env)
|
15
|
-
logger.info "##{__method__} => ##{env.method} #{env.url.to_s}"
|
16
|
-
logger.debug "##{__method__} => Response Headers: #{dump_headers env.response_headers}"
|
17
|
-
logger.info "##{__method__} => Response Body: #{env.body}" if env.body
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
def dump_headers(headers)
|
22
|
-
headers.map { |k, v| " #{k}: #{filter_sensitive_header_values(k,v)}" }.to_s
|
23
|
-
end
|
24
|
-
|
25
|
-
def filter_sensitive_header_values(key, value)
|
26
|
-
case key
|
27
|
-
when 'X-FinApps-Token', 'Authorization'
|
28
|
-
'[REDACTED]'
|
29
|
-
else
|
30
|
-
value.inspect
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
data/lib/finapps/rest/alert.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
module FinApps
|
2
|
-
module REST
|
3
|
-
|
4
|
-
require 'erb'
|
5
|
-
|
6
|
-
class Alert < FinApps::REST::Resources
|
7
|
-
include FinApps::REST::Defaults
|
8
|
-
|
9
|
-
# @return [Hash, Array<String>]
|
10
|
-
def list(page = 1, requested=100, sort='date', asc=false, read='all')
|
11
|
-
|
12
|
-
end_point = Defaults::END_POINTS[:alert_list]
|
13
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
14
|
-
|
15
|
-
path = end_point.sub ':page', ERB::Util.url_encode(page)
|
16
|
-
path = path.sub ':requested', ERB::Util.url_encode(requested)
|
17
|
-
path = path.sub ':sort', ERB::Util.url_encode(sort)
|
18
|
-
path = path.sub ':asc', ERB::Util.url_encode(asc)
|
19
|
-
path = path.sub ':read', ERB::Util.url_encode(read)
|
20
|
-
logger.debug "##{__method__} => path: #{path}"
|
21
|
-
|
22
|
-
result, error_messages = client.send_request(path, :get)
|
23
|
-
return result, error_messages
|
24
|
-
end
|
25
|
-
|
26
|
-
# @return [Hash, Array<String>]
|
27
|
-
def update(alert_id, read=true)
|
28
|
-
raise MissingArgumentsError.new 'Missing argument: alert_id.' if alert_id.blank?
|
29
|
-
logger.debug "##{__method__} => alert_id: #{alert_id.inspect}"
|
30
|
-
|
31
|
-
raise MissingArgumentsError.new 'Missing argument: read.' if read.blank?
|
32
|
-
logger.debug "##{__method__} => read: #{read.inspect}"
|
33
|
-
|
34
|
-
end_point = Defaults::END_POINTS[:alert_update]
|
35
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
36
|
-
|
37
|
-
path = end_point.sub ':alert_id', ERB::Util.url_encode(alert_id)
|
38
|
-
path = path.sub ':read', ERB::Util.url_encode(read)
|
39
|
-
logger.debug "##{__method__} => path: #{path}"
|
40
|
-
|
41
|
-
_, error_messages = client.send_request(path, :put)
|
42
|
-
error_messages
|
43
|
-
end
|
44
|
-
|
45
|
-
# @return [Hash, Array<String>]
|
46
|
-
def delete(alert_id)
|
47
|
-
raise MissingArgumentsError.new 'Missing argument: alert_id.' if alert_id.blank?
|
48
|
-
logger.debug "##{__method__} => alert_id: #{alert_id.inspect}"
|
49
|
-
|
50
|
-
end_point = Defaults::END_POINTS[:alert_delete]
|
51
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
52
|
-
|
53
|
-
path = end_point.sub ':alert_id', ERB::Util.url_encode(alert_id)
|
54
|
-
logger.debug "##{__method__} => path: #{path}"
|
55
|
-
|
56
|
-
_, error_messages = client.send_request(path, :delete)
|
57
|
-
error_messages
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module FinApps
|
2
|
-
module REST
|
3
|
-
|
4
|
-
require 'erb'
|
5
|
-
|
6
|
-
class AlertDefinition < FinApps::REST::Resources
|
7
|
-
include FinApps::REST::Defaults
|
8
|
-
|
9
|
-
# Returns a list of alert definitions for current tenant.
|
10
|
-
# @return [Hash, Array<String>]
|
11
|
-
def list
|
12
|
-
end_point = Defaults::END_POINTS[:alert_definition_list]
|
13
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
14
|
-
|
15
|
-
path = end_point
|
16
|
-
logger.debug "##{__method__} => path: #{path}"
|
17
|
-
|
18
|
-
result, error_messages = client.send_request(path, :get)
|
19
|
-
return result, error_messages
|
20
|
-
end
|
21
|
-
|
22
|
-
# Shows a single alert definition matching the given alert name.
|
23
|
-
# @return [Hash, Array<String>]
|
24
|
-
def show(alert_name)
|
25
|
-
raise MissingArgumentsError.new 'Missing argument: alert_name.' if alert_name.blank?
|
26
|
-
logger.debug "##{__method__} => alert_name: #{alert_name}"
|
27
|
-
|
28
|
-
end_point = Defaults::END_POINTS[:alert_definition_show]
|
29
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
30
|
-
|
31
|
-
path = end_point.sub ':alert_name', ERB::Util.url_encode(alert_name)
|
32
|
-
logger.debug "##{__method__} => path: #{path}"
|
33
|
-
|
34
|
-
result, error_messages = client.send_request(path, :get)
|
35
|
-
return result, error_messages
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module FinApps
|
2
|
-
module REST
|
3
|
-
|
4
|
-
require 'erb'
|
5
|
-
|
6
|
-
class AlertPreferences < FinApps::REST::Resources
|
7
|
-
include FinApps::REST::Defaults
|
8
|
-
|
9
|
-
# Shows alert preferences for a given user
|
10
|
-
# @return [Hash, Array<String>]
|
11
|
-
def show
|
12
|
-
end_point = Defaults::END_POINTS[:alert_preferences_show]
|
13
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
14
|
-
|
15
|
-
path = end_point
|
16
|
-
logger.debug "##{__method__} => path: #{path}"
|
17
|
-
|
18
|
-
result, error_messages = client.send_request(path, :get)
|
19
|
-
return result, error_messages
|
20
|
-
end
|
21
|
-
|
22
|
-
# Updates alert preferences for a given user
|
23
|
-
# @return [Hash, Array<String>]
|
24
|
-
def update(params)
|
25
|
-
raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
|
26
|
-
logger.debug "##{__method__} => params: #{params.inspect}"
|
27
|
-
|
28
|
-
end_point = Defaults::END_POINTS[:alert_preferences_update]
|
29
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
30
|
-
|
31
|
-
path = end_point
|
32
|
-
logger.debug "##{__method__} => path: #{path}"
|
33
|
-
|
34
|
-
_, error_messages = client.send_request(path, :put, params.compact)
|
35
|
-
error_messages
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module FinApps
|
2
|
-
module REST
|
3
|
-
|
4
|
-
require 'erb'
|
5
|
-
|
6
|
-
class AlertSettings < FinApps::REST::Resources
|
7
|
-
include FinApps::REST::Defaults
|
8
|
-
|
9
|
-
# Shows alert settings for a given user.
|
10
|
-
# @return [Hash, Array<String>]
|
11
|
-
def show
|
12
|
-
end_point = Defaults::END_POINTS[:alert_settings_show]
|
13
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
14
|
-
|
15
|
-
path = end_point
|
16
|
-
logger.debug "##{__method__} => path: #{path}"
|
17
|
-
|
18
|
-
result, error_messages = client.send_request(path, :get)
|
19
|
-
return result, error_messages
|
20
|
-
end
|
21
|
-
|
22
|
-
# Updates alert settings for a given user.
|
23
|
-
# @return [Hash, Array<String>]
|
24
|
-
def update(params)
|
25
|
-
raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
|
26
|
-
logger.debug "##{__method__} => params: #{params.inspect}"
|
27
|
-
|
28
|
-
end_point = Defaults::END_POINTS[:alert_settings_update]
|
29
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
30
|
-
|
31
|
-
path = end_point
|
32
|
-
logger.debug "##{__method__} => path: #{path}"
|
33
|
-
|
34
|
-
_, error_messages = client.send_request(path, :put, params.compact)
|
35
|
-
error_messages
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module FinApps
|
2
|
-
module REST
|
3
|
-
|
4
|
-
require 'erb'
|
5
|
-
|
6
|
-
class BudgetCalculation < FinApps::REST::Resources
|
7
|
-
include FinApps::REST::Defaults
|
8
|
-
|
9
|
-
# Creates a new Budget Calculation for the given user, using a budget template
|
10
|
-
# matching budget_model_id and teh given income amount.
|
11
|
-
# @param [String] budget_model_id
|
12
|
-
# @param [Number] income
|
13
|
-
# @return [Array<Hash>, Array<String>]
|
14
|
-
def create(budget_model_id, income)
|
15
|
-
raise MissingArgumentsError.new 'Missing argument: budget_model_id.' if budget_model_id.blank?
|
16
|
-
logger.debug "##{__method__} => budget_model: #{budget_model_id}"
|
17
|
-
raise MissingArgumentsError.new 'Missing argument: income.' if income.blank?
|
18
|
-
logger.debug "##{__method__} => income: #{income}"
|
19
|
-
|
20
|
-
end_point = Defaults::END_POINTS[:budget_calculation_create]
|
21
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
22
|
-
|
23
|
-
path = end_point.sub(':budget_model_id', ERB::Util.url_encode(budget_model_id)).sub(':income', ERB::Util.url_encode(income))
|
24
|
-
logger.debug "##{__method__} => path: #{path}"
|
25
|
-
|
26
|
-
budget_calculation, error_messages = client.send_request(path, :get)
|
27
|
-
return budget_calculation, error_messages
|
28
|
-
end
|
29
|
-
|
30
|
-
# Shows the Budget Calculation for the given user.
|
31
|
-
# @return [Array<Hash>, Array<String>]
|
32
|
-
def show
|
33
|
-
end_point = Defaults::END_POINTS[:budget_calculation_show]
|
34
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
35
|
-
|
36
|
-
path = end_point
|
37
|
-
logger.debug "##{__method__} => path: #{path}"
|
38
|
-
|
39
|
-
budget_calculation, error_messages = client.send_request(path, :get)
|
40
|
-
return budget_calculation, error_messages
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module FinApps
|
2
|
-
module REST
|
3
|
-
|
4
|
-
require 'erb'
|
5
|
-
|
6
|
-
class BudgetModels < FinApps::REST::Resources
|
7
|
-
include FinApps::REST::Defaults
|
8
|
-
|
9
|
-
# Lists all budget models.
|
10
|
-
# @return [Array<Hash>, Array<String>]
|
11
|
-
def list
|
12
|
-
path = Defaults::END_POINTS[:budget_models_list]
|
13
|
-
logger.debug "##{__method__} => path: #{path}"
|
14
|
-
|
15
|
-
budget_models, error_messages = client.send_request(path, :get)
|
16
|
-
return budget_models, error_messages
|
17
|
-
end
|
18
|
-
|
19
|
-
# Shows a budget model matching a given budget_model_id
|
20
|
-
# @param [Integer] budget_model_id
|
21
|
-
def show(budget_model_id)
|
22
|
-
raise MissingArgumentsError.new 'Missing argument: budget_model_id.' if budget_model_id.blank?
|
23
|
-
logger.debug "##{__method__} => budget_model_id: #{budget_model_id}"
|
24
|
-
|
25
|
-
end_point = Defaults::END_POINTS[:budget_models_show]
|
26
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
27
|
-
|
28
|
-
path = end_point.sub ':budget_model_id', ERB::Util.url_encode(budget_model_id)
|
29
|
-
logger.debug "##{__method__} => path: #{path}"
|
30
|
-
|
31
|
-
budget_model, error_messages = client.send_request(path, :get) { |r| BudgetModel.new(r.body) }
|
32
|
-
return budget_model, error_messages
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
class BudgetModel < FinApps::REST::Resource
|
38
|
-
attr_accessor :_id, :name, :desc
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
end
|