-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (28 loc) · 920 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const GraphHelper = require('../common/graphHelper');
module.exports = function (context, myQueueItem) {
context.log('Starting travel meeting booking');
const start = new Date(myQueueItem.start);
const MS_PER_MINUTE = 60000;
const end = new Date(start.getTime() + myQueueItem.durationInMins * MS_PER_MINUTE).toISOString();
context.log(myQueueItem.start);
context.log(end);
const meeting = {
subject: "Travel time",
start: {
dateTime: myQueueItem.start,
timeZone: "UTC"
},
end: {
dateTime: end,
timeZone: "UTC"
}
}
var graphHelper = new GraphHelper();
graphHelper.postData(`/v1.0/me/events`, myQueueItem.accessToken, JSON.stringify(meeting), (error, data) => {
if (error) {
context.done(error);
return;
}
context.done(null, data);
});
};