mrjoy-mintkit 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +23 -0
- data/README.md +56 -0
- data/Rakefile +1 -0
- data/bin/mintkit +108 -0
- data/lib/mintkit/client.rb +122 -0
- data/lib/mintkit/error.rb +4 -0
- data/lib/mintkit/version.rb +3 -0
- data/lib/mintkit.rb +8 -0
- data/mrjoy-mintkit.gemspec +27 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 633ece54cef071dd677e7e93c4dbaee9c7865f91
|
4
|
+
data.tar.gz: a482977dd634ce5218afc96255ef6958e43665f3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 060e7cc1acbdd7ca8f804ab4750d38b02acfaae757870b6525d9b8ad81c7e7a42510ff57cafc5fe1fb5c9aa8e0aefe3b40f329405f901110eb9b6f2e1e638e4c
|
7
|
+
data.tar.gz: 17835b25425072306869058c00871222aa6995ab9dc51d46b1982c6a29e52bf1b85079fe80d8862c6625f56c1ce271b43f7d18c0a99a2a36c281d2bb4e4c225b
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
### dev
|
2
|
+
[full changelog](http://github.com/MrJoy/mintkit/compare/v0.0.4...master)
|
3
|
+
|
4
|
+
### v0.0.4
|
5
|
+
[full changelog](http://github.com/MrJoy/mintkit/compare/3f12e2d21ef2adaf79dff02d634d2fd3ea45b33e...v0.0.4)
|
6
|
+
|
7
|
+
Changes
|
8
|
+
|
9
|
+
* Updated to work with Mint.com as of 2013-11-10.
|
10
|
+
* Facilitate development by specifying RVM ruby and gemsetin `Gemfile`.
|
11
|
+
* Add a changelog.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2013 Rob Scanlon
|
2
|
+
Modifications Copyright (c) 2013 Jon Frisby
|
3
|
+
|
4
|
+
MIT License
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Mintkit
|
2
|
+
|
3
|
+
A Mint.com API. Not at all affiliated with or endorsed by mint.com/intuit. Your mileage may vary.
|
4
|
+
|
5
|
+
## This Fork
|
6
|
+
|
7
|
+
* This fork has been updated to work with Mint.com as of 2013-11-10.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'mintkit'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install mintkit
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Command line:
|
26
|
+
|
27
|
+
``` shell
|
28
|
+
mintkit --help
|
29
|
+
```
|
30
|
+
|
31
|
+
Ruby API:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
client = Mintkit::Client.new(username,password)
|
35
|
+
|
36
|
+
# tell mint to refresh all your accounts
|
37
|
+
client.refresh #(note: it doesn't block yet while refreshing)
|
38
|
+
|
39
|
+
# dump all accounts and transactions
|
40
|
+
puts client.accounts #print out the accounts
|
41
|
+
puts client.transactions #print out all your transactions
|
42
|
+
|
43
|
+
# or use iterators (works for accounts as well)
|
44
|
+
client.transactions do |t|
|
45
|
+
puts "#{t[:account]} #{t[:amount]} #{t[:description]} #{t[:date]}"
|
46
|
+
end
|
47
|
+
|
48
|
+
```
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
1. Fork it
|
53
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
54
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
55
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
56
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/mintkit
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'mintkit'
|
4
|
+
require 'mintkit/error'
|
5
|
+
require 'trollop'
|
6
|
+
require 'io/console'
|
7
|
+
|
8
|
+
|
9
|
+
Signal.trap("PIPE", "EXIT")
|
10
|
+
|
11
|
+
############################3
|
12
|
+
# Main functions
|
13
|
+
#
|
14
|
+
|
15
|
+
def refresh(client)
|
16
|
+
client.refresh
|
17
|
+
|
18
|
+
puts "Account is currently refreshing. It might take a minute or two"
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
def accounts(client)
|
23
|
+
client.accounts do |a|
|
24
|
+
puts "%-10s %10s %s" % [a[:account_type],a[:value],a[:name][0..27]]
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
def transactions(client)
|
30
|
+
client.transactions do |t|
|
31
|
+
sign = "-"
|
32
|
+
sign = "" if t[:type] == "credit"
|
33
|
+
puts "%-11s %1s%-9s %s" % [ t[:date].strftime("%-m/%-d/%Y"), sign, t[:amount], t[:description]]
|
34
|
+
#puts "#{t[:date]} #{t[:amount]} \t#{t[:description]}"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
#############################3
|
40
|
+
# Options, etc
|
41
|
+
|
42
|
+
opts = Trollop::options do
|
43
|
+
version Mintkit::VERSION
|
44
|
+
banner <<-EOS
|
45
|
+
Mintkit provides a simple interface to Mint.com. Not affiliated with Mint.com or Intuit. Your mileage may vary.
|
46
|
+
|
47
|
+
Usage:
|
48
|
+
mintkit [options] command
|
49
|
+
|
50
|
+
where command is one of:
|
51
|
+
refresh :refreshes your accounts
|
52
|
+
accounts :lists your accounts and balances
|
53
|
+
transactions :lists your transactions
|
54
|
+
|
55
|
+
and options are:
|
56
|
+
EOS
|
57
|
+
|
58
|
+
opt :username, "Mint.com username", :type => :string
|
59
|
+
opt :password, "Mint.com password", :type => :string
|
60
|
+
end
|
61
|
+
|
62
|
+
username = opts.username
|
63
|
+
password = opts.password
|
64
|
+
|
65
|
+
command = ARGV.shift
|
66
|
+
args = ARGV.join(' ')
|
67
|
+
|
68
|
+
unless command
|
69
|
+
puts "Error: no command specified. Try \"mintkit --help\""
|
70
|
+
exit
|
71
|
+
end
|
72
|
+
|
73
|
+
unless username
|
74
|
+
print "Mint.com username: "
|
75
|
+
username = $stdin.gets.chomp
|
76
|
+
end
|
77
|
+
|
78
|
+
unless password
|
79
|
+
print "Mint.com password: "
|
80
|
+
password = STDIN.noecho(&:gets)
|
81
|
+
print "\n"
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
#############################3
|
86
|
+
#
|
87
|
+
# create the client and call the appropriate function
|
88
|
+
|
89
|
+
|
90
|
+
begin
|
91
|
+
client = Mintkit::Client.new(username,password)
|
92
|
+
rescue Mintkit::FailedLogin
|
93
|
+
puts "Login failed. Please check that your username/password is correct"
|
94
|
+
exit 1
|
95
|
+
end
|
96
|
+
|
97
|
+
case
|
98
|
+
when command == 'refresh'
|
99
|
+
refresh(client)
|
100
|
+
|
101
|
+
when command == 'accounts'
|
102
|
+
accounts(client)
|
103
|
+
|
104
|
+
when command == 'transactions'
|
105
|
+
transactions(client)
|
106
|
+
else
|
107
|
+
puts "No such command: #{command}"
|
108
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require "mechanize"
|
2
|
+
require "json"
|
3
|
+
require "mintkit/error"
|
4
|
+
|
5
|
+
module Mintkit
|
6
|
+
|
7
|
+
class Client
|
8
|
+
|
9
|
+
def initialize(username, password)
|
10
|
+
|
11
|
+
@username, @password = username, password
|
12
|
+
@agent = Mechanize.new{|a| a.ssl_version, a.verify_mode = 'SSLv3', OpenSSL::SSL::VERIFY_NONE}
|
13
|
+
login
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
# login to my account
|
18
|
+
# get all the transactions
|
19
|
+
def transactions
|
20
|
+
raw_transactions = @agent.get("https://wwws.mint.com/transactionDownload.event?").body
|
21
|
+
|
22
|
+
transos = []
|
23
|
+
|
24
|
+
raw_transactions.split("\n").each_with_index do |line,index|
|
25
|
+
|
26
|
+
if index > 1
|
27
|
+
line_array = line.split(",")
|
28
|
+
transaction = {
|
29
|
+
:date => Date.strptime(remove_quotes(line_array[0]), '%m/%d/%Y'),
|
30
|
+
:description=>remove_quotes(line_array[1]),
|
31
|
+
:original_description=>remove_quotes(line_array[2]),
|
32
|
+
:amount=>remove_quotes(line_array[3]).to_f,
|
33
|
+
:type=>remove_quotes(line_array[4]),
|
34
|
+
:category=>remove_quotes(line_array[5]),
|
35
|
+
:account=>remove_quotes(line_array[6]),
|
36
|
+
:labels=>remove_quotes(line_array[7]),
|
37
|
+
:notes=>remove_quotes(line_array[8])
|
38
|
+
}
|
39
|
+
transos << transaction
|
40
|
+
|
41
|
+
if block_given?
|
42
|
+
yield transaction
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
transos
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
def accounts
|
53
|
+
page = @agent.get('https://wwws.mint.com/overview.event')
|
54
|
+
|
55
|
+
requeststring = %q#[{"args":{"types":["BANK","CREDIT","INVESTMENT","LOAN","MORTGAGE","OTHER_PROPERTY","REAL_ESTATE","VEHICLE","UNCLASSIFIED"]},"service":"MintAccountService","task":"getAccountsSortedByBalanceDescending","id":"8675309"}]#
|
56
|
+
|
57
|
+
accounts = JSON.parse(@agent.post("https://wwws.mint.com/bundledServiceController.xevent?token=#{@token}",{"input" => requeststring}).body)["response"]["8675309"]["response"]
|
58
|
+
|
59
|
+
accountlist = []
|
60
|
+
accounts.each do |a|
|
61
|
+
account = {
|
62
|
+
:current_balance => a["currentBalance"],
|
63
|
+
:login_status => a["fiLoginUIStatus"],
|
64
|
+
:currency => a["currency"],
|
65
|
+
:id => a["id"],
|
66
|
+
:amount_due => a["dueAmt"],
|
67
|
+
:name => a["name"],
|
68
|
+
:value => a["value"],
|
69
|
+
#:due_date => Date.strptime(a["dueDate"], '%m/%d/%Y'),
|
70
|
+
:last_updated => Time.at(a["lastUpdated"]/1000).to_date,
|
71
|
+
:last_updated_string => a["lastUpdatedInString"],
|
72
|
+
:active => !!a["isActive"],
|
73
|
+
:login_status => a["fiLoginStatus"],
|
74
|
+
:account_type => a["accountType"],
|
75
|
+
:date_added => Time.at(a["addAccountDate"]/1000).to_date
|
76
|
+
}
|
77
|
+
|
78
|
+
if block_given?
|
79
|
+
yield account
|
80
|
+
end
|
81
|
+
|
82
|
+
accountlist << account
|
83
|
+
|
84
|
+
end
|
85
|
+
accountlist
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
# force a refresh on my account
|
90
|
+
def refresh
|
91
|
+
page = @agent.get('https://wwws.mint.com/overview.event')
|
92
|
+
|
93
|
+
@agent.post("https://wwws.mint.com/refreshFILogins.xevent", {"token"=>@token})
|
94
|
+
|
95
|
+
true
|
96
|
+
|
97
|
+
end
|
98
|
+
private
|
99
|
+
|
100
|
+
def login
|
101
|
+
|
102
|
+
page = @agent.get('https://wwws.mint.com/login.event')
|
103
|
+
form = page.forms[2]
|
104
|
+
form.username = @username
|
105
|
+
form.password = @password
|
106
|
+
page = @agent.submit(form,form.buttons.first)
|
107
|
+
|
108
|
+
raise FailedLogin unless page.at('input').attributes["value"]
|
109
|
+
@token = page.at('input#javascript-token').attributes['value'].value
|
110
|
+
end
|
111
|
+
|
112
|
+
def logout
|
113
|
+
@agent.get('https://wwws.mint.com/logout.event?task=explicit')
|
114
|
+
true
|
115
|
+
end
|
116
|
+
|
117
|
+
def remove_quotes(input)
|
118
|
+
input.slice(1..-1).slice(0..-2)
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|
data/lib/mintkit.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mintkit/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mrjoy-mintkit"
|
8
|
+
spec.version = Mintkit::VERSION
|
9
|
+
spec.authors = ["Jon Frisby", "Rob Scanlon"]
|
10
|
+
spec.email = ["jfrisby@mrjoy.com", "robscanlon@gmail.com"]
|
11
|
+
spec.description = %q{Ruby API for mint.com. Not at all affiliated with or endorsed by Mint.com/Intuit. Your mileage may vary.}
|
12
|
+
spec.summary = spec.description
|
13
|
+
spec.homepage = "https://github.com/MrJoy/mintkit"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "mechanize"
|
22
|
+
spec.add_runtime_dependency "trollop"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mrjoy-mintkit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jon Frisby
|
8
|
+
- Rob Scanlon
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-11-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: mechanize
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: trollop
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bundler
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.3'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.3'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
description: Ruby API for mint.com. Not at all affiliated with or endorsed by Mint.com/Intuit. Your
|
85
|
+
mileage may vary.
|
86
|
+
email:
|
87
|
+
- jfrisby@mrjoy.com
|
88
|
+
- robscanlon@gmail.com
|
89
|
+
executables:
|
90
|
+
- mintkit
|
91
|
+
extensions: []
|
92
|
+
extra_rdoc_files: []
|
93
|
+
files:
|
94
|
+
- .gitignore
|
95
|
+
- CHANGELOG.md
|
96
|
+
- Gemfile
|
97
|
+
- LICENSE.txt
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- bin/mintkit
|
101
|
+
- lib/mintkit.rb
|
102
|
+
- lib/mintkit/client.rb
|
103
|
+
- lib/mintkit/error.rb
|
104
|
+
- lib/mintkit/version.rb
|
105
|
+
- mrjoy-mintkit.gemspec
|
106
|
+
homepage: https://github.com/MrJoy/mintkit
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.0.6
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Ruby API for mint.com. Not at all affiliated with or endorsed by Mint.com/Intuit. Your
|
130
|
+
mileage may vary.
|
131
|
+
test_files: []
|