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
// Copyright (c) 2014 Gabi Zuniga | |
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. | |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
// | |
#include <pebble.h> | |
// standard defines | |
// | |
#define WIDTH 144 |
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
app_message_register_inbox_received(fetch_msg); | |
app_message_register_inbox_dropped(in_dropped_handler); | |
app_message_register_outbox_failed(out_failed_handler); | |
app_message_open(256,50); // in/out |
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
// Copyright (c) 2014 Gabi Zuniga | |
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. | |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
// | |
// Configuration: Hardcoded for Hackathon | |
// TODO: The updated Mojio endpoint should be https://api.moj.io:443/v1/Trips?s |
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
// Initialization | |
Pebble.addEventListener('ready', function(e) { | |
config = [ | |
{"cb-enable":"true","title":"Expense Pro","sampling-rate":"1"} | |
]; | |
sendEntry(0, "-"); | |
fetchLastMojoTrip(); | |
}); | |
// Messages from the Pebble App |
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 postToConcur() { | |
console.log("Posting to Concur"); | |
var lastTrip = localStorage.getItem('lastTrip'); | |
if (lastTrip != null) { | |
console.log("lastTrip "+lastTrip); | |
lastTrip = JSON.parse(lastTrip); | |
concurBody.Journey.StartLocation = lastTrip.StartAddress.Address1; | |
concurBody.Journey.EndLocation = lastTrip.EndAddress.Address1; | |
concurBody.TransactionDate = lastTrip.EndTime; | |
concurBody.Journey.OdometerStart = lastTrip.StartMilage; |
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
// After setting up Twilio to call our node.js app | |
// ('/receiveMMS') when an SMS/MMS is received, | |
// the snippet below will get the Twilio-hosted | |
// MMS image URL and the message body, which | |
// represent the image receipt and expense amt | |
app.post('/receiveMMS', function (req, res) { | |
fromTwilio.mediaUrl = req.body.MediaUrl0; |
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
// *Post image to Concur using Concur module* (Coming soon!) | |
// The snippet below takes the Twilio-hosted MMS image URL | |
// and passes it to be uploaded to Concur | |
function(callback) { | |
options = { | |
oauthToken:concurToken, | |
imageURL: fromTwilio.mediaUrl | |
}; |
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
// *Create expense entry and link image to it* | |
function(imageId, callback) { | |
// Check if text message was included in MMS | |
if (isNaN(fromTwilio.msgBody)) callback(null, "Receipt uploaded, expense entry skipped!"); | |
var now = new Date(); | |
var year = now.getFullYear(); | |
var month = now.getMonth(); |
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
// *Builds the TwiML (XML) request that this app sends back to Twilio, to be relayed back as SMS to user* | |
// Sample usage: sendTwiml(res, "Receipt uploaded, expense entry created!") | |
function sendTwiml(res, message) { | |
var twiml = '<?xml version="1.0" encoding="UTF-8" ?><Response><Sms>' + message + '</Sms></Response>'; | |
res.send(twiml, { | |
'Content-Type': 'text/xml' | |
}, 200); | |
} |
OlderNewer