fine_ants 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3697392395db65fdf59a5227adc446f7214ecf4
4
- data.tar.gz: f838e9a2bbd3ccbf1b46e7c99bebf24c9a9380a9
3
+ metadata.gz: fa66f515564aac911448db2c86e2657720b037ff
4
+ data.tar.gz: 2db921e79de8fb46b7f8c1321c2e12180c04c772
5
5
  SHA512:
6
- metadata.gz: 007c5ab54b95b8622afedf1d62ab83b198cde91e46cc06b55fdb24955a2b2e1eab8cc7de4d95d6001a0ed178d4a5fd038b4535c1a488b9103cf8f248a27ccd90
7
- data.tar.gz: 5ddba5b03f1fb7a33a65d4b98eb0460757555501ab0e341a67668b5344f075c81be261142135efbecc502dd6d5ec4a6972f13e6320b880a06a4c05788e7fb50d
6
+ metadata.gz: 64f0b77656425eabd3ce562f1c19f96cd32b98030a2bf4111b40965246a32c09b68194230e85afc26e1535d585e10a1cebe69321462a5c915774688e6433f13a
7
+ data.tar.gz: 27de194d5cfbca097eebd86926261d2f9b8a4d00abcfd42347de93fe5cf2abbe1955d374d6a416abe16763d7ccfc4340f5092859b60360a5939db781f9139c32
data/README.md CHANGED
@@ -59,6 +59,8 @@ Right now, FineAnts ships with adapters for:
59
59
 
60
60
  * [Vanguard Personal Investment](https://personal.vanguard.com/us/hnwnesc/nesc/LoginPage)
61
61
  * [PNC Personal Banking](https://www.pnc.com/en/personal-banking.html)
62
+ * [Betterment](https://www.betterment.com)
63
+ * [Chase](https://www.chase.com)
62
64
 
63
65
  You can also implement your own adapter and pass it to `FineAnts.download`. The
64
66
  expected public contract of an adapter is:
@@ -0,0 +1,72 @@
1
+ require "bigdecimal"
2
+
3
+ module FineAnts
4
+ module Adapters
5
+ class Chase
6
+ def initialize(credentials)
7
+ @user = credentials[:user]
8
+ @password = credentials[:password]
9
+ end
10
+
11
+ def login
12
+ visit "https://www.chase.com"
13
+ fill_in "User name", :with => @user
14
+ fill_in "Password", :with => @password
15
+ click_link "Sign in"
16
+ verify_login!
17
+ end
18
+
19
+ def logout
20
+ click_button "Sign out"
21
+ end
22
+
23
+ def download
24
+ # Select credit card
25
+ find("h3", text: "CREDIT CARDS")
26
+ .find(:xpath, "../..")
27
+ .find("section")
28
+ .first("div")
29
+ .click
30
+
31
+ credit_card_table = find("table.dl-box")
32
+
33
+ balance = credit_card_table.find("#accountCurrentBalance").text
34
+ available_balance = credit_card_table.find("#accountAvailableCreditBalance").text
35
+ next_due_date = credit_card_table.find("#nextPaymentDueDate").text
36
+
37
+ accounts = [
38
+ {
39
+ :adapter => :chase,
40
+ :user => @user,
41
+ :id => find(".ACTNAME").text,
42
+ :name => find(".ACTNAME").text,
43
+ :type => :credit_card,
44
+ :amount => -1 * parse_currency(balance),
45
+ :available_amount => parse_currency(available_balance),
46
+ :next_due_date => parse_due_date(next_due_date)
47
+ }
48
+ ]
49
+
50
+ logout
51
+ accounts
52
+ end
53
+
54
+ private
55
+
56
+ def parse_currency(currency_string)
57
+ BigDecimal.new(currency_string.match(/\$(.*)$/)[1].gsub(/,/,''))
58
+ end
59
+
60
+ def parse_due_date(due_date_string)
61
+ Date.strptime(due_date_string, "%b %d, %Y")
62
+ end
63
+
64
+ def verify_login!
65
+ find '[data-attr="LOGON_DETAILS.lastLogonDetailsLabel"]'
66
+ rescue Capybara::ElementNotFound
67
+ raise FineAnts::LoginFailedError.new
68
+ end
69
+ end
70
+ end
71
+ end
72
+
@@ -3,6 +3,7 @@ require "capybara/dsl"
3
3
  require "fine_ants/adapters/vanguard"
4
4
  require "fine_ants/adapters/pnc"
5
5
  require "fine_ants/adapters/betterment"
6
+ require "fine_ants/adapters/chase"
6
7
 
7
8
  module FineAnts
8
9
  module Adapters
@@ -1,3 +1,3 @@
1
1
  module FineAnts
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
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.1.0
4
+ version: 1.2.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-20 00:00:00.000000000 Z
11
+ date: 2016-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -98,6 +98,7 @@ files:
98
98
  - lib/fine_ants.rb
99
99
  - lib/fine_ants/adapters.rb
100
100
  - lib/fine_ants/adapters/betterment.rb
101
+ - lib/fine_ants/adapters/chase.rb
101
102
  - lib/fine_ants/adapters/pnc.rb
102
103
  - lib/fine_ants/adapters/vanguard.rb
103
104
  - lib/fine_ants/capybara_setup.rb