0
List Event Invitees
One script reply has been approved by the moderators Verified

Returns a list of Invitees for an event.

Created by hugo697 2 days ago Viewed 0 times
0
Submitted by hugo697 Bun
Verified 2 days ago
1
//native
2
type Calendly = {
3
	token: string
4
}
5

6
export async function main(
7
	auth: Calendly,
8
	uuid: string,
9
	status: 'active' | 'canceled' | undefined,
10
	sort: string | undefined,
11
	email: string | undefined,
12
	page_token: string | undefined,
13
	count: string | undefined
14
) {
15
	const url = new URL(`https://api.calendly.com/scheduled_events/${uuid}/invitees`)
16

17
	for (const [k, v] of [
18
		['status', status],
19
		['sort', sort],
20
		['email', email],
21
		['page_token', page_token],
22
		['count', count]
23
	]) {
24
		if (v !== undefined && v !== '' && k !== undefined) {
25
			url.searchParams.append(k, v)
26
		}
27
	}
28

29
	const response = await fetch(url, {
30
		method: 'GET',
31
		headers: {
32
			Authorization: 'Bearer ' + auth.token
33
		},
34
		body: undefined
35
	})
36

37
	if (!response.ok) {
38
		const text = await response.text()
39
		throw new Error(`${response.status} ${text}`)
40
	}
41

42
	return await response.json()
43
}
44