Created
August 17, 2018 22:38
-
-
Save aarobc/a7df757ff0325f875649190fa2169203 to your computer and use it in GitHub Desktop.
Proof of concept fetching utilities and pushing them into a google spreadsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main(){ | |
var td = [ | |
startDate(), | |
power(), | |
115, | |
water() | |
] | |
pushIt(td) | |
} | |
function pushIt(data){ | |
var sheet = SpreadsheetApp.getActiveSheet() | |
sheet.appendRow(data); | |
} | |
function actionEmail(query){ | |
var threads = GmailApp.search(query) | |
return threads.pop().getMessages().pop().getBody() | |
} | |
function startDate(){ | |
var date = new Date() | |
var y = date.getFullYear() | |
var m = date.getMonth() + 1 | |
return y + '/' + m + '/1' | |
} | |
function water(){ | |
var qs = 'after:' + startDate() | |
qs += ' from:no-reply@xpressbillpay.com' | |
Logger.log(qs) | |
var email = actionEmail(qs) | |
var ammount = email.match(/Transaction Amount: (\d*\.\d+)/)[1] | |
return ammount | |
} | |
function power(){ | |
var qs = 'after:' + startDate() | |
qs += ' from:accountnotices@rockymountainpower.net' | |
qs += ' "Your Rocky Mountain Power bill is available"' | |
var email = actionEmail(qs) | |
var amount = email.match(/amount of \$(\d*\.\d+)/)[1] | |
return amount | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment