//native
type Calendly = {
token: string
}
export async function main(
auth: Calendly,
body: {
name: string
host: string
co_hosts?: string[]
duration: number
timezone?: string
date_setting:
| { type: 'date_range'; start_date: string; end_date: string }
| { type: 'days_in_future'; days: number; only_weekdays: false | true }
| {}
location?:
| { kind: 'custom'; location?: string }
| { kind: 'google_conference' }
| { kind: 'gotomeeting_conference' }
| { kind: 'physical'; location?: string; additional_info?: string }
| { kind: 'inbound_call'; phone_number: string; additional_info?: string }
| { kind: 'ask_invitee'; location?: string }
| { kind: 'microsoft_teams_conference' }
| { kind: 'outbound_call' }
| { kind: 'webex_conference' }
| { kind: 'zoom_conference' }
}
) {
const url = new URL(`https://api.calendly.com/one_off_event_types`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.token
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 51 days ago