fine_ants 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/fine_ants/adapters/simple.rb +55 -0
- data/lib/fine_ants/adapters/target.rb +60 -0
- data/lib/fine_ants/adapters.rb +2 -4
- data/lib/fine_ants/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdfd25caa322ccfb9cadc91f34bbe37193220c56
|
4
|
+
data.tar.gz: 32edb4b9d2e7d33dcda39819df4cb01167f0d8e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8266c49f0559ca3a1207f01c8423f72eddbc3fe469cf310437c60acae857b55d211f4af3bfa02eddd94444c3fcf975d9a9f3bad451ecfd695f0021f53376f877
|
7
|
+
data.tar.gz: 20df6842aec3549e9a84a46d5ff22351aaedb181c47d07b32a4767bec156475c6eb5f973b6b316a99f3607ac74e0b485cb03ca3d6f8532f1d4ab821f7b4377f9
|
data/README.md
CHANGED
@@ -61,6 +61,8 @@ Right now, FineAnts ships with adapters for:
|
|
61
61
|
* [PNC Personal Banking](https://www.pnc.com/en/personal-banking.html)
|
62
62
|
* [Betterment](https://www.betterment.com)
|
63
63
|
* [Chase](https://www.chase.com)
|
64
|
+
* [Simple](https://www.simple.com)
|
65
|
+
* [Target REDcard](https://rcam.target.com)
|
64
66
|
|
65
67
|
You can also implement your own adapter and pass it to `FineAnts.download`. The
|
66
68
|
expected public contract of an adapter is:
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "bigdecimal"
|
2
|
+
|
3
|
+
module FineAnts
|
4
|
+
module Adapters
|
5
|
+
class Simple
|
6
|
+
def initialize(credentials)
|
7
|
+
@user = credentials[:user]
|
8
|
+
@password = credentials[:password]
|
9
|
+
end
|
10
|
+
|
11
|
+
def login
|
12
|
+
visit "https://www.simple.com"
|
13
|
+
click_link "Log In"
|
14
|
+
|
15
|
+
fill_in "username", :with => @user
|
16
|
+
fill_in "passphrase", :with => @password
|
17
|
+
click_button "Sign in"
|
18
|
+
verify_login!
|
19
|
+
end
|
20
|
+
|
21
|
+
def download
|
22
|
+
balance = find(".sts-available").find("b").text
|
23
|
+
available_balance = find("#sts-flag").text.strip
|
24
|
+
user_name = find(".masthead-username").text
|
25
|
+
|
26
|
+
[
|
27
|
+
{
|
28
|
+
:adapter => :simple,
|
29
|
+
:user => @user,
|
30
|
+
:id => "#{user_name}",
|
31
|
+
:name => "#{user_name}",
|
32
|
+
:amount => parse_currency(balance),
|
33
|
+
:available_amount => parse_currency(available_balance),
|
34
|
+
}
|
35
|
+
].tap{ logout! }
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def logout!
|
40
|
+
visit "https://bank.simple.com/signout"
|
41
|
+
end
|
42
|
+
|
43
|
+
def parse_currency(currency_string)
|
44
|
+
BigDecimal.new(currency_string.match(/\$?(.*)$/)[1].gsub(/,/,''))
|
45
|
+
end
|
46
|
+
|
47
|
+
def verify_login!
|
48
|
+
find("h2", text: "Safe-to-Spend")
|
49
|
+
rescue Capybara::ElementNotFound
|
50
|
+
raise FineAnts::LoginFailedError.new
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "bigdecimal"
|
2
|
+
|
3
|
+
module FineAnts
|
4
|
+
module Adapters
|
5
|
+
class Target
|
6
|
+
def initialize(credentials)
|
7
|
+
@user = credentials[:user]
|
8
|
+
@password = credentials[:password]
|
9
|
+
end
|
10
|
+
|
11
|
+
def login
|
12
|
+
visit "https://rcam.target.com/default.aspx"
|
13
|
+
|
14
|
+
fill_in "Login_UserName", :with => @user
|
15
|
+
fill_in "Login_Password", :with => @password
|
16
|
+
find("#Login_btnSignIn_btnSignIn").click
|
17
|
+
|
18
|
+
verify_login!
|
19
|
+
end
|
20
|
+
|
21
|
+
def download
|
22
|
+
balance = find("#AcctSummaryRCAM_AcctTbl_CrntBal").text
|
23
|
+
available_balance = find("#AcctSummaryRCAM_AcctTbl_CredAvail").text
|
24
|
+
next_due_date = find("#AcctSummaryRCAM_AcctTbl_PmtDueDt").text
|
25
|
+
card_number = find("#AccountAcctNum").text.delete("For your REDcard ending in: ")
|
26
|
+
|
27
|
+
[
|
28
|
+
{
|
29
|
+
:adapter => :target,
|
30
|
+
:user => @user,
|
31
|
+
:id => "REDcard #{card_number}",
|
32
|
+
:name => "REDcard #{card_number}",
|
33
|
+
:type => :credit_card,
|
34
|
+
:amount => -1 * parse_currency(balance),
|
35
|
+
:available_amount => parse_currency(available_balance),
|
36
|
+
:next_due_date => parse_due_date(next_due_date)
|
37
|
+
}
|
38
|
+
]
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def parse_currency(currency_string)
|
44
|
+
BigDecimal.new(currency_string.match(/\$(.*)$/)[1].delete(","))
|
45
|
+
end
|
46
|
+
|
47
|
+
def parse_due_date(date_string)
|
48
|
+
return nil if date_string == "-"
|
49
|
+
date_string
|
50
|
+
end
|
51
|
+
|
52
|
+
def verify_login!
|
53
|
+
find "span#DefaultPageTitle", text: "View Account Summary"
|
54
|
+
rescue Capybara::ElementNotFound
|
55
|
+
raise FineAnts::LoginFailedError.new
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
data/lib/fine_ants/adapters.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
require "capybara/dsl"
|
2
2
|
|
3
|
-
|
4
|
-
require
|
5
|
-
require "fine_ants/adapters/betterment"
|
6
|
-
require "fine_ants/adapters/chase"
|
3
|
+
# Autoload all predefined adapters
|
4
|
+
Dir[File.join(File.dirname(__FILE__), 'adapters', '*.rb')].each { |f| require f }
|
7
5
|
|
8
6
|
module FineAnts
|
9
7
|
module Adapters
|
data/lib/fine_ants/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fine_ants
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Searls
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -100,6 +100,8 @@ files:
|
|
100
100
|
- lib/fine_ants/adapters/betterment.rb
|
101
101
|
- lib/fine_ants/adapters/chase.rb
|
102
102
|
- lib/fine_ants/adapters/pnc.rb
|
103
|
+
- lib/fine_ants/adapters/simple.rb
|
104
|
+
- lib/fine_ants/adapters/target.rb
|
103
105
|
- lib/fine_ants/adapters/vanguard.rb
|
104
106
|
- lib/fine_ants/capybara_setup.rb
|
105
107
|
- lib/fine_ants/login_failed_error.rb
|