Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// nodejs freshdesk implementation
var request = require('request');
var url = "http://yourcompanyname.freshdesk.com"; // Your URL
var apikey = ""; // Your API key
var auth = 'Basic ' + new Buffer(apikey + ':X').toString('base64');
var fresh = {
get: function(link, callback) {
request({
url: url + link,
headers: {
'Authorization' : auth
}
},
callback
);
},
post: function(link, data, callback) {
request.post(
{
url: url + link,
json: data,
headers: {
'Authorization' : auth
}
},
callback
);
},
put: function(link, data, callback) {
request.put(
{
url: url + link,
json: data,
headers: {
'Authorization' : auth
}
},
callback
);
}
};
postContact: function(contact, callback) {
fresh.post('/contacts.json', contact, callback);
},
putContact: function(id, contact, callback) {
fresh.put('/contacts/' + id + '.json', contact, callback);
},
getContacts: function(callback) {
fresh.get('/contacts.json?state=all', callback);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment