Created
July 19, 2014 11:50
-
-
Save jeffdonthemic/81927d7ff181abf2a5aa to your computer and use it in GitHub Desktop.
Q snippets
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
Q.all([ | |
salesforce.getContactByMobile(res.locals.org, '(941) 111-1111'), | |
twilio.getMessage("MMd3dbafbbde409a109e4c71c7684cec77") | |
]).then(function(results) { | |
console.log(results[0]); | |
console.log(results[1]); | |
}); |
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
Q.spread([ | |
salesforce.getContactByMobile(res.locals.org, '(941) 809-3455'), | |
twilio.getMessage("MMd3dbafbbde409a109e4c71c7684cec24") | |
], function (contact, message) { | |
console.log(contact); | |
console.log(message); | |
}); |
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
var Q = require("q"); | |
exports.getContactByMobile = function(org, mobile) { | |
var deferred = Q.defer(); | |
var qry = "select id, name, mobilephone from contact where mobilephone = '" + mobile + "'"; | |
org.query({ query: qry }, function(err, resp){ | |
if(!err && resp.records) { | |
deferred.resolve(resp.records) | |
} else { | |
deferred.reject(err); | |
} | |
}); | |
return deferred.promise; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment