finapps 0.15.1.pre → 0.15.2.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/finapps +1 -0
- data/lib/finapps/cli/budgets.rb +37 -0
- data/lib/finapps/cli/common.rb +6 -3
- data/lib/finapps/cli/institutions.rb +1 -1
- data/lib/finapps/rest/budgets.rb +22 -11
- data/lib/finapps/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 221dace01dc937a32d9e2c5f7f6f6055e4256f07
|
4
|
+
data.tar.gz: ec44bba21c568e39ba7f2ad3032de9a4fc47d67e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38716ba06d21b39137079daa0e4488dae4f7afe95f7d01cc28e3b5028bb0bbbd0a4e670d7363da3befee325bf6c266923820a36ab5b5fd111cb3b8b05b0954e5
|
7
|
+
data.tar.gz: d5a77305abbdb03169a083b42d765354976ac83e7a907f433cec9e8b0939188fe3f3db974afa498763b97d0d15eb8d1cb2085b30d24edf43cffa28405df70d59
|
data/bin/finapps
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'finapps'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
module FinApps
|
6
|
+
class CLI < Thor
|
7
|
+
|
8
|
+
desc 'budgets', 'show'
|
9
|
+
|
10
|
+
def budgets_show
|
11
|
+
|
12
|
+
begin
|
13
|
+
|
14
|
+
user_identifier = '53d17daf-909d-45d2-6fb6-d43b74d364cb'
|
15
|
+
user_token = '4JZmhcHVf3ODRJ9TMKF7N/1sHDY3M5Q49A9ToAy+TDE='
|
16
|
+
|
17
|
+
client.user_credentials!(user_identifier, user_token)
|
18
|
+
budget, error_messages = client.budgets.show('2015-01-01T00:00:00Z', '2015-01-31T00:00:00Z')
|
19
|
+
if budget.present?
|
20
|
+
puts
|
21
|
+
puts 'budget results:'
|
22
|
+
pp budget
|
23
|
+
else
|
24
|
+
puts
|
25
|
+
puts 'unable to get budgets'
|
26
|
+
error_messages.each { |m| puts m } if error_messages.present?
|
27
|
+
end
|
28
|
+
puts
|
29
|
+
|
30
|
+
rescue StandardError => error
|
31
|
+
rescue_standard_error(error)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
data/lib/finapps/cli/common.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'finapps'
|
3
3
|
|
4
|
+
# export FINAPPS_COMPANY_IDENTIFIER=2e9cfb18-8ac4-4d9d-5695-aa16154f71f6
|
5
|
+
# export FINAPPS_COMPANY_TOKEN=uExvlQ0XQBt1PR+Nlfj96pgOMmd9bgKnnWx/kiygmrc=
|
6
|
+
# export FINAPPS_BASE_URL=https://finapps-qa.herokuapp.com
|
4
7
|
|
5
8
|
module FinApps
|
6
9
|
class CLI < Thor
|
@@ -14,13 +17,13 @@ module FinApps
|
|
14
17
|
private
|
15
18
|
|
16
19
|
def client
|
17
|
-
company_id = ENV['
|
20
|
+
company_id = ENV['FINAPPS_COMPANY_IDENTIFIER']
|
18
21
|
raise 'Invalid company identifier. Please setup the FA_ID environment variable.' if company_id.blank?
|
19
22
|
|
20
|
-
company_token = ENV['
|
23
|
+
company_token = ENV['FINAPPS_COMPANY_TOKEN']
|
21
24
|
raise 'Invalid company token. Please setup the FA_TOKEN environment variable.' if company_token.blank?
|
22
25
|
|
23
|
-
host = ENV['
|
26
|
+
host = ENV['FINAPPS_BASE_URL']
|
24
27
|
raise 'Invalid API host url. Please setup the FA_URL environment variable.' if host.blank?
|
25
28
|
|
26
29
|
@client ||= FinApps::REST::Client.new company_id, company_token, {:host => host, :log_level => Logger::DEBUG,
|
@@ -8,7 +8,7 @@ module FinApps
|
|
8
8
|
|
9
9
|
desc 'institutions_search', 'search institutions'
|
10
10
|
|
11
|
-
def institutions_search(user_identifier, user_token, term=nil)
|
11
|
+
def institutions_search(user_identifier, user_token = '4JZmhcHVf3ODRJ9TMKF7N/1sHDY3M5Q49A9ToAy+TDE=', term=nil)
|
12
12
|
|
13
13
|
begin
|
14
14
|
client.user_credentials!(user_identifier, user_token)
|
data/lib/finapps/rest/budgets.rb
CHANGED
@@ -28,24 +28,37 @@ module FinApps
|
|
28
28
|
result, error_messages = @client.send(path, :get)
|
29
29
|
if result.present? && error_messages.blank?
|
30
30
|
transactions = result.find { |r| r.has_key?('trans') }
|
31
|
+
transactions = transactions['trans'] if transactions.present?
|
32
|
+
logger.debug transactions.pretty_inspect
|
33
|
+
|
31
34
|
categories = result.find { |r| r.has_key?('cats') }
|
35
|
+
logger.debug categories.pretty_inspect
|
32
36
|
|
33
37
|
raise 'Category results set for budget is not an array.' unless categories.respond_to?(:each)
|
34
38
|
categories['cats'].each do |c|
|
35
|
-
|
36
|
-
raise 'Unable to locate category id for current category record.' unless c.key?
|
39
|
+
logger.debug "---------------------------------------------"
|
40
|
+
raise 'Unable to locate category id for current category record.' unless c.key?('cat_id')
|
37
41
|
category_id = c['cat_id']
|
42
|
+
logger.debug "category_id: #{category_id}"
|
38
43
|
|
39
|
-
raise 'Unable to locate
|
40
|
-
raise 'Unable to locate number of days for current category record.' unless c.key?['days']
|
41
|
-
budget_amount = c['budget_amount'].to_f * c['days'].to_i
|
42
|
-
|
43
|
-
raise 'Unable to locate category name for current category record.' unless c.key?['name']
|
44
|
+
raise 'Unable to locate category name for current category record.' unless c.key?('name')
|
44
45
|
category_name = c['name']
|
46
|
+
logger.debug "category_name: #{category_name}"
|
47
|
+
|
48
|
+
raise 'Unable to locate budget_amount for current category record.' unless c.key?('budget_amount')
|
49
|
+
budget_amount = c['budget_amount']
|
50
|
+
logger.debug "daily_budget_amount: #{budget_amount}"
|
51
|
+
|
52
|
+
raise 'Unable to locate number of days for current category record.' unless c.key?('days')
|
53
|
+
days = c['days']
|
54
|
+
logger.debug "days: #{days}"
|
55
|
+
|
56
|
+
date_range_budget_amount = budget_amount.to_f * days.to_i
|
57
|
+
logger.debug "budget_amount for #{days} days: #{date_range_budget_amount}"
|
45
58
|
|
46
59
|
budget.details << BudgetDetail.new({:category_id => category_id,
|
47
60
|
:category_name => category_name,
|
48
|
-
:budget_amount =>
|
61
|
+
:budget_amount => date_range_budget_amount,
|
49
62
|
:expense_amount => expense_amount(category_id, transactions)})
|
50
63
|
end
|
51
64
|
end
|
@@ -76,9 +89,7 @@ module FinApps
|
|
76
89
|
amount = 0
|
77
90
|
if category_id.present? && transactions.respond_to?(:find)
|
78
91
|
transaction = transactions.find { |t| t['category_id'] == category_id }
|
79
|
-
if transaction.present? && transaction.key?
|
80
|
-
amount = transaction['expense'].to_f
|
81
|
-
end
|
92
|
+
amount = transaction['expense'].to_f if transaction.present? && transaction.key?('expense')
|
82
93
|
end
|
83
94
|
amount
|
84
95
|
end
|
data/lib/finapps/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finapps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.2.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erich Quintero
|
@@ -191,6 +191,7 @@ files:
|
|
191
191
|
- bin/finapps
|
192
192
|
- finapps.gemspec
|
193
193
|
- lib/finapps.rb
|
194
|
+
- lib/finapps/cli/budgets.rb
|
194
195
|
- lib/finapps/cli/common.rb
|
195
196
|
- lib/finapps/cli/institutions.rb
|
196
197
|
- lib/finapps/cli/users.rb
|