Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const _extractEmail = vacation => {
- const approvalRequestExists = !!vacation.planApproval;
- return approvalRequestExists
- ? vacation.planApproval.requester.key
- : vacation.assignee.key;
- };
- const _extractDataForStatus = vacation => {
- const email = _extractEmail(vacation);
- const { start, end } = vacation;
- return { email, start, end };
- }
- const getUsersOnVacation = async date => {
- const url = `${process.env.TEMPO_ALLOCATIONS_URL}?assigneeType=user&startDate=${date}&endDate=${date}`;
- const vacations = await request.get(url, {
- auth: {
- user: process.env.TEMPO_USER,
- password: process.env.TEMPO_PASS
- },
- json: true
- });
- return vacations.map(_extractDataForStatus);
- };
Add Comment
Please, Sign In to add comment