Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kody/zoom

src/webinars/get.ts

24 lines · 811 B · TypeScript
import { normalizeWebinarLocator, pickAuthInput, request } from '../core.ts'
import { asRecord, slimWebinar } from '../shape.ts'

/**
 * Fetch one Zoom webinar by id or `zoom.us/w/{id}` URL.
 *
 * @example
 * import getZoomWebinar from 'kody:@kody/zoom/webinars/get'
 * const webinar = await getZoomWebinar({ webinarId: '22222222222' })
 */
export default async function getZoomWebinar(params: Record<string, unknown> = {}) {
	const auth = pickAuthInput(params)
	const { webinarId, occurrenceId } = normalizeWebinarLocator(params)
	const response = await request<Record<string, unknown>>({
		...auth,
		path: `/webinars/${webinarId}`,
		query: occurrenceId ? { occurrence_id: occurrenceId } : undefined,
		throwOnError: true,
	})
	return {
		...slimWebinar(asRecord(response.data)),
		auth: response.auth,
	}
}