Skip to content

Instantly share code, notes, and snippets.

@pasviegas
Last active April 4, 2016 15:45
Show Gist options
  • Save pasviegas/43cc8d42f1c19d8df5f44b477238a4d7 to your computer and use it in GitHub Desktop.
Save pasviegas/43cc8d42f1c19d8df5f44b477238a4d7 to your computer and use it in GitHub Desktop.
import request from 'request';
export default async function (hook) {
const output = [hook.params.data.hook.changedTimesheetCompleteEntry].map((completeEntry) => {
return {
date: `${completeEntry.day}/${completeEntry.month}/${completeEntry.year}`,
sent: completeEntry.sent,
user: completeEntry.user,
forwardTo: completeEntry.forwardTo,
content: completeEntry.entryPairs.nodes.map((pair) => {
return `Entrada: ${pair.inEntry.hour}h${pair.inEntry.minute}min, Saída: ${pair.outEntry.hour}h${pair.outEntry.minute}min, Total: ${pair.total}h, Projeto: ${pair.project}`
}).join("<br/>")
}
});
request.post({url: 'https://zapier.com/hooks/catch/198776/27d1q7/', json: true, body: output}, (err, res, body) => {
if (err) return hook.res.end(err.messsage);
hook.res.end(body);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment