Skip to content

Instantly share code, notes, and snippets.

@zacwasielewski
Created December 14, 2015 16:25
Show Gist options
  • Save zacwasielewski/b1c59ebfc7460def4fdf to your computer and use it in GitHub Desktop.
Save zacwasielewski/b1c59ebfc7460def4fdf to your computer and use it in GitHub Desktop.
var NOTIFY_RULES = {
'South Utica': 'eriley@romanelli.com, zac@romanelli.com',
'New Hartford': ''
};
var NOTIFY_CONDITION = 'Most convenient branch for us to meet';
var NOTIFY_URL = 'https://zapier.com/hooks/catch/3c89f1/';
//var NOTIFY_URL = 'http://requestb.in/1hjdom11'; // TEST
var payload = {};
for (var prop in input) {
if (input.hasOwnProperty(prop)) {
payload[prop] = input[prop];
}
}
payload.email_to = NOTIFY_RULES[ input[NOTIFY_CONDITION] ];
fetch(NOTIFY_URL, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(payload)
}).then(function(response) {
return response.text();
}).then(function(responsebody) {
var output = {response: responsebody};
callback(null, output);
}).catch(function(error) {
callback(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment