Last active
April 4, 2016 15:45
-
-
Save pasviegas/43cc8d42f1c19d8df5f44b477238a4d7 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
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