Skip to content

Instantly share code, notes, and snippets.

@mathetos
Forked from kevinwhoffman/zap.js
Last active February 15, 2018 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mathetos/fcb8dc34dcbebfdb23c1b92479878d1e to your computer and use it in GitHub Desktop.
Save mathetos/fcb8dc34dcbebfdb23c1b92479878d1e to your computer and use it in GitHub Desktop.
Get Unassigned from HelpScout
/*
* HelpScout Zap: Get Number of Unassigned in a Specific Mailbox
* Use Zapier's "Code" Action to trigger this
* This only works with Zapier, it depends on the "callback" functions
*/
var btoa = function (str) {return new Buffer(str).toString('base64');};
fetch('https://api.helpscout.net/v1/mailboxes/{HELPSCOUT_MAILBOX_ID}/folders.json', {
cache: 'no-cache',
credentials: 'same-origin',
headers: {
"Authorization": "Basic " + btoa('{HELPSCOUT_API_KEY}:X')
},
mode: 'no-cors',
})
.then(function(res) {
return res.json();
})
.then(function (body) {
var output = {
name: body.items[0].name, // Returns 'Unassigned'
totalCount: body.items[0].totalCount // Returns int
};
callback(null, output);
})
.catch(callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment