mintkit 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/mintkit.rb +8 -0
- data/lib/mintkit/client.rb +102 -0
- data/lib/mintkit/version.rb +3 -0
- data/mintkit.gemspec +26 -0
- metadata +121 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Rob Scanlon
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Mintkit
|
2
|
+
|
3
|
+
A Mint.com API. Not at all affialiated with or endorsed by mint.com/intuit. Your mileage may vary.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'mintkit'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install mintkit
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/mintkit.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
require "mechanize"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
module Mintkit
|
5
|
+
|
6
|
+
class Client
|
7
|
+
|
8
|
+
def initialize(username, password)
|
9
|
+
|
10
|
+
@username = username
|
11
|
+
@password = password
|
12
|
+
@token = nil
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
# login to my account
|
17
|
+
# get all the transactions
|
18
|
+
def transactions
|
19
|
+
agent = login
|
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
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
end
|
45
|
+
logout(agent)
|
46
|
+
transos
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
def accounts
|
51
|
+
agent = login
|
52
|
+
page = agent.get('https://wwws.mint.com/overview.event')
|
53
|
+
|
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
|
+
logout(agent)
|
60
|
+
|
61
|
+
accounts
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
# force a refresh on my account
|
66
|
+
def refresh
|
67
|
+
agent = login
|
68
|
+
page = agent.get('https://wwws.mint.com/overview.event')
|
69
|
+
|
70
|
+
agent.post("https://wwws.mint.com/refreshFILogins.xevent", {"token"=>@token})
|
71
|
+
|
72
|
+
logout(agent)
|
73
|
+
|
74
|
+
true
|
75
|
+
|
76
|
+
end
|
77
|
+
private
|
78
|
+
|
79
|
+
def login
|
80
|
+
|
81
|
+
agent = Mechanize.new{|a| a.ssl_version, a.verify_mode = 'SSLv3', OpenSSL::SSL::VERIFY_NONE}
|
82
|
+
page = agent.get('https://wwws.mint.com/login.event')
|
83
|
+
form = page.forms[2]
|
84
|
+
form.username = @username
|
85
|
+
form.password = @password
|
86
|
+
page = agent.submit(form,form.buttons.first)
|
87
|
+
@token = page.at('input').attributes["value"].value.match(/"token":"([0-9a-zA-Z]*)"/)[1]
|
88
|
+
agent
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
def logout(agent)
|
93
|
+
agent.get('https://wwws.mint.com/logout.event?task=explicit')
|
94
|
+
true
|
95
|
+
end
|
96
|
+
|
97
|
+
def remove_quotes(input)
|
98
|
+
input.slice(1..-1).slice(0..-2)
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
data/mintkit.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
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 = "mintkit"
|
8
|
+
spec.version = Mintkit::VERSION
|
9
|
+
spec.authors = ["Rob Scanlon"]
|
10
|
+
spec.email = ["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/arscan/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_dependency "mechanize"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mintkit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Rob Scanlon
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: mechanize
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.3'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.3'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: Ruby API for mint.com. Not at all affiliated with or endorsed by mint.com/Intuit. Your
|
79
|
+
mileage may vary.
|
80
|
+
email:
|
81
|
+
- robscanlon@gmail.com
|
82
|
+
executables: []
|
83
|
+
extensions: []
|
84
|
+
extra_rdoc_files: []
|
85
|
+
files:
|
86
|
+
- .gitignore
|
87
|
+
- Gemfile
|
88
|
+
- LICENSE.txt
|
89
|
+
- README.md
|
90
|
+
- Rakefile
|
91
|
+
- lib/mintkit.rb
|
92
|
+
- lib/mintkit/client.rb
|
93
|
+
- lib/mintkit/version.rb
|
94
|
+
- mintkit.gemspec
|
95
|
+
homepage: https://github.com/arscan/mintkit
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ! '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ! '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 1.8.23
|
117
|
+
signing_key:
|
118
|
+
specification_version: 3
|
119
|
+
summary: Ruby API for mint.com. Not at all affiliated with or endorsed by mint.com/Intuit. Your
|
120
|
+
mileage may vary.
|
121
|
+
test_files: []
|