finapps 0.22.4.pre → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51fd6a45e06021b7c1ed0826f14602c13e1e9793
4
- data.tar.gz: e8b2044c41c8a427fd951f7ae3a8de26992381a1
3
+ metadata.gz: eb461d21865e07fa51273dcdba8337ec180e92a2
4
+ data.tar.gz: 33b0266527b3cae73c4c114b1effe741a9f4f20e
5
5
  SHA512:
6
- metadata.gz: 24a8763926c94e431b22490d7f53234946decb0cf74c99e2dd7e7f5fe637e3a8924dfe213b4b73c27f0820086921cbdf235d13b9ce76225adf2861153faf65e9
7
- data.tar.gz: ef4e0edd93c1c3ac2f7ed0ae61977d489ad4686a835b1abb000c4ee44c96d611fdb62c30e14ef9a6fe04bd94eb7706bdbc1283ba4c89b3a0afab74c81090cceb
6
+ metadata.gz: fe94326204732916fbcf07c404ad85a311b1ad5a496a9eb6adae4286ce4766ea35c0b447ecc1c235d764ed297d93d7271ae1fb5a22cbec31aa8e3fd0fc2678d7
7
+ data.tar.gz: ff6af765e1e116ab4698c07706774c5d3bd9276aa1b755643be39dc0534487bf0114e0fa9cc6c5457b5e53aafb6369b197f7fb232bd3428014d02b1e734f0a4a
data/.gitignore CHANGED
@@ -1,4 +1,7 @@
1
+ /spec/examples.txt
1
2
  *.gem
3
+ *.rbc
4
+ .bundle
2
5
  .config
3
6
  .yardoc
4
7
  Gemfile.lock
@@ -9,34 +12,13 @@ doc/
9
12
  lib/bundler/man
10
13
  pkg
11
14
  rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
12
19
  *.bundle
13
20
  *.so
14
21
  *.o
15
22
  *.a
16
23
  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
24
  .idea/
36
- /spec/tmp/*
37
- /cache
38
-
39
- *.BACKUP.*
40
- *.BASE.*
41
- *.LOCAL.*
42
- *.REMOTE.*
data/.rspec ADDED
@@ -0,0 +1,5 @@
1
+ --drb
2
+ --format Fuubar
3
+ --color
4
+ --warnings
5
+ --require spec_helper
@@ -20,16 +20,16 @@ Gem::Specification.new do |spec|
20
20
  spec.test_files = Dir['spec/**/*.rb']
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.add_runtime_dependency 'thor', '~> 0.19', '>= 0.19.1'
24
- spec.add_runtime_dependency 'faraday', '~> 0.9', '>= 0.9.0'
25
- spec.add_runtime_dependency 'faraday_middleware', '~> 0.9', '>= 0.9.1'
26
- spec.add_runtime_dependency 'typhoeus', '~> 0.6', '>= 0.6.8'
23
+ spec.add_runtime_dependency 'faraday', '~> 0.9', '>= 0.9.2'
24
+ spec.add_runtime_dependency 'faraday_middleware', '~> 0.10', '>= 0.10.0'
25
+ spec.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
27
26
  spec.add_runtime_dependency 'rash', '~> 0.4', '>= 0.4.0'
28
27
 
29
- spec.add_development_dependency 'bundler', '~> 1.6', '>= 1.6.2'
30
- spec.add_development_dependency 'rake', '~> 0.9', '>= 0.9.6'
31
- spec.add_development_dependency 'rspec', '~> 3.0', '>= 3.0.0'
32
- # spec.add_development_dependency 'webmock', '~> 1.18', '>= 1.18.0'
28
+ spec.add_development_dependency 'bundler', '~> 1.11', '>= 1.11.2'
29
+ spec.add_development_dependency 'rake', '~> 11.1', '>= 11.1.2'
30
+ spec.add_development_dependency 'fuubar', '~> 2.0', '>= 2.0.0'
31
+ spec.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0'
32
+ spec.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.2'
33
33
 
34
34
  spec.extra_rdoc_files = %w(README.md LICENSE.txt)
35
35
  spec.rdoc_options = %w(--line-numbers --inline-source --title finapps-ruby --main README.md)
@@ -10,17 +10,17 @@ module FinApps
10
10
  end
11
11
 
12
12
  def call(env)
13
- raise MissingArgumentsError.new 'Missing argument: company_identifier.' if @options[:company_identifier].blank?
14
- raise MissingArgumentsError.new 'Missing argument: company_token.' if @options[:company_token].blank?
13
+ company_identifier = @options[:company_identifier].trim
14
+ raise FinApps::REST::MissingArgumentsError.new 'Missing argument: company_identifier.' if company_identifier.blank?
15
15
 
16
- header_value = "#{@options[:company_identifier].trim}=#{@options[:company_token].trim}"
17
- logger.debug "##{__method__.to_s} => Request Header X-FinApps-Token: #{header_value}"
18
- env[:request_headers]['X-FinApps-Token'] = header_value
16
+ company_token = @options[:company_token].trim
17
+ raise FinApps::REST::MissingArgumentsError.new 'Missing argument: company_token.' if company_token.blank?
19
18
 
19
+ env[:request_headers]['X-FinApps-Token'] = "#{company_identifier}=#{company_token}"
20
20
  @app.call(env)
21
21
  end
22
22
 
23
23
  end
24
24
 
25
25
  end
26
- end
26
+ end
@@ -8,6 +8,7 @@ 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"
11
12
 
12
13
  end_point = Defaults::END_POINTS[:alert_list]
13
14
  logger.debug "##{__method__.to_s} => end_point: #{end_point}"
@@ -19,16 +20,18 @@ module FinApps
19
20
  path = path.sub ':read', ERB::Util.url_encode(read)
20
21
  logger.debug "##{__method__.to_s} => path: #{path}"
21
22
 
22
- result, error_messages = @client.send(path, :get)
23
+ result, error_messages = @client.send_request(path, :get)
23
24
 
25
+ logger.debug "##{__method__.to_s} => Completed"
24
26
  return result, error_messages
25
27
  end
26
28
 
27
29
  # @return [Hash, Array<String>]
28
30
  def update(alert_id, read=true)
31
+ logger.debug "##{__method__.to_s} => Started"
32
+
29
33
  raise MissingArgumentsError.new 'Missing argument: alert_id.' if alert_id.blank?
30
34
  logger.debug "##{__method__.to_s} => alert_id: #{alert_id.inspect}"
31
-
32
35
  raise MissingArgumentsError.new 'Missing argument: read.' if read.blank?
33
36
  logger.debug "##{__method__.to_s} => read: #{read.inspect}"
34
37
 
@@ -39,13 +42,16 @@ module FinApps
39
42
  path = path.sub ':read', ERB::Util.url_encode(read)
40
43
  logger.debug "##{__method__.to_s} => path: #{path}"
41
44
 
42
- _, error_messages = @client.send(path, :put)
45
+ _, error_messages = @client.send_request(path, :put)
43
46
 
47
+ logger.debug "##{__method__.to_s} => Completed"
44
48
  error_messages
45
49
  end
46
50
 
47
51
  # @return [Hash, Array<String>]
48
52
  def delete(alert_id)
53
+ logger.debug "##{__method__.to_s} => Started"
54
+
49
55
  raise MissingArgumentsError.new 'Missing argument: alert_id.' if alert_id.blank?
50
56
  logger.debug "##{__method__.to_s} => alert_id: #{alert_id.inspect}"
51
57
 
@@ -55,11 +61,12 @@ module FinApps
55
61
  path = end_point.sub ':alert_id', ERB::Util.url_encode(alert_id)
56
62
  logger.debug "##{__method__.to_s} => path: #{path}"
57
63
 
58
- _, error_messages = @client.send(path, :delete)
64
+ _, error_messages = @client.send_request(path, :delete)
59
65
 
66
+ logger.debug "##{__method__.to_s} => Completed"
60
67
  error_messages
61
68
  end
62
69
 
63
70
  end
64
71
  end
65
- end
72
+ end
@@ -8,18 +8,24 @@ module FinApps
8
8
 
9
9
  # @return [Hash, Array<String>]
10
10
  def list
11
+ logger.debug "##{__method__.to_s} => Started"
12
+
11
13
  end_point = Defaults::END_POINTS[:alert_definition_list]
12
14
  logger.debug "##{__method__.to_s} => end_point: #{end_point}"
13
15
 
14
16
  path = end_point
15
17
  logger.debug "##{__method__.to_s} => path: #{path}"
16
18
 
17
- result, error_messages = @client.send(path, :get)
19
+ result, error_messages = @client.send_request(path, :get)
20
+
21
+ logger.debug "##{__method__.to_s} => Completed"
18
22
  return result, error_messages
19
23
  end
20
24
 
21
25
  # @return [Hash, Array<String>]
22
26
  def show(alert_name)
27
+ logger.debug "##{__method__.to_s} => Started"
28
+
23
29
  raise MissingArgumentsError.new 'Missing argument: alert_name.' if alert_name.blank?
24
30
  logger.debug "##{__method__.to_s} => alert_name: #{alert_name}"
25
31
 
@@ -29,10 +35,12 @@ module FinApps
29
35
  path = end_point.sub ':alert_name', ERB::Util.url_encode(alert_name)
30
36
  logger.debug "##{__method__.to_s} => path: #{path}"
31
37
 
32
- result, error_messages = @client.send(path, :get)
38
+ result, error_messages = @client.send_request(path, :get)
39
+
40
+ logger.debug "##{__method__.to_s} => Completed"
33
41
  return result, error_messages
34
42
  end
35
43
 
36
44
  end
37
45
  end
38
- end
46
+ end
@@ -8,18 +8,24 @@ module FinApps
8
8
 
9
9
  # @return [Hash, Array<String>]
10
10
  def show
11
+ logger.debug "##{__method__.to_s} => Started"
12
+
11
13
  end_point = Defaults::END_POINTS[:alert_preferences_show]
12
14
  logger.debug "##{__method__.to_s} => end_point: #{end_point}"
13
15
 
14
16
  path = end_point
15
17
  logger.debug "##{__method__.to_s} => path: #{path}"
16
18
 
17
- result, error_messages = @client.send(path, :get)
19
+ result, error_messages = @client.send_request(path, :get)
20
+
21
+ logger.debug "##{__method__.to_s} => Completed"
18
22
  return result, error_messages
19
23
  end
20
24
 
21
25
  # @return [Hash, Array<String>]
22
26
  def update(params)
27
+ logger.debug "##{__method__.to_s} => Started"
28
+
23
29
  raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
24
30
  logger.debug "##{__method__.to_s} => params: #{params.inspect}"
25
31
 
@@ -29,7 +35,9 @@ module FinApps
29
35
  path = end_point
30
36
  logger.debug "##{__method__.to_s} => path: #{path}"
31
37
 
32
- _, error_messages = @client.send(path, :put, params.compact)
38
+ _, error_messages = @client.send_request(path, :put, params.compact)
39
+
40
+ logger.debug "##{__method__.to_s} => Completed"
33
41
  error_messages
34
42
  end
35
43
 
@@ -8,18 +8,24 @@ module FinApps
8
8
 
9
9
  # @return [Hash, Array<String>]
10
10
  def show
11
+ logger.debug "##{__method__.to_s} => Started"
12
+
11
13
  end_point = Defaults::END_POINTS[:alert_settings_show]
12
14
  logger.debug "##{__method__.to_s} => end_point: #{end_point}"
13
15
 
14
16
  path = end_point
15
17
  logger.debug "##{__method__.to_s} => path: #{path}"
16
18
 
17
- result, error_messages = @client.send(path, :get)
19
+ result, error_messages = @client.send_request(path, :get)
20
+
21
+ logger.debug "##{__method__.to_s} => Completed"
18
22
  return result, error_messages
19
23
  end
20
24
 
21
25
  # @return [Hash, Array<String>]
22
26
  def update(params)
27
+ logger.debug "##{__method__.to_s} => Started"
28
+
23
29
  raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
24
30
  logger.debug "##{__method__.to_s} => params: #{params.inspect}"
25
31
 
@@ -29,10 +35,12 @@ module FinApps
29
35
  path = end_point
30
36
  logger.debug "##{__method__.to_s} => path: #{path}"
31
37
 
32
- _, error_messages = @client.send(path, :put, params.compact)
38
+ _, error_messages = @client.send_request(path, :put, params.compact)
39
+
40
+ logger.debug "##{__method__.to_s} => Completed"
33
41
  error_messages
34
42
  end
35
43
 
36
44
  end
37
45
  end
38
- end
46
+ end
@@ -10,9 +10,10 @@ 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
+
13
15
  raise MissingArgumentsError.new 'Missing argument: budget_model_id.' if budget_model_id.blank?
14
16
  logger.debug "##{__method__.to_s} => budget_model: #{budget_model_id}"
15
-
16
17
  raise MissingArgumentsError.new 'Missing argument: income.' if income.blank?
17
18
  logger.debug "##{__method__.to_s} => income: #{income}"
18
19
 
@@ -22,22 +23,28 @@ module FinApps
22
23
  path = end_point.sub(':budget_model_id', ERB::Util.url_encode(budget_model_id)).sub(':income', ERB::Util.url_encode(income))
23
24
  logger.debug "##{__method__.to_s} => path: #{path}"
24
25
 
25
- budget_calculation, error_messages = @client.send(path, :get)
26
+ budget_calculation, error_messages = @client.send_request(path, :get)
27
+ logger.debug "##{__method__.to_s} => Completed"
28
+
26
29
  return budget_calculation, error_messages
27
30
  end
28
31
 
29
32
  # @return [Array<Hash>, Array<String>]
30
33
  def show
34
+ logger.debug "##{__method__.to_s} => Started"
35
+
31
36
  end_point = Defaults::END_POINTS[:budget_calculation_show]
32
37
  logger.debug "##{__method__.to_s} => end_point: #{end_point}"
33
38
 
34
39
  path = end_point
35
40
  logger.debug "##{__method__.to_s} => path: #{path}"
36
41
 
37
- budget_calculation, error_messages = @client.send(path, :get)
42
+ budget_calculation, error_messages = @client.send_request(path, :get)
43
+ logger.debug "##{__method__.to_s} => Completed"
44
+
38
45
  return budget_calculation, error_messages
39
46
  end
40
47
 
41
48
  end
42
49
  end
43
- end
50
+ end
@@ -8,15 +8,21 @@ module FinApps
8
8
 
9
9
  # @return [Array<Hash>, Array<String>]
10
10
  def list
11
+ logger.debug "##{__method__.to_s} => Started"
12
+
11
13
  path = Defaults::END_POINTS[:budget_models_list]
12
14
  logger.debug "##{__method__.to_s} => path: #{path}"
13
15
 
14
- budget_models, error_messages = @client.send(path, :get)
16
+ budget_models, error_messages = @client.send_request(path, :get)
17
+
18
+ logger.debug "##{__method__.to_s} => Completed"
15
19
  return budget_models, error_messages
16
20
  end
17
21
 
18
22
  # @param [Integer] budget_model_id
19
23
  def show(budget_model_id)
24
+ logger.debug "##{__method__.to_s} => Started"
25
+
20
26
  raise MissingArgumentsError.new 'Missing argument: budget_model_id.' if budget_model_id.blank?
21
27
  logger.debug "##{__method__.to_s} => budget_model_id: #{budget_model_id}"
22
28
 
@@ -26,7 +32,9 @@ module FinApps
26
32
  path = end_point.sub ':budget_model_id', ERB::Util.url_encode(budget_model_id)
27
33
  logger.debug "##{__method__.to_s} => path: #{path}"
28
34
 
29
- budget_model, error_messages = @client.send(path, :get) { |r| BudgetModel.new(r.body) }
35
+ budget_model, error_messages = @client.send_request(path, :get) { |r| BudgetModel.new(r.body) }
36
+
37
+ logger.debug "##{__method__.to_s} => Completed"
30
38
  return budget_model, error_messages
31
39
  end
32
40
 
@@ -37,4 +45,4 @@ module FinApps
37
45
  end
38
46
 
39
47
  end
40
- end
48
+ end
@@ -10,9 +10,10 @@ 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
+
13
15
  raise MissingArgumentsError.new 'Missing argument: start_date.' if start_date.blank?
14
16
  logger.debug "##{__method__.to_s} => start_date: #{start_date}"
15
-
16
17
  raise MissingArgumentsError.new 'Missing argument: end_date.' if end_date.blank?
17
18
  logger.debug "##{__method__.to_s} => end_date: #{end_date}"
18
19
 
@@ -24,7 +25,7 @@ module FinApps
24
25
  path = end_point.sub(':start_date', ERB::Util.url_encode(start_date)).sub(':end_date', ERB::Util.url_encode(end_date))
25
26
  logger.debug "##{__method__.to_s} => path: #{path}"
26
27
 
27
- result, error_messages = @client.send(path, :get)
28
+ result, error_messages = @client.send_request(path, :get)
28
29
  if result.present? && error_messages.blank?
29
30
  categories = result_categories(result)
30
31
  raise 'Category results-set for budget is not an array.' unless categories.respond_to?(:each)
@@ -33,18 +34,23 @@ module FinApps
33
34
  categories.each { |category| budget.details << result_category_to_budget_detail(category, transactions) }
34
35
  end
35
36
 
37
+ logger.debug "##{__method__.to_s} => Completed"
36
38
  return budget, error_messages
37
39
  end
38
40
 
39
41
  # @param [Hash] params
40
42
  # @return [Array<Hash>, Array<String>]
41
43
  def update(params={})
44
+ logger.debug "##{__method__.to_s} => Started"
45
+
42
46
  raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
43
47
 
44
48
  end_point = Defaults::END_POINTS[:budget_update]
45
49
  logger.debug "##{__method__.to_s} => end_point: #{end_point}"
46
50
 
47
- budget, error_messages = @client.send(end_point, :put, params)
51
+ budget, error_messages = @client.send_request(end_point, :put, params)
52
+ logger.debug "##{__method__.to_s} => Completed"
53
+
48
54
  return budget, error_messages
49
55
  end
50
56
 
@@ -99,4 +105,4 @@ module FinApps
99
105
  end
100
106
 
101
107
  end
102
- end
108
+ end
@@ -10,9 +10,10 @@ 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
+
13
15
  raise MissingArgumentsError.new 'Missing argument: start_date.' if start_date.blank?
14
16
  logger.debug "##{__method__.to_s} => start_date: #{start_date}"
15
-
16
17
  raise MissingArgumentsError.new 'Missing argument: end_date.' if end_date.blank?
17
18
  logger.debug "##{__method__.to_s} => end_date: #{end_date}"
18
19
 
@@ -29,7 +30,7 @@ module FinApps
29
30
  path = end_point.sub(':start_date', ERB::Util.url_encode(start_date)).sub(':end_date', ERB::Util.url_encode(end_date))
30
31
  logger.debug "##{__method__.to_s} => path: #{path}"
31
32
 
32
- result, error_messages = @client.send(path, :get)
33
+ result, error_messages = @client.send_request(path, :get)
33
34
  if result.present? && error_messages.blank?
34
35
 
35
36
  summary = extract_value(result, 'summary')
@@ -51,6 +52,7 @@ module FinApps
51
52
  categories.each { |category| cashflow.details << result_category_to_cashflow_detail(category) }
52
53
  end
53
54
 
55
+ logger.debug "##{__method__.to_s} => Completed"
54
56
  return cashflow, error_messages
55
57
  end
56
58
 
@@ -85,4 +87,4 @@ module FinApps
85
87
  end
86
88
 
87
89
  end
88
- end
90
+ end