import { normalizeMeetingLocator, pickAuthInput, request } from '../core.ts'
import { asRecord, slimRecordingMeeting } from '../shape.ts'
/**
* Fetch cloud recordings for one meeting.
*
* @example
* import getZoomRecording from 'kody:@kody/zoom/recordings/get'
* const recording = await getZoomRecording({ meetingId: '11111111111' })
*/
export default async function getZoomRecording(params: Record<string, unknown> = {}) {
const auth = pickAuthInput(params)
const { meetingId } = normalizeMeetingLocator(params)
const includeFields =
typeof params.include_fields === 'string'
? params.include_fields
: typeof params.includeFields === 'string'
? params.includeFields
: undefined
const ttl = typeof params.ttl === 'number' ? params.ttl : undefined
const response = await request<Record<string, unknown>>({
...auth,
path: `/meetings/${meetingId}/recordings`,
query: {
...(includeFields ? { include_fields: includeFields } : {}),
...(ttl !== undefined ? { ttl } : {}),
},
throwOnError: true,
})
return {
...slimRecordingMeeting(asRecord(response.data)),
auth: response.auth,
}
}