import {z} from 'zod' export type GetApiConferenceRoomsIdArgs = {id: string}; export type GetApiConferenceRoomsIdOptions = {baseUrl?: string | undefined, bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiConferenceRoomsIdResponse = z.object({id: z.string().optional(), extension_number: z.string().min(3).max(64).optional(), mode: z.enum(["AUDIO", "VIDEO"]).optional(), control: z.enum(["FREE", "MASTER"]).optional(), height: z.number().int().gte(144).lte(1920).optional(), width: z.number().int().gte(144).lte(1920).optional(), bitrate: z.number().int().gte(128).lte(10240).optional(), framerate: z.number().int().gte(5).lte(30).optional(), layout: z.enum(["LAYOUT0", "LAYOUT1", "LAYOUT2", "LAYOUT3", "LAYOUT4", "LAYOUT6", "LAYOUT9"]).optional(), subject: z.string().min(1).max(64).optional(), language: z.string().optional(), capacity: z.number().int().gte(1).lte(200).optional(), admin_pin: z.string().min(3).max(6).optional(), room_pin: z.string().min(3).max(6).optional(), enable_recording: z.boolean().optional(), enable_prompt: z.boolean().optional(), timezone: z.string().optional(), created_at: z.string().optional(), scheduled_start_at: z.string().optional(), scheduled_end_at: z.string().optional(), numbers: z.string().max(128).optional(), internal_invitees: z.array(z.string()).optional(), external_invitees: z.string().optional(), domain: z.string().min(1).max(280).optional(), sbc_host: z.string().optional(), sbc_port: z.number().int().gte(0).lte(65535).optional(), token: z.string().optional(), outbound_caller_ids: z.array(z.object({provider_id: z.string().optional(), caller_id: z.string().min(1).max(64).optional(), description: z.string().max(1024).optional()})).optional(), custom_options: z.string().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Retrieve a conference room * * GET /conference_rooms/{id} */ export const getApiConferenceRoomsId = async (args: GetApiConferenceRoomsIdArgs, options?: GetApiConferenceRoomsIdOptions) => { const {baseUrl = "https://HOSTNAME:8887/api", fetch: fetchFn = fetch, bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (bearer !== undefined) headers.set('authorization', `Bearer ${bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/conference_rooms/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(getApiConferenceRoomsIdResponse, await res.json()) };