finapps 0.22.4.pre → 1.0.0
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 +7 -25
- data/.rspec +5 -0
- data/finapps.gemspec +8 -8
- data/lib/finapps/middleware/api_token.rb +6 -6
- data/lib/finapps/rest/alert.rb +12 -5
- data/lib/finapps/rest/alert_definition.rb +11 -3
- data/lib/finapps/rest/alert_preferences.rb +10 -2
- data/lib/finapps/rest/alert_settings.rb +11 -3
- data/lib/finapps/rest/budget_calculation.rb +11 -4
- data/lib/finapps/rest/budget_models.rb +11 -3
- data/lib/finapps/rest/budgets.rb +10 -4
- data/lib/finapps/rest/cashflows.rb +5 -3
- data/lib/finapps/rest/categories.rb +6 -2
- data/lib/finapps/rest/client.rb +102 -48
- data/lib/finapps/rest/connection.rb +20 -45
- data/lib/finapps/rest/defaults.rb +1 -2
- data/lib/finapps/rest/institutions.rb +11 -3
- data/lib/finapps/rest/relevance/rulesets.rb +10 -10
- data/lib/finapps/rest/transactions.rb +16 -4
- data/lib/finapps/rest/user_institutions.rb +35 -10
- data/lib/finapps/rest/users.rb +20 -24
- data/lib/finapps/utils/logging.rb +7 -7
- data/lib/finapps/version.rb +1 -1
- data/spec/middleware/api_token_spec.rb +32 -0
- data/spec/rest/client_spec.rb +91 -59
- data/spec/rest/connection_spec.rb +40 -0
- data/spec/spec_helper.rb +12 -60
- data/spec/utils/logging_spec.rb +4 -8
- metadata +70 -54
- data/bin/finapps +0 -9
- data/lib/finapps/cli/alert_preferences.rb +0 -65
- data/lib/finapps/cli/budgets.rb +0 -37
- data/lib/finapps/cli/cashflows.rb +0 -37
- data/lib/finapps/cli/common.rb +0 -43
- data/lib/finapps/cli/institutions.rb +0 -59
- data/lib/finapps/cli/users.rb +0 -87
data/lib/finapps/cli/budgets.rb
DELETED
@@ -1,37 +0,0 @@
|
|
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
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'finapps'
|
3
|
-
require 'pp'
|
4
|
-
|
5
|
-
module FinApps
|
6
|
-
class CLI < Thor
|
7
|
-
|
8
|
-
desc 'cashflows', 'show'
|
9
|
-
|
10
|
-
def cashflows_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.cashflows.show('2015-02-01T00:00:00Z', '2015-02-28T00:00:00Z')
|
19
|
-
if budget.present?
|
20
|
-
puts
|
21
|
-
puts 'cashflow results:'
|
22
|
-
pp budget
|
23
|
-
else
|
24
|
-
puts
|
25
|
-
puts 'unable to get cashflow'
|
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
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'finapps'
|
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
|
7
|
-
|
8
|
-
module FinApps
|
9
|
-
class CLI < Thor
|
10
|
-
|
11
|
-
desc 'create_client', 'initialize API REST Client'
|
12
|
-
|
13
|
-
def create_client
|
14
|
-
puts client
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def client
|
20
|
-
company_id = ENV['FINAPPS_COMPANY_IDENTIFIER']
|
21
|
-
raise 'Invalid company identifier. Please setup the FA_ID environment variable.' if company_id.blank?
|
22
|
-
|
23
|
-
company_token = ENV['FINAPPS_COMPANY_TOKEN']
|
24
|
-
raise 'Invalid company token. Please setup the FA_TOKEN environment variable.' if company_token.blank?
|
25
|
-
|
26
|
-
host = ENV['FINAPPS_BASE_URL']
|
27
|
-
raise 'Invalid API host url. Please setup the FA_URL environment variable.' if host.blank?
|
28
|
-
|
29
|
-
@client ||= FinApps::REST::Client.new company_id, company_token, {:host => host, :log_level => Logger::DEBUG,
|
30
|
-
:request_uuid => 'le-request-uuid-z',
|
31
|
-
:session_id => 'da-session-idz'}
|
32
|
-
end
|
33
|
-
|
34
|
-
def rescue_standard_error(error)
|
35
|
-
puts '=============================='
|
36
|
-
puts 'Error:'
|
37
|
-
p error
|
38
|
-
puts "Backtrace:\n\t#{error.backtrace.join("\n\t")}"
|
39
|
-
puts '=============================='
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'finapps'
|
3
|
-
require 'securerandom'
|
4
|
-
require 'pp'
|
5
|
-
|
6
|
-
module FinApps
|
7
|
-
class CLI < Thor
|
8
|
-
|
9
|
-
desc 'institutions_search', 'search institutions'
|
10
|
-
|
11
|
-
def institutions_search(user_identifier, user_token = '4JZmhcHVf3ODRJ9TMKF7N/1sHDY3M5Q49A9ToAy+TDE=', term=nil)
|
12
|
-
|
13
|
-
begin
|
14
|
-
client.user_credentials!(user_identifier, user_token)
|
15
|
-
institutions, error_messages = client.institutions.search term
|
16
|
-
if institutions.present?
|
17
|
-
puts
|
18
|
-
puts 'search results:'
|
19
|
-
pp institutions
|
20
|
-
else
|
21
|
-
puts
|
22
|
-
puts 'unable to search institutions'
|
23
|
-
error_messages.each { |m| puts m } if error_messages.present?
|
24
|
-
end
|
25
|
-
puts
|
26
|
-
|
27
|
-
rescue StandardError => error
|
28
|
-
rescue_standard_error(error)
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
desc 'institutions_refresh', 'refresh institutions'
|
35
|
-
|
36
|
-
def institutions_refresh(user_identifier, user_token = '4JZmhcHVf3ODRJ9TMKF7N/1sHDY3M5Q49A9ToAy+TDE=', term=nil)
|
37
|
-
|
38
|
-
begin
|
39
|
-
client.user_credentials!(user_identifier, user_token)
|
40
|
-
results, error_messages = client.user_institutions.refresh
|
41
|
-
if results.present?
|
42
|
-
puts
|
43
|
-
puts 'refresh results:'
|
44
|
-
pp results
|
45
|
-
else
|
46
|
-
puts
|
47
|
-
puts 'unable to refresh institutions'
|
48
|
-
error_messages.each { |m| puts m } if error_messages.present?
|
49
|
-
end
|
50
|
-
puts
|
51
|
-
|
52
|
-
rescue StandardError => error
|
53
|
-
rescue_standard_error(error)
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
end
|
data/lib/finapps/cli/users.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'finapps'
|
3
|
-
require 'securerandom'
|
4
|
-
require 'pp'
|
5
|
-
|
6
|
-
module FinApps
|
7
|
-
class CLI < Thor
|
8
|
-
|
9
|
-
desc 'user_create', 'creates a new API user'
|
10
|
-
|
11
|
-
def user_create(email=nil, password=nil)
|
12
|
-
|
13
|
-
begin
|
14
|
-
email ||= "test-#{SecureRandom.uuid}@powerwallet.com"
|
15
|
-
password ||= 'Power1'
|
16
|
-
user, error_messages = client.users.create ({:email => email,
|
17
|
-
:password => password,
|
18
|
-
:password_confirm => password,
|
19
|
-
:postal_code => '33021'})
|
20
|
-
if user.present?
|
21
|
-
puts
|
22
|
-
puts 'user created:'
|
23
|
-
pp user
|
24
|
-
else
|
25
|
-
puts
|
26
|
-
puts 'unable to create user'
|
27
|
-
error_messages.each { |m| puts m } if error_messages.present?
|
28
|
-
end
|
29
|
-
puts
|
30
|
-
|
31
|
-
rescue StandardError => error
|
32
|
-
rescue_standard_error(error)
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
desc 'user_login', 'creates a new API user and signs in'
|
38
|
-
|
39
|
-
def user_login(email=nil, password=nil)
|
40
|
-
|
41
|
-
begin
|
42
|
-
email ||= "test-#{SecureRandom.uuid}@powerwallet.com"
|
43
|
-
password ||= 'WrongPassword'
|
44
|
-
user, error_messages = client.users.login ({:email => email, :password => password})
|
45
|
-
if user.present?
|
46
|
-
puts
|
47
|
-
puts 'user logged in:'
|
48
|
-
pp user
|
49
|
-
else
|
50
|
-
puts
|
51
|
-
puts 'unable to login user'
|
52
|
-
error_messages.each { |m| puts m } if error_messages.present?
|
53
|
-
end
|
54
|
-
puts
|
55
|
-
|
56
|
-
rescue StandardError => error
|
57
|
-
rescue_standard_error(error)
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
desc 'user_delete', 'deletes an API user'
|
63
|
-
|
64
|
-
def user_delete(public_id=nil)
|
65
|
-
|
66
|
-
begin
|
67
|
-
public_id ||= SecureRandom.uuid.to_s
|
68
|
-
|
69
|
-
error_messages = client.users.delete (public_id)
|
70
|
-
if error_messages.blank?
|
71
|
-
puts
|
72
|
-
puts 'user deleted!'
|
73
|
-
else
|
74
|
-
puts
|
75
|
-
puts 'unable to delete user'
|
76
|
-
error_messages.each { |m| puts m }
|
77
|
-
end
|
78
|
-
puts
|
79
|
-
|
80
|
-
rescue StandardError => error
|
81
|
-
rescue_standard_error(error)
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
end
|