-
-
Save martyndavies/002c49b11d7a367be139 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
#!/usr/bin/env node | |
var program = require('commander'); | |
var request = require('request'); | |
var userId, apiKey; | |
console.log('Enter your API credentials to see your current settings...'); | |
program.prompt('User ID: ', function(uid){ | |
userId = uid; | |
program.password('API Key: ', '*', function(key){ | |
apiKey = key; | |
process.stdin.destroy(); | |
request('https://sendgrid.com/api/parse.get.json?api_user='+userId+'&api_key='+apiKey, function(err, res, body){ | |
if (!err & res.statusCode === 200){ | |
var settings = JSON.parse(body); | |
console.log('Here are your Inbound Parse API settings:\n'); | |
for(var i = 0; i < settings.parse.length; i++){ | |
console.log(i+1+'. '+settings.parse[i].hostname+' -> '+settings.parse[i].url+'\n'); | |
} | |
console.log('\nHave a nice day!'); | |
} else { | |
console.log('Ooops! Looks like errors!'); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment