0
List activity log entries
One script reply has been approved by the moderators Verified

This endpoint requires an Enterprise subscription.

Returns a list of activity log entries

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

6
export async function main(
7
	auth: Calendly,
8
	organization: string | undefined,
9
	search_term: string | undefined,
10
	actor: string | undefined,
11
	sort: string | undefined,
12
	min_occurred_at: string | undefined,
13
	max_occurred_at: string | undefined,
14
	page_token: string | undefined,
15
	count: string | undefined,
16
	namespace: string | undefined,
17
	action: string | undefined
18
) {
19
	const url = new URL(`https://api.calendly.com/activity_log_entries`)
20

21
	for (const [k, v] of [
22
		['organization', organization],
23
		['search_term', search_term],
24
		['actor', actor],
25
		['sort', sort],
26
		['min_occurred_at', min_occurred_at],
27
		['max_occurred_at', max_occurred_at],
28
		['page_token', page_token],
29
		['count', count],
30
		['namespace', namespace],
31
		['action', action]
32
	]) {
33
		if (v !== undefined && v !== '' && k !== undefined) {
34
			url.searchParams.append(k, v)
35
		}
36
	}
37

38
	const response = await fetch(url, {
39
		method: 'GET',
40
		headers: {
41
			Authorization: 'Bearer ' + auth.token
42
		},
43
		body: undefined
44
	})
45

46
	if (!response.ok) {
47
		const text = await response.text()
48
		throw new Error(`${response.status} ${text}`)
49
	}
50

51
	return await response.json()
52
}
53