Commit 81b91378 authored by Farid Neshat's avatar Farid Neshat

Don't use Farid's hardcoded ID to make timeoff requests

parent cf93f292
......@@ -81,9 +81,21 @@ module.exports = function (robot) {
}];
}
bamboohr.employee(10)
.requestTimeOffAsync(request)
.done(() => msg.reply('Everything worked out'), utils.errorHandler(msg));
bamboohr.employeesAsync().then(employees => {
const profile = res.message.user.profile;
const email = profile && profile.email;
if (!email) {
res.reply("You don't have an email associated with your user.");
return;
}
const employee = employees.find(employee => employee.fields.workEmail === email);
if (!employee) {
res.reply("I can't find your email in the BambooHR system.");
return;
}
return employee.requestTimeOffAsync(request);
}).done(id => msg.reply('Your timeoff request is created. ;)'), utils.errorHandler(msg));
});
dialog.addChoice(/no/, (msg) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment