import { isConfirmed, isDryRun, normalizeMeetingLocator, pickAuthInput, request } from '../core.ts' import { buildMeetingBody } from '../shape.ts' /** * Update a Zoom meeting. * * Pass `dryRun: true` to preview the request. Live updates require `confirm: true`. * * @example * import updateZoomMeeting from 'kody:@kody/zoom/meetings/update' * const preview = await updateZoomMeeting({ * meetingId: '11111111111', * topic: 'Updated example meeting', * dryRun: true, * }) */ export default async function updateZoomMeeting(params: Record = {}) { const auth = pickAuthInput(params) const { meetingId, occurrenceId } = normalizeMeetingLocator(params) const body = buildMeetingBody(params) if (Object.keys(body).length === 0) { throw new Error('Provide at least one meeting field to update (topic, start_time, duration, …).') } if (isDryRun(params)) { return { dryRun: true, wouldUpdate: true, meetingId, occurrenceId: occurrenceId ?? null, path: `/meetings/${meetingId}`, body, auth, } } if (!isConfirmed(params)) { throw new Error( `Updating meeting ${meetingId} requires dryRun: true (preview) or confirm: true (live write).`, ) } const response = await request>({ ...auth, method: 'PATCH', path: `/meetings/${meetingId}`, query: occurrenceId ? { occurrence_id: occurrenceId } : undefined, body, throwOnError: true, confirm: true, }) return { ok: true, meetingId, status: response.status, auth: response.auth, } }