Class: Mintkit::Client
- Inherits:
-
Object
- Object
- Mintkit::Client
- Defined in:
- lib/mintkit/client.rb
Instance Method Summary collapse
- #accounts ⇒ Object
-
#initialize(username, password) ⇒ Client
constructor
A new instance of Client.
-
#refresh ⇒ Object
force a refresh on my account.
-
#transactions ⇒ Object
login to my account get all the transactions.
Constructor Details
#initialize(username, password) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 |
# File 'lib/mintkit/client.rb', line 9 def initialize(username, password) @username, @password = username, password @agent = Mechanize.new{|a| a.ssl_version, a.verify_mode = 'SSLv3', OpenSSL::SSL::VERIFY_NONE} login end |
Instance Method Details
#accounts ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/mintkit/client.rb', line 52 def accounts page = @agent.get('https://wwws.mint.com/overview.event') requeststring = %q#[{"args":{"types":["BANK","CREDIT","INVESTMENT","LOAN","MORTGAGE","OTHER_PROPERTY","REAL_ESTATE","VEHICLE","UNCLASSIFIED"]},"service":"MintAccountService","task":"getAccountsSortedByBalanceDescending","id":"8675309"}]# accounts = JSON.parse(@agent.post("https://wwws.mint.com/bundledServiceController.xevent?token=#{@token}",{"input" => requeststring}).body)["response"]["8675309"]["response"] accountlist = [] accounts.each do |a| account = { :current_balance => a["currentBalance"], :login_status => a["fiLoginUIStatus"], :currency => a["currency"], :id => a["id"], :amount_due => a["dueAmt"], :name => a["name"], :value => a["value"], #:due_date => Date.strptime(a["dueDate"], '%m/%d/%Y'), :last_updated => Time.at(a["lastUpdated"]/1000).to_date, :last_updated_string => a["lastUpdatedInString"], :active => !!a["isActive"], :login_status => a["fiLoginStatus"], :account_type => a["accountType"], :date_added => Time.at(a["addAccountDate"]/1000).to_date } if block_given? yield account end accountlist << account end accountlist end |
#refresh ⇒ Object
force a refresh on my account
90 91 92 93 94 95 96 97 |
# File 'lib/mintkit/client.rb', line 90 def refresh page = @agent.get('https://wwws.mint.com/overview.event') @agent.post("https://wwws.mint.com/refreshFILogins.xevent", {"token"=>@token}) true end |
#transactions ⇒ Object
login to my account get all the transactions
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/mintkit/client.rb', line 19 def transactions raw_transactions = @agent.get("https://wwws.mint.com/transactionDownload.event?").body transos = [] raw_transactions.split("\n").each_with_index do |line,index| if index > 1 line_array = line.split(",") transaction = { :date => Date.strptime(remove_quotes(line_array[0]), '%m/%d/%Y'), :description=>remove_quotes(line_array[1]), :original_description=>remove_quotes(line_array[2]), :amount=>remove_quotes(line_array[3]).to_f, :type=>remove_quotes(line_array[4]), :category=>remove_quotes(line_array[5]), :account=>remove_quotes(line_array[6]), :labels=>remove_quotes(line_array[7]), :notes=>remove_quotes(line_array[8]) } transos << transaction if block_given? yield transaction end end end transos end |