aggcat 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +20 -17
- data/lib/aggcat/client.rb +17 -7
- data/lib/aggcat/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -21,42 +21,45 @@ gem 'aggcat'
|
|
21
21
|
```ruby
|
22
22
|
require 'aggcat'
|
23
23
|
|
24
|
-
#
|
24
|
+
# Aggcat global configuration
|
25
25
|
Aggcat.configure do |config|
|
26
|
-
config.issuer_id =
|
27
|
-
config.consumer_key =
|
28
|
-
config.consumer_secret =
|
26
|
+
config.issuer_id = 'your issuer id'
|
27
|
+
config.consumer_key = 'your consumer key'
|
28
|
+
config.consumer_secret = 'your consumer secret'
|
29
29
|
config.certificate_path = '/path/to/your/certificate/key'
|
30
30
|
end
|
31
31
|
|
32
|
-
#
|
33
|
-
client = Aggcat.
|
32
|
+
# alternatively, specify configuration options when instantiating an Aggcat::Client
|
33
|
+
client = Aggcat::Client.new(
|
34
|
+
issuer_id: 'your issuer id',
|
35
|
+
consumer_key: 'your consumer key',
|
36
|
+
consumer_secret: 'your consumer secret',
|
37
|
+
certificate_path: '/path/to/your/certificate/key'
|
38
|
+
)
|
34
39
|
|
35
40
|
# get all supported financial institutions
|
36
|
-
|
37
|
-
=> {:response_code=>"200", :response=>{:institutions=>{:institution=>[{:institution_id=>"8860", :institution_name=>"Carolina Foothills FCU Credit Card", :home_url=>"http://www.cffcu.org/index.html", :phone_number=>"1-864-585-6838", :virtual=>false},
|
41
|
+
Aggcat.institutions
|
38
42
|
|
39
43
|
# get details for Bank of America
|
40
|
-
|
41
|
-
=> {:response_code=>"200", :response=>{:institution_detail=>{:institution_id=>"14007", :institution_name=>"Bank of America", :home_url=>"https://www.bankofamerica.com/", :phone_number=>"1-800-792-0808", :address=>{:address1=>"307 S. MAIN", :city=>"Charlotte", :state=>"NC", :postal_code=>"28255", :country=>"USA"}, :email_address=>"https://www.bankofamerica.com/contact/", :special_text=>"Please enter your Bank of America Online ID and Passcode required for login.", :currency_code=>"USD", :keys=>{:key=>[{:name=>"TAX_AGGR_ENABLED", :val=>"FALSE", :status=>"Active", :display_flag=>false, :display_order=>"20", :mask=>false}, {:name=>"passcode", :status=>"Active", :value_length_max=>"20", :display_flag=>true, :display_order=>"2", :mask=>true, :description=>"Passcode"}, {:name=>"onlineID", :status=>"Active", :value_length_max=>"32", :display_flag=>true, :display_order=>"1", :mask=>false, :description=>"Online ID"}]}}}}
|
44
|
+
Aggcat.institution(14007)
|
42
45
|
|
43
46
|
# add new financial account to aggregate from Bank of America
|
44
|
-
|
47
|
+
Aggcat.discover_and_add_accounts(14007, username, password)
|
45
48
|
|
46
|
-
# get
|
47
|
-
|
49
|
+
# get already aggregated financial account
|
50
|
+
Aggcat.account(account_id)
|
48
51
|
|
49
52
|
# get all aggregated accounts
|
50
|
-
|
53
|
+
Aggcat.accounts
|
51
54
|
|
52
55
|
# delete account
|
53
|
-
|
56
|
+
Aggcat.delete_account(account_id)
|
54
57
|
|
55
58
|
# get account transactions
|
56
|
-
|
59
|
+
Aggcat.account_transactions(account_id, start_date, end_date)
|
57
60
|
|
58
61
|
# delete all aggregated customers
|
59
|
-
|
62
|
+
Aggcat.delete_customers
|
60
63
|
|
61
64
|
```
|
62
65
|
|
data/lib/aggcat/client.rb
CHANGED
@@ -14,10 +14,12 @@ module Aggcat
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def institution(institution_id)
|
17
|
+
validate(institution_id: institution_id)
|
17
18
|
get("/institutions/#{institution_id}")
|
18
19
|
end
|
19
20
|
|
20
21
|
def discover_and_add_accounts(institution_id, username, password)
|
22
|
+
validate(institution_id: institution_id, username: username, password: password)
|
21
23
|
body = credentials(institution_id, username, password)
|
22
24
|
post("/institutions/#{institution_id}/logins", body, {user_id: "#{institution_id}-#{username}"})
|
23
25
|
end
|
@@ -27,21 +29,21 @@ module Aggcat
|
|
27
29
|
end
|
28
30
|
|
29
31
|
def account(account_id)
|
32
|
+
validate(account_id: account_id)
|
30
33
|
get("/accounts/#{account_id}")
|
31
34
|
end
|
32
35
|
|
33
|
-
def account_transactions(account_id, start_date
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
uri += "&txnEndDate=#{end_date.strftime(DATE_FORMAT)}"
|
39
|
-
end
|
36
|
+
def account_transactions(account_id, start_date, end_date = nil)
|
37
|
+
validate(account_id: account_id, start_date: start_date)
|
38
|
+
uri = "/accounts/#{account_id}/transactions?txnStartDate=#{start_date.strftime(DATE_FORMAT)}"
|
39
|
+
if end_date
|
40
|
+
uri += "&txnEndDate=#{end_date.strftime(DATE_FORMAT)}"
|
40
41
|
end
|
41
42
|
get(uri)
|
42
43
|
end
|
43
44
|
|
44
45
|
def delete_account(account_id)
|
46
|
+
validate(account_id: account_id)
|
45
47
|
delete("/accounts/#{account_id}")
|
46
48
|
end
|
47
49
|
|
@@ -73,6 +75,14 @@ module Aggcat
|
|
73
75
|
|
74
76
|
private
|
75
77
|
|
78
|
+
def validate(args)
|
79
|
+
args.each do |name, value|
|
80
|
+
if value.nil? || value.to_s.empty?
|
81
|
+
raise ArgumentError, "#{name} is required"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
76
86
|
def credentials(institution_id, username, password)
|
77
87
|
institution = institution(institution_id)
|
78
88
|
keys = institution[:response][:institution_detail][:keys][:key].sort { |a, b| a[:display_order] <=> b[:display_order] }
|
data/lib/aggcat/version.rb
CHANGED