//native
type Calendly = {
token: string
}
export async function main(
auth: Calendly,
organization: string | undefined,
search_term: string | undefined,
actor: string | undefined,
sort: string | undefined,
min_occurred_at: string | undefined,
max_occurred_at: string | undefined,
page_token: string | undefined,
count: string | undefined,
namespace: string | undefined,
action: string | undefined
) {
const url = new URL(`https://api.calendly.com/activity_log_entries`)
for (const [k, v] of [
['organization', organization],
['search_term', search_term],
['actor', actor],
['sort', sort],
['min_occurred_at', min_occurred_at],
['max_occurred_at', max_occurred_at],
['page_token', page_token],
['count', count],
['namespace', namespace],
['action', action]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: 'Bearer ' + auth.token
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 16 days ago