-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLog unavailable time - (4 full days).js
63 lines (59 loc) · 1.73 KB
/
Log unavailable time - (4 full days).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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const myHeaders = new Headers();
const userName = "email address or API KEY here";
const password = "password";
const siteName = "yourSiteName"
const userId = "userIdHere"
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Basic " + btoa(userName + ":" + password));
/*Event type id's:
-2 : Paid Time Off
-3 : Sick Leave
-4 : Meeting
-5 : Other
-6 : Training
-7 : Public Holiday*/
const raw = JSON.stringify({
"event": {
"title": "Unavailable",
"attending-user-ids": userId,
"description": "11 - 14 June",
"start": "2024-06-11T09:00",//yyyy-mm-ddThh:mm
"end": "2024-06-14T17:00",//yyyy-mm-ddThh:mm
"ranges": [
{
"start": "2024-06-11T09:00",//yyyy-mm-ddThh:mm
"end": "2024-06-14T17:00",//yyyy-mm-ddThh:mm
"attending-user-ids": userId,
"unavailableTimes": [
{
"userId": userId,
"durationMinutes": 480
}
]
}
],
"type": {
"color": "0000ff",
"unavailable": "1",
"id": "-2",
"name": "Paid Time Off",
"translatedName": "Paid time off"
},
"all-day": true,
"utc": true,
"attendees-can-edit": true,
"privacy": {
"type": "all"
}
}
});
const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("https://" + siteName + ".teamwork.com/calendarevents.json", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));