-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcalendar_test.js
46 lines (39 loc) · 1.37 KB
/
calendar_test.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var CalendarUtils = require('./lib/calendar_utils')
var moment = require('moment')
var title = "Maker Night!"
var startTime = moment().hours(20).minutes(0).seconds(0).milliseconds(0)
var endTime = moment().hours(21).minutes(0).seconds(0).milliseconds(0)
var room = "[email protected]"
CalendarUtils.createEvent(title, startTime, endTime, room, (event) => {
if (event) {
console.log(`Created an event!`)
console.log("Title:", event.summary)
console.log("Starting at:", event.start.dateTime)
console.log("Ending at:", event.end.dateTime)
console.log("Attendees:", event.attendees.map((attendee) => {
return attendee.email
}))
CalendarUtils.findEvent(title, startTime, endTime, room, (event) => {
if (event) {
console.log(`Found a matching event!`)
console.log("Title:", event.summary)
console.log("Starting at:", event.start.dateTime)
console.log("Ending at:", event.end.dateTime)
console.log("Attendees:", event.attendees.map((attendee) => {
return attendee.email
}))
CalendarUtils.deleteEvent(event.id, (success) => {
if (success) {
console.log(`Deleted event.`)
} else {
console.log(`Epic FAIL!`)
}
})
} else {
console.log(`Epic FAIL!`)
}
})
} else {
console.log(`Epic FAIL!`)
}
})