Created
December 14, 2015 16:25
-
-
Save zacwasielewski/b1c59ebfc7460def4fdf to your computer and use it in GitHub Desktop.
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 NOTIFY_RULES = { | |
'South Utica': '[email protected], [email protected]', | |
'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