Created
October 8, 2015 08:02
-
-
Save tomfa/3de4ed7de47812dee638 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
// 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