usbank 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +4 -0
  4. data/lib/usbank.rb +48 -0
  5. metadata +59 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 79faa6e122350da91356e900244e336d3bf98785
4
+ data.tar.gz: 473d34612edaf5726e2453a259df9f856f9b5987
5
+ SHA512:
6
+ metadata.gz: 053942a3f3c273ee4098696452b914caa1a1ba56b126ee30fc37084fd12469b67b771b2ab5bdb8b108c99cd8dd51d05405cc85ab6dd71efe97187d1f3dc19f4d
7
+ data.tar.gz: 612a1edb9e153657607f19c7dec381a3f74257c2d48d9599ebc2b3df8a039b5cfa8dfeadd4eb3f86bd6147dfdda76ab384f8b87f4bc645f0576944fde5faf316
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 edlebert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ usbank
2
+ ======
3
+
4
+ A gem to fetch usbank transaction data.
data/lib/usbank.rb ADDED
@@ -0,0 +1,48 @@
1
+ require 'mechanize'
2
+
3
+ class USBank
4
+
5
+ attr_accessor :username, :password, :challenges
6
+
7
+ attr_reader :agent, :dashboard_url
8
+
9
+ def initialize(attributes={})
10
+ attributes.each { |k,v| send("#{k}=", v) }
11
+ self.challenges ||= {}
12
+ end
13
+
14
+ def login
15
+ @agent = Mechanize.new
16
+
17
+ page = @agent.get 'https://www4.usbank.com/internetBanking/RequestRouter?requestCmdId=DisplayLoginPage'
18
+ form = page.form_with :name => 'logon'
19
+ form['USERID'] = username
20
+ page = form.submit
21
+
22
+ form = page.forms.first
23
+ question = (challenges).keys.find { |question| page.body.include? question }
24
+ raise 'Challenge question not found' unless question
25
+ form["CHALLENGEANSWER"] = challenges[question]
26
+ page = form.submit
27
+
28
+ form = page.forms.first
29
+ form["PSWD"] = password
30
+ page = form.submit
31
+
32
+ raise "SSO redirect not found after password submission." unless page.body =~ /MM SSO/i && page.forms.any?
33
+ page = page.forms.first.submit
34
+
35
+ raise "Dashboard not found after SSO redirect." unless page.body =~ /U.S. Bank - Customer Dashboard/i
36
+ @dashboard_url = page.uri
37
+ end
38
+
39
+ def fetch account_index=2, options = {}
40
+ login unless dashboard_url
41
+ from = options.delete(:from) || Date.today - 90
42
+ to = options.delete(:to) || Date.today
43
+ download_path = "AccountDashboard/DownloadTrans.ashx?index=#{account_index}&from=#{from.to_s}&to=#{to.to_s}&type=qfx"
44
+ download_url = dashboard_url.to_s.gsub('CustomerDashboard/Index', download_path)
45
+ agent.get(download_url).body
46
+ end
47
+
48
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: usbank
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ed Lebert
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mechanize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ description: a gem to fetch transaction data from usbank
28
+ email: edlebert@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - LICENSE
34
+ - README.md
35
+ - lib/usbank.rb
36
+ homepage: http://github.com/edlebert/usbank
37
+ licenses: []
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.2.0
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: a gem to fetch transaction data from usbank
59
+ test_files: []