finapps 0.22.2.pre → 0.22.3.pre

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ca6b380d56d4a5bc2c2e27149d6fee6f8d78da0
4
- data.tar.gz: a6ebbbd6d7725d5370450d8cbe4282e38fe3dd27
3
+ metadata.gz: 43ea47ac9694d4dba3fab923139344ee89b46780
4
+ data.tar.gz: f9aa6c0f7a25bd48d9af43ceecd311c0db19b2ab
5
5
  SHA512:
6
- metadata.gz: ac33f9808003c4579c57b6074e2fddd695b0925f23dc4b33c02931dd5b8c574e987f4d0e764f464dfe402a28879b445b9eb30ecc6ff26b0e4b49e5b40a9e0f9b
7
- data.tar.gz: de1b4e6a5205ab7ff48cfb9c26665fd90f46c829a3be642209a7a929567eba209cb5043cde6d306a7d5160ee1d29654933a761e784f0db0577dbbf11581d554f
6
+ metadata.gz: 8dec3552f184098e53af7da7170ff01838b898422c8a4b53f8e94040ab0db12a8d8eac63cb5d8c01b5292dac7f6435fd6ad630fb839c3cde2cfe44bd6d683b7a
7
+ data.tar.gz: 5ed925c293033c7de685ff0077c64603a5deb1d8b168feab3ac3e4a1c1b530339a0301fd5820f344e477284cc9863beb0150500484f19b9904bfd144da133d3a
data/.gitignore CHANGED
@@ -1,6 +1,4 @@
1
1
  *.gem
2
- *.rbc
3
- .bundle
4
2
  .config
5
3
  .yardoc
6
4
  Gemfile.lock
@@ -11,12 +9,34 @@ doc/
11
9
  lib/bundler/man
12
10
  pkg
13
11
  rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
12
  *.bundle
19
13
  *.so
20
14
  *.o
21
15
  *.a
22
16
  mkmf.log
17
+
18
+ # Ignore bundler config.
19
+ /.bundle
20
+ /vendor/bundle/
21
+ /vendor/ruby/
22
+
23
+ # Ignore all log files and tempfiles.
24
+ /log/*
25
+ !/log/.keep
26
+ /tmp
27
+
28
+ # various artifacts
29
+ **.war
30
+ *.rbc
31
+ *.sassc
32
+ .project
33
+ .secret
34
+ .rspec
35
+ .idea/
36
+ /spec/tmp/*
37
+ /cache
38
+
39
+ *.BACKUP.*
40
+ *.BASE.*
41
+ *.LOCAL.*
42
+ *.REMOTE.*
data/README.md CHANGED
@@ -5,7 +5,7 @@ FinApps Ruby-Client
5
5
 
6
6
  [![Gem Version](http://img.shields.io/gem/v/finapps.svg)][gem]
7
7
 
8
- ![Build Status](http://teamciti.powerwallet.com/app/rest/builds/buildType:(id:FaRuby_BuildMaster)/statusIcon)
8
+ [![Build Status](http://teamciti.powerwallet.com/app/rest/builds/buildType:(id:FaRuby_BuildMaster)/statusIcon)][build_status]
9
9
 
10
10
 
11
11
  Ruby client for [FinApps][financialapps].
@@ -73,3 +73,4 @@ Please check the [FinApps wiki][wiki] for extended documentation.
73
73
  [bundler]: http://bundler.io
74
74
  [rubygems]: http://rubygems.org
75
75
  [gem]: https://rubygems.org/gems/finapps
76
+ [build_status]: http://teamciti.powerwallet.com/viewType.html?buildTypeId=FaRuby_BuildMaster&guest=1
@@ -8,7 +8,6 @@ module FinApps
8
8
 
9
9
  # @return [Hash, Array<String>]
10
10
  def list(page = 1, requested=100, sort='date', asc=false, read='all')
11
- logger.debug "##{__method__.to_s} => Started"
12
11
 
13
12
  end_point = Defaults::END_POINTS[:alert_list]
14
13
  logger.debug "##{__method__.to_s} => end_point: #{end_point}"
@@ -22,16 +21,14 @@ module FinApps
22
21
 
23
22
  result, error_messages = @client.send(path, :get)
24
23
 
25
- logger.debug "##{__method__.to_s} => Completed"
26
24
  return result, error_messages
27
25
  end
28
26
 
29
27
  # @return [Hash, Array<String>]
30
28
  def update(alert_id, read=true)
31
- logger.debug "##{__method__.to_s} => Started"
32
-
33
29
  raise MissingArgumentsError.new 'Missing argument: alert_id.' if alert_id.blank?
34
30
  logger.debug "##{__method__.to_s} => alert_id: #{alert_id.inspect}"
31
+
35
32
  raise MissingArgumentsError.new 'Missing argument: read.' if read.blank?
36
33
  logger.debug "##{__method__.to_s} => read: #{read.inspect}"
37
34
 
@@ -44,14 +41,11 @@ module FinApps
44
41
 
45
42
  _, error_messages = @client.send(path, :put)
46
43
 
47
- logger.debug "##{__method__.to_s} => Completed"
48
44
  error_messages
49
45
  end
50
46
 
51
47
  # @return [Hash, Array<String>]
52
48
  def delete(alert_id)
53
- logger.debug "##{__method__.to_s} => Started"
54
-
55
49
  raise MissingArgumentsError.new 'Missing argument: alert_id.' if alert_id.blank?
56
50
  logger.debug "##{__method__.to_s} => alert_id: #{alert_id.inspect}"
57
51
 
@@ -63,7 +57,6 @@ module FinApps
63
57
 
64
58
  _, error_messages = @client.send(path, :delete)
65
59
 
66
- logger.debug "##{__method__.to_s} => Completed"
67
60
  error_messages
68
61
  end
69
62
 
@@ -8,8 +8,6 @@ module FinApps
8
8
 
9
9
  # @return [Hash, Array<String>]
10
10
  def list
11
- logger.debug "##{__method__.to_s} => Started"
12
-
13
11
  end_point = Defaults::END_POINTS[:alert_definition_list]
14
12
  logger.debug "##{__method__.to_s} => end_point: #{end_point}"
15
13
 
@@ -17,15 +15,11 @@ module FinApps
17
15
  logger.debug "##{__method__.to_s} => path: #{path}"
18
16
 
19
17
  result, error_messages = @client.send(path, :get)
20
-
21
- logger.debug "##{__method__.to_s} => Completed"
22
18
  return result, error_messages
23
19
  end
24
20
 
25
21
  # @return [Hash, Array<String>]
26
22
  def show(alert_name)
27
- logger.debug "##{__method__.to_s} => Started"
28
-
29
23
  raise MissingArgumentsError.new 'Missing argument: alert_name.' if alert_name.blank?
30
24
  logger.debug "##{__method__.to_s} => alert_name: #{alert_name}"
31
25
 
@@ -36,8 +30,6 @@ module FinApps
36
30
  logger.debug "##{__method__.to_s} => path: #{path}"
37
31
 
38
32
  result, error_messages = @client.send(path, :get)
39
-
40
- logger.debug "##{__method__.to_s} => Completed"
41
33
  return result, error_messages
42
34
  end
43
35
 
@@ -8,8 +8,6 @@ module FinApps
8
8
 
9
9
  # @return [Hash, Array<String>]
10
10
  def show
11
- logger.debug "##{__method__.to_s} => Started"
12
-
13
11
  end_point = Defaults::END_POINTS[:alert_preferences_show]
14
12
  logger.debug "##{__method__.to_s} => end_point: #{end_point}"
15
13
 
@@ -17,15 +15,11 @@ module FinApps
17
15
  logger.debug "##{__method__.to_s} => path: #{path}"
18
16
 
19
17
  result, error_messages = @client.send(path, :get)
20
-
21
- logger.debug "##{__method__.to_s} => Completed"
22
18
  return result, error_messages
23
19
  end
24
20
 
25
21
  # @return [Hash, Array<String>]
26
22
  def update(params)
27
- logger.debug "##{__method__.to_s} => Started"
28
-
29
23
  raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
30
24
  logger.debug "##{__method__.to_s} => params: #{params.inspect}"
31
25
 
@@ -36,8 +30,6 @@ module FinApps
36
30
  logger.debug "##{__method__.to_s} => path: #{path}"
37
31
 
38
32
  _, error_messages = @client.send(path, :put, params.compact)
39
-
40
- logger.debug "##{__method__.to_s} => Completed"
41
33
  error_messages
42
34
  end
43
35
 
@@ -8,8 +8,6 @@ module FinApps
8
8
 
9
9
  # @return [Hash, Array<String>]
10
10
  def show
11
- logger.debug "##{__method__.to_s} => Started"
12
-
13
11
  end_point = Defaults::END_POINTS[:alert_settings_show]
14
12
  logger.debug "##{__method__.to_s} => end_point: #{end_point}"
15
13
 
@@ -17,15 +15,11 @@ module FinApps
17
15
  logger.debug "##{__method__.to_s} => path: #{path}"
18
16
 
19
17
  result, error_messages = @client.send(path, :get)
20
-
21
- logger.debug "##{__method__.to_s} => Completed"
22
18
  return result, error_messages
23
19
  end
24
20
 
25
21
  # @return [Hash, Array<String>]
26
22
  def update(params)
27
- logger.debug "##{__method__.to_s} => Started"
28
-
29
23
  raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
30
24
  logger.debug "##{__method__.to_s} => params: #{params.inspect}"
31
25
 
@@ -36,8 +30,6 @@ module FinApps
36
30
  logger.debug "##{__method__.to_s} => path: #{path}"
37
31
 
38
32
  _, error_messages = @client.send(path, :put, params.compact)
39
-
40
- logger.debug "##{__method__.to_s} => Completed"
41
33
  error_messages
42
34
  end
43
35
 
@@ -10,10 +10,9 @@ module FinApps
10
10
  # @param [Number] income
11
11
  # @return [Array<Hash>, Array<String>]
12
12
  def create(budget_model_id, income)
13
- logger.debug "##{__method__.to_s} => Started"
14
-
15
13
  raise MissingArgumentsError.new 'Missing argument: budget_model_id.' if budget_model_id.blank?
16
14
  logger.debug "##{__method__.to_s} => budget_model: #{budget_model_id}"
15
+
17
16
  raise MissingArgumentsError.new 'Missing argument: income.' if income.blank?
18
17
  logger.debug "##{__method__.to_s} => income: #{income}"
19
18
 
@@ -24,15 +23,11 @@ module FinApps
24
23
  logger.debug "##{__method__.to_s} => path: #{path}"
25
24
 
26
25
  budget_calculation, error_messages = @client.send(path, :get)
27
- logger.debug "##{__method__.to_s} => Completed"
28
-
29
26
  return budget_calculation, error_messages
30
27
  end
31
28
 
32
29
  # @return [Array<Hash>, Array<String>]
33
30
  def show
34
- logger.debug "##{__method__.to_s} => Started"
35
-
36
31
  end_point = Defaults::END_POINTS[:budget_calculation_show]
37
32
  logger.debug "##{__method__.to_s} => end_point: #{end_point}"
38
33
 
@@ -40,8 +35,6 @@ module FinApps
40
35
  logger.debug "##{__method__.to_s} => path: #{path}"
41
36
 
42
37
  budget_calculation, error_messages = @client.send(path, :get)
43
- logger.debug "##{__method__.to_s} => Completed"
44
-
45
38
  return budget_calculation, error_messages
46
39
  end
47
40
 
@@ -8,21 +8,15 @@ module FinApps
8
8
 
9
9
  # @return [Array<Hash>, Array<String>]
10
10
  def list
11
- logger.debug "##{__method__.to_s} => Started"
12
-
13
11
  path = Defaults::END_POINTS[:budget_models_list]
14
12
  logger.debug "##{__method__.to_s} => path: #{path}"
15
13
 
16
14
  budget_models, error_messages = @client.send(path, :get)
17
-
18
- logger.debug "##{__method__.to_s} => Completed"
19
15
  return budget_models, error_messages
20
16
  end
21
17
 
22
18
  # @param [Integer] budget_model_id
23
19
  def show(budget_model_id)
24
- logger.debug "##{__method__.to_s} => Started"
25
-
26
20
  raise MissingArgumentsError.new 'Missing argument: budget_model_id.' if budget_model_id.blank?
27
21
  logger.debug "##{__method__.to_s} => budget_model_id: #{budget_model_id}"
28
22
 
@@ -33,8 +27,6 @@ module FinApps
33
27
  logger.debug "##{__method__.to_s} => path: #{path}"
34
28
 
35
29
  budget_model, error_messages = @client.send(path, :get) { |r| BudgetModel.new(r.body) }
36
-
37
- logger.debug "##{__method__.to_s} => Completed"
38
30
  return budget_model, error_messages
39
31
  end
40
32
 
@@ -10,10 +10,9 @@ module FinApps
10
10
  # @param [Date] end_date
11
11
  # @return [Hash, Array<String>]
12
12
  def show(start_date, end_date)
13
- logger.debug "##{__method__.to_s} => Started"
14
-
15
13
  raise MissingArgumentsError.new 'Missing argument: start_date.' if start_date.blank?
16
14
  logger.debug "##{__method__.to_s} => start_date: #{start_date}"
15
+
17
16
  raise MissingArgumentsError.new 'Missing argument: end_date.' if end_date.blank?
18
17
  logger.debug "##{__method__.to_s} => end_date: #{end_date}"
19
18
 
@@ -34,23 +33,18 @@ module FinApps
34
33
  categories.each { |category| budget.details << result_category_to_budget_detail(category, transactions) }
35
34
  end
36
35
 
37
- logger.debug "##{__method__.to_s} => Completed"
38
36
  return budget, error_messages
39
37
  end
40
38
 
41
39
  # @param [Hash] params
42
40
  # @return [Array<Hash>, Array<String>]
43
41
  def update(params={})
44
- logger.debug "##{__method__.to_s} => Started"
45
-
46
42
  raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
47
43
 
48
44
  end_point = Defaults::END_POINTS[:budget_update]
49
45
  logger.debug "##{__method__.to_s} => end_point: #{end_point}"
50
46
 
51
47
  budget, error_messages = @client.send(end_point, :put, params)
52
- logger.debug "##{__method__.to_s} => Completed"
53
-
54
48
  return budget, error_messages
55
49
  end
56
50
 
@@ -10,10 +10,9 @@ module FinApps
10
10
  # @param [Date] end_date
11
11
  # @return [Hash, Array<String>]
12
12
  def show(start_date, end_date)
13
- logger.debug "##{__method__.to_s} => Started"
14
-
15
13
  raise MissingArgumentsError.new 'Missing argument: start_date.' if start_date.blank?
16
14
  logger.debug "##{__method__.to_s} => start_date: #{start_date}"
15
+
17
16
  raise MissingArgumentsError.new 'Missing argument: end_date.' if end_date.blank?
18
17
  logger.debug "##{__method__.to_s} => end_date: #{end_date}"
19
18
 
@@ -52,7 +51,6 @@ module FinApps
52
51
  categories.each { |category| cashflow.details << result_category_to_cashflow_detail(category) }
53
52
  end
54
53
 
55
- logger.debug "##{__method__.to_s} => Completed"
56
54
  return cashflow, error_messages
57
55
  end
58
56
 
@@ -5,8 +5,6 @@ module FinApps
5
5
 
6
6
  # @return [Array<Hash>, Array<String>]
7
7
  def list
8
- logger.debug "##{__method__.to_s} => Started"
9
-
10
8
  end_point = Defaults::END_POINTS[:categories_list]
11
9
  logger.debug "##{__method__.to_s} => end_point: #{end_point}"
12
10
 
@@ -14,8 +12,6 @@ module FinApps
14
12
  logger.debug "##{__method__.to_s} => path: #{path}"
15
13
 
16
14
  categories, error_messages = @client.send(path, :get)
17
-
18
- logger.debug "##{__method__.to_s} => Completed"
19
15
  return categories, error_messages
20
16
  end
21
17
 
@@ -16,8 +16,6 @@ module FinApps
16
16
  # @param [Hash] options
17
17
  # @return [FinApps::REST::Client]
18
18
  def initialize(company_identifier, company_token, options = {})
19
- logger.debug "##{__method__.to_s} => Started"
20
-
21
19
  @config = DEFAULTS.merge! options
22
20
  if @config[:logger_tag].present?
23
21
  Logging.tag= @config[:logger_tag]
@@ -34,8 +32,6 @@ module FinApps
34
32
 
35
33
  set_up_resources
36
34
  logger.debug "##{__method__.to_s} => All resources initialized"
37
-
38
- logger.debug "##{__method__.to_s} => Completed"
39
35
  end
40
36
 
41
37
  # Performs HTTP GET, POST, UPDATE and DELETE requests.
@@ -47,7 +43,6 @@ module FinApps
47
43
  # @param [Proc] proc
48
44
  # @return [Hash,Array<String>]
49
45
  def send(path, method, params = {}, &proc)
50
- logger.debug "##{__method__.to_s} => Started"
51
46
  raise MissingArgumentsError.new 'Missing argument: method.' if method.blank?
52
47
  result, error_messages = nil, nil
53
48
 
@@ -84,18 +79,14 @@ module FinApps
84
79
  logger.fatal "##{__method__.to_s} => Exception, #{error.to_s}"
85
80
  logger.fatal error
86
81
  ensure
87
- logger.error "##{__method__.to_s} => Failed, error_messages: #{error_messages.pretty_inspect}" if error_messages.present?
82
+ logger.debug "##{__method__.to_s} => Failed, error_messages: #{error_messages.pretty_inspect}" if error_messages.present?
88
83
  end
89
-
90
- logger.debug "##{__method__.to_s} => Completed"
91
84
  return result, error_messages
92
85
  end
93
86
 
94
87
  # @param [String] user_identifier
95
88
  # @param [String] user_token
96
89
  def user_credentials!(user_identifier, user_token)
97
- logger.debug "##{__method__.to_s} => Started"
98
-
99
90
  {:user_identifier => user_identifier, :user_token => user_token}.validate_required_strings!
100
91
  logger.debug "##{__method__.to_s} => Credentials passed validation. Attempting to set user credentials on current connection."
101
92
 
@@ -103,8 +94,6 @@ module FinApps
103
94
  @config[:user_identifier] = user_identifier
104
95
  @config[:user_token] = user_token
105
96
  @connection = set_up_connection(@company_credentials, @config)
106
-
107
- logger.debug "##{__method__.to_s} => Completed"
108
97
  end
109
98
 
110
99
  private
@@ -116,16 +105,10 @@ module FinApps
116
105
  # @param [String] path
117
106
  # @return [Hash,Array<String>]
118
107
  def get(path)
119
- logger.debug "##{__method__.to_s} => Started"
120
108
  raise MissingArgumentsError.new 'Missing argument: path.' if path.blank?
121
109
 
122
110
  logger.debug "##{__method__.to_s} => GET path:#{path}"
123
- response = @connection.get do |req|
124
- req.url path
125
- end
126
-
127
- logger.debug "##{__method__.to_s} => Completed"
128
- response
111
+ @connection.get { |req| req.url path }
129
112
  end
130
113
 
131
114
  # Performs an HTTP POST request.
@@ -136,17 +119,13 @@ module FinApps
136
119
  # @param [Hash] params
137
120
  # @return [Hash,Array<String>]
138
121
  def post(path, params = {})
139
- logger.debug "##{__method__.to_s} => Started"
140
122
  raise MissingArgumentsError.new 'Missing argument: path.' if path.blank?
141
123
 
142
124
  logger.debug "##{__method__.to_s} => POST path:#{path} params:#{skip_sensitive_data params }"
143
- response = @connection.post do |req|
125
+ @connection.post do |req|
144
126
  req.url path
145
127
  req.body = params
146
128
  end
147
-
148
- logger.debug "##{__method__.to_s} => Completed"
149
- response
150
129
  end
151
130
 
152
131
  # Performs an HTTP PUT request.
@@ -157,17 +136,13 @@ module FinApps
157
136
  # @param [Hash] params
158
137
  # @return [Hash,Array<String>]
159
138
  def put(path, params = {})
160
- logger.debug "##{__method__.to_s} => Started"
161
139
  raise MissingArgumentsError.new 'Missing argument: path.' if path.blank?
162
140
 
163
141
  logger.debug "##{__method__.to_s} => PUT path:#{path} params:#{skip_sensitive_data(params)}"
164
- response = @connection.put do |req|
142
+ @connection.put do |req|
165
143
  req.url path
166
144
  req.body = params
167
145
  end
168
-
169
- logger.debug "##{__method__.to_s} => Completed"
170
- response
171
146
  end
172
147
 
173
148
  # Performs an HTTP DELETE request.
@@ -178,19 +153,17 @@ module FinApps
178
153
  # @param [Hash] params
179
154
  # @return [Hash,Array<String>]
180
155
  def delete(path, params = {})
181
- logger.debug "##{__method__.to_s} => Started"
182
156
  raise MissingArgumentsError.new 'Missing argument: path.' if path.blank?
183
157
 
184
158
  logger.debug "##{__method__.to_s} => DELETE path:#{path} params:#{skip_sensitive_data(params)}"
185
- response = @connection.delete do |req|
159
+ @connection.delete do |req|
186
160
  req.url path
187
161
  req.body = params
188
162
  end
189
-
190
- logger.debug "##{__method__.to_s} => Completed"
191
- response
192
163
  end
193
164
 
165
+ # Initialize resources.
166
+ #
194
167
  def set_up_resources
195
168
  @users ||= FinApps::REST::Users.new self
196
169
  @institutions ||= FinApps::REST::Institutions.new self
@@ -9,10 +9,8 @@ module FinApps
9
9
  # @param [Hash] config
10
10
  # @return [Faraday::Connection]
11
11
  def set_up_connection(company_credentials, config)
12
- logger.debug "##{__method__.to_s} => Started"
13
-
14
12
  company_credentials.validate_required_strings!
15
- logger.debug "##{__method__.to_s} => company_credentials passed validation."
13
+ logger.debug "##{__method__.to_s} => company_credentials were provided."
16
14
 
17
15
  host = config[:host]
18
16
  validate_host_url! host
@@ -23,48 +21,48 @@ module FinApps
23
21
  timeout = config[:timeout].blank? ? DEFAULTS[:timeout] : config[:timeout]
24
22
  logger.debug " timeout: #{timeout}"
25
23
 
26
- user_identifier = config[:user_identifier]
27
- logger.debug " user_identifier: #{user_identifier}" if user_identifier.present?
28
-
29
- user_token = config[:user_token]
30
- logger.debug ' user_token: [REDACTED]' if user_token.present?
31
-
32
- connection = Faraday.new(:url => base_url,
33
- :request => {
34
- :open_timeout => timeout,
35
- :timeout => timeout},
36
- :headers => {
37
- :accept => HEADERS[:accept],
38
- :user_agent => HEADERS[:user_agent]}) do |conn|
24
+ Faraday.new(:url => base_url,
25
+ :request => {
26
+ :open_timeout => timeout,
27
+ :timeout => timeout},
28
+ :headers => {
29
+ :accept => HEADERS[:accept],
30
+ :user_agent => HEADERS[:user_agent]}) do |conn|
39
31
 
40
- # Request Middleware
41
- conn.use FinApps::Middleware::ApiToken, company_credentials
42
- conn.request :json
43
- conn.request :retry
44
- conn.request :multipart
45
- conn.request :url_encoded
46
- if user_identifier.blank? || user_token.blank?
47
- logger.debug "##{__method__.to_s} => User credentials were not provided. Authentication header not set."
48
- else
49
- conn.request :basic_auth, user_identifier, user_token
50
- logger.debug "##{__method__.to_s} => Basic Authentication header set for provided user credentials."
51
- end
52
-
53
- # Response Middleware
54
- conn.use FinApps::Middleware::RaiseHttpExceptions
55
- conn.response :rashify
56
- conn.response :json, :content_type => /\bjson$/
57
- conn.use FinApps::Middleware::ResponseLogger
32
+ set_request_middleware(conn, company_credentials)
33
+ set_basic_authentication(conn, config)
34
+ set_response_middleware(conn)
58
35
 
59
36
  # Adapter (ensure that the adapter is always last.)
60
37
  conn.adapter :typhoeus
61
38
  end
62
-
63
- logger.debug "##{__method__.to_s} => Completed"
64
- connection
65
39
  end
66
40
 
67
41
  private
42
+ def set_response_middleware(conn)
43
+ conn.use FinApps::Middleware::RaiseHttpExceptions
44
+ conn.response :rashify
45
+ conn.response :json, :content_type => /\bjson$/
46
+ conn.use FinApps::Middleware::ResponseLogger
47
+ end
48
+
49
+ def set_request_middleware(conn, company_credentials)
50
+ conn.use FinApps::Middleware::ApiToken, company_credentials
51
+ conn.request :json
52
+ conn.request :retry
53
+ conn.request :multipart
54
+ conn.request :url_encoded
55
+ end
56
+
57
+ def set_basic_authentication(conn, config)
58
+ if config[:user_identifier].blank? || config[:user_token].blank?
59
+ logger.debug "##{__method__.to_s} => User credentials were not provided. Authentication header not set."
60
+ else
61
+ conn.request :basic_auth, config[:user_identifier], config[:user_token]
62
+ logger.debug "##{__method__.to_s} => Basic Authentication header set for provided user credentials."
63
+ end
64
+ end
65
+
68
66
  def validate_host_url!(host_url)
69
67
  raise MissingArgumentsError.new 'Missing argument: host_url.' if host_url.blank?
70
68
  raise InvalidArgumentsError.new 'Invalid argument: host_url does not specify a valid protocol (http/https).' unless host_url.start_with?('http://', 'https://')
@@ -9,8 +9,6 @@ module FinApps
9
9
  # @param [String] term
10
10
  # @return [Array<FinApps::REST::Institution>, Array<String>]
11
11
  def search(term)
12
- logger.debug "##{__method__.to_s} => Started"
13
-
14
12
  raise MissingArgumentsError.new 'Missing argument: term.' if term.blank?
15
13
  logger.debug "##{__method__.to_s} => term: #{term}"
16
14
 
@@ -21,15 +19,11 @@ module FinApps
21
19
  logger.debug "##{__method__.to_s} => path: #{path}"
22
20
 
23
21
  institutions, error_messages = @client.send(path, :get)
24
-
25
- logger.debug "##{__method__.to_s} => Completed"
26
22
  return institutions, error_messages
27
23
  end
28
24
 
29
25
  # @param [Integer] site_id
30
26
  def form(site_id)
31
- logger.debug "##{__method__.to_s} => Started"
32
-
33
27
  raise MissingArgumentsError.new 'Missing argument: site_id.' if site_id.blank?
34
28
  logger.debug "##{__method__.to_s} => site_id: #{site_id}"
35
29
 
@@ -40,8 +34,6 @@ module FinApps
40
34
  logger.debug "##{__method__.to_s} => path: #{path}"
41
35
 
42
36
  institution, error_messages = @client.send(path, :get) { |r| Institution.new(r.body) }
43
-
44
- logger.debug "##{__method__.to_s} => Completed"
45
37
  return institution, error_messages
46
38
  end
47
39
 
@@ -7,7 +7,7 @@ module FinApps
7
7
  class Rulesets < FinApps::REST::Resources
8
8
 
9
9
  def list
10
- logger.debug "##{__method__.to_s} => Started"
10
+
11
11
 
12
12
  end_point = Defaults::END_POINTS[:relevance_rulesets_list]
13
13
  logger.debug "##{__method__.to_s} => end_point: #{end_point}"
@@ -17,12 +17,12 @@ module FinApps
17
17
 
18
18
  results, error_messages = @client.send(path, :get)
19
19
 
20
- logger.debug "##{__method__.to_s} => Completed"
20
+
21
21
  return results, error_messages
22
22
  end
23
23
 
24
24
  def show(ruleset_name)
25
- logger.debug "##{__method__.to_s} => Started"
25
+
26
26
 
27
27
  raise MissingArgumentsError.new 'Missing argument: ruleset_name.' if ruleset_name.blank?
28
28
  logger.debug "##{__method__.to_s} => ruleset_name: #{ruleset_name}"
@@ -35,12 +35,12 @@ module FinApps
35
35
 
36
36
  results, error_messages = @client.send(path, :get)
37
37
 
38
- logger.debug "##{__method__.to_s} => Completed"
38
+
39
39
  return results, error_messages
40
40
  end
41
41
 
42
42
  def run(params = {})
43
- logger.debug "##{__method__.to_s} => Started"
43
+
44
44
 
45
45
  raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
46
46
  logger.debug "##{__method__.to_s} => params: #{params.inspect}"
@@ -53,7 +53,7 @@ module FinApps
53
53
 
54
54
  results, error_messages = @client.send(path, :post, params)
55
55
 
56
- logger.debug "##{__method__.to_s} => Completed"
56
+
57
57
  return results, error_messages
58
58
  end
59
59
 
@@ -7,45 +7,33 @@ module FinApps
7
7
  # @transaction_id [String]
8
8
  # # @return [Hash, Array<String>]
9
9
  def show(transaction_id)
10
- logger.debug "##{__method__.to_s} => Started"
11
-
12
10
  end_point = Defaults::END_POINTS[:transactions_show]
13
11
  logger.debug "##{__method__.to_s} => end_point: #{end_point}"
14
12
 
15
13
  path = end_point.sub ':transaction_id', ERB::Util.url_encode(transaction_id)
16
14
  logger.debug "##{__method__.to_s} => path: #{path}"
17
15
 
18
- transaction, error_messages = @client.send(path, :get)
19
-
20
- logger.debug "##{__method__.to_s} => Completed"
16
+ transaction, error_messages = @client.send(path, :get)
21
17
  return transaction, error_messages
22
18
  end
23
19
 
24
20
  # @param [Hash] params
25
21
  # @return [Array<Hash>, Array<String>]
26
22
  def search(params={})
27
- logger.debug "##{__method__.to_s} => Started"
28
-
29
23
  path = Defaults::END_POINTS[:transactions_list]
30
24
  logger.debug "##{__method__.to_s} => path: #{path}"
31
25
 
32
26
  transactions, error_messages = @client.send(path, :post, params.compact)
33
-
34
- logger.debug "##{__method__.to_s} => Completed"
35
27
  return transactions, error_messages
36
28
  end
37
29
 
38
30
  # @param [Hash] params
39
31
  # @return [Array<Hash>, Array<String>]
40
32
  def update(params={})
41
- logger.debug "##{__method__.to_s} => Started"
42
-
43
33
  path = Defaults::END_POINTS[:transactions_update]
44
34
  logger.debug "##{__method__.to_s} => path: #{path}"
45
35
 
46
36
  _, error_messages = @client.send(path, :put, params.compact)
47
-
48
- logger.debug "##{__method__.to_s} => Completed"
49
37
  error_messages
50
38
  end
51
39
 
@@ -7,19 +7,15 @@ module FinApps
7
7
  include FinApps::REST::Defaults
8
8
 
9
9
  def list
10
- logger.debug "##{__method__.to_s} => Started"
11
-
12
10
  path = Defaults::END_POINTS[:user_institutions_list]
13
11
  logger.debug "##{__method__.to_s} => path: #{path}"
14
12
 
15
13
  user_institutions, error_messages = @client.send(path, :get)
16
14
 
17
- logger.debug "##{__method__.to_s} => Completed"
18
15
  return user_institutions, error_messages
19
16
  end
20
17
 
21
18
  def add(site_id, parameters)
22
- logger.debug "##{__method__.to_s} => Started"
23
19
 
24
20
  raise MissingArgumentsError.new 'Missing argument: site_id.' if site_id.blank?
25
21
  logger.debug "##{__method__.to_s} => site_id: #{site_id}"
@@ -35,12 +31,10 @@ module FinApps
35
31
 
36
32
  user_institution, error_messages = @client.send(path, :post, :parameters => parameters)
37
33
 
38
- logger.debug "##{__method__.to_s} => Completed"
39
34
  return user_institution, error_messages
40
35
  end
41
36
 
42
37
  def show(user_institution_id)
43
- logger.debug "##{__method__.to_s} => Started"
44
38
 
45
39
  raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
46
40
  logger.debug "##{__method__.to_s} => user_institution_id: #{user_institution_id}"
@@ -53,13 +47,10 @@ module FinApps
53
47
 
54
48
  user_institution, error_messages = @client.send(path, :get)
55
49
 
56
- logger.debug "##{__method__.to_s} => Completed"
57
50
  return user_institution, error_messages
58
51
  end
59
52
 
60
53
  def form(user_institution_id)
61
- logger.debug "##{__method__.to_s} => Started"
62
-
63
54
  raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
64
55
  logger.debug "##{__method__.to_s} => user_institution_id: #{user_institution_id}"
65
56
 
@@ -71,13 +62,10 @@ module FinApps
71
62
 
72
63
  user_institution, error_messages = @client.send(path, :get)
73
64
 
74
- logger.debug "##{__method__.to_s} => Completed"
75
65
  return user_institution, error_messages
76
66
  end
77
67
 
78
68
  def status(user_institution_id)
79
- logger.debug "##{__method__.to_s} => Started"
80
-
81
69
  raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
82
70
  logger.debug "##{__method__.to_s} => user_institution_id: #{user_institution_id}"
83
71
 
@@ -89,13 +77,10 @@ module FinApps
89
77
 
90
78
  user_institution, error_messages = @client.send(path, :get)
91
79
 
92
- logger.debug "##{__method__.to_s} => Completed"
93
80
  return user_institution, error_messages
94
81
  end
95
82
 
96
83
  def mfa(user_institution_id, parameters)
97
- logger.debug "##{__method__.to_s} => Started"
98
-
99
84
  raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
100
85
  logger.debug "##{__method__.to_s} => user_institution_id: #{user_institution_id}"
101
86
 
@@ -110,13 +95,10 @@ module FinApps
110
95
 
111
96
  user_institution, error_messages = @client.send(path, :put, :parameters => parameters)
112
97
 
113
- logger.debug "##{__method__.to_s} => Completed"
114
98
  return user_institution, error_messages
115
99
  end
116
100
 
117
101
  def update(user_institution_id, parameters)
118
- logger.debug "##{__method__.to_s} => Started"
119
-
120
102
  raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
121
103
  logger.debug "##{__method__.to_s} => user_institution_id: #{user_institution_id}"
122
104
 
@@ -131,26 +113,20 @@ module FinApps
131
113
 
132
114
  user_institution, error_messages = @client.send(path, :put, :parameters => parameters)
133
115
 
134
- logger.debug "##{__method__.to_s} => Completed"
135
116
  return user_institution, error_messages
136
117
  end
137
118
 
138
119
  def refresh
139
- logger.debug "##{__method__.to_s} => Started"
140
-
141
120
  path = Defaults::END_POINTS[:user_institutions_refresh]
142
121
  logger.debug "##{__method__.to_s} => path: #{path}"
143
122
 
144
123
  user_institutions, error_messages = @client.send(path, :get)
145
124
 
146
- logger.debug "##{__method__.to_s} => Completed"
147
125
  return user_institutions, error_messages
148
126
  end
149
127
 
150
128
  # @return [Hash, Array<String>]
151
129
  def delete(user_institution_id)
152
- logger.debug "##{__method__.to_s} => Started"
153
-
154
130
  raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
155
131
  logger.debug "##{__method__.to_s} => user_institution_id: #{user_institution_id.inspect}"
156
132
 
@@ -162,7 +138,6 @@ module FinApps
162
138
 
163
139
  _, error_messages = @client.send(path, :delete)
164
140
 
165
- logger.debug "##{__method__.to_s} => Completed"
166
141
  error_messages
167
142
  end
168
143
 
@@ -10,8 +10,6 @@ module FinApps
10
10
  # @param [Hash] params
11
11
  # @return [FinApps::REST::User, Array<String>]
12
12
  def create(params = {})
13
- logger.debug "##{__method__.to_s} => Started"
14
-
15
13
  raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
16
14
  logger.debug "##{__method__.to_s} => params: #{skip_sensitive_data params}"
17
15
 
@@ -19,14 +17,12 @@ module FinApps
19
17
  logger.debug "##{__method__.to_s} => end_point: #{end_point}"
20
18
 
21
19
  user, error_messages = @client.send(end_point, :post, params) { |r| User.new(r.body) }
22
- logger.debug "##{__method__.to_s} => Completed"
23
20
 
24
21
  return user, error_messages
25
22
  end
26
23
 
27
24
  def update(params = {})
28
- logger.debug "##{__method__.to_s} => Started"
29
-
25
+ raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
30
26
  logger.debug "##{__method__.to_s} => params: #{skip_sensitive_data params}"
31
27
 
32
28
  path = Defaults::END_POINTS[:users_update]
@@ -34,20 +30,17 @@ module FinApps
34
30
 
35
31
  _, error_messages = @client.send(path, :put, params.compact)
36
32
 
37
- logger.debug "##{__method__.to_s} => Completed"
38
33
  error_messages
39
34
  end
40
35
 
41
36
  def update_password(params = {})
42
- logger.debug "##{__method__.to_s} => Started"
43
-
37
+ raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
44
38
  logger.debug "##{__method__.to_s} => params: #{skip_sensitive_data params}"
45
39
 
46
40
  path = Defaults::END_POINTS[:users_update_password]
47
41
  logger.debug "##{__method__.to_s} => path: #{path}"
48
42
 
49
43
  user, error_messages = @client.send(path, :put, params.compact) { |r| User.new(r.body) }
50
- logger.debug "##{__method__.to_s} => Completed"
51
44
 
52
45
  return user, error_messages
53
46
  end
@@ -55,8 +48,6 @@ module FinApps
55
48
  # @param [Hash] params
56
49
  # @return [FinApps::REST::User, Array<String>]
57
50
  def login(params = {})
58
- logger.debug "##{__method__.to_s} => Started"
59
-
60
51
  raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
61
52
  logger.debug "##{__method__.to_s} => params: #{skip_sensitive_data params}"
62
53
 
@@ -64,7 +55,6 @@ module FinApps
64
55
  logger.debug "##{__method__.to_s} => end_point: #{end_point}"
65
56
 
66
57
  user, error_messages = @client.send(end_point, :post, params) { |r| User.new(r.body) }
67
- logger.debug "##{__method__.to_s} => Completed"
68
58
 
69
59
  return user, error_messages
70
60
  end
@@ -72,8 +62,6 @@ module FinApps
72
62
  # @param [String] public_id
73
63
  # @return [Array<String>]
74
64
  def delete(public_id)
75
- logger.debug "##{__method__.to_s} => Started"
76
-
77
65
  raise MissingArgumentsError.new 'Missing argument: public_id.' if public_id.blank?
78
66
  logger.debug "##{__method__.to_s} => public_id: #{public_id}"
79
67
 
@@ -84,7 +72,6 @@ module FinApps
84
72
  logger.debug "##{__method__.to_s} => path: #{path}"
85
73
 
86
74
  _, error_messages = @client.send(path, :delete)
87
- logger.debug "##{__method__.to_s} => Completed"
88
75
 
89
76
  error_messages
90
77
  end
@@ -34,9 +34,9 @@ module FinApps
34
34
  end
35
35
 
36
36
  def set_up_logger_level(logger_level)
37
- unless logger_level.blank? || @logger.level == logger_level
38
- @logger.info "##{__method__.to_s} => Setting logger level to #{SEVERITY_LABEL[logger_level]}"
39
- @logger.level = logger_level
37
+ unless logger_level.blank? || logger.level == logger_level
38
+ logger.info "##{__method__.to_s} => Setting logger level to #{SEVERITY_LABEL[logger_level]}"
39
+ logger.level = logger_level
40
40
  end
41
41
  end
42
42
 
@@ -1,3 +1,3 @@
1
1
  module FinApps
2
- VERSION = '0.22.2.pre'
2
+ VERSION = '0.22.3.pre'
3
3
  end
@@ -17,8 +17,6 @@ module FinApps
17
17
  expect(@client).to respond_to(:user_credentials!)
18
18
  end
19
19
 
20
-
21
-
22
20
  it 'responds to public api methods' do
23
21
  [:alert, :alert_definition, :alert_settings, :alert_preferences,
24
22
  :budgets, :budget_calculation, :budget_models, :cashflows,
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: 0.22.2.pre
4
+ version: 0.22.3.pre
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-02-11 00:00:00.000000000 Z
11
+ date: 2016-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -257,6 +257,6 @@ signing_key:
257
257
  specification_version: 4
258
258
  summary: FinApps REST API ruby client.
259
259
  test_files:
260
- - spec/rest/client_spec.rb
261
260
  - spec/spec_helper.rb
262
261
  - spec/utils/logging_spec.rb
262
+ - spec/rest/client_spec.rb