import {z} from 'zod' export type GetApiWebAccessSessionRecordingsPublicIdDownloadArgs = {'Api-Version': 2, 'Api-Application': string, 'Api-Company': string, 'Api-Branding'?: string | undefined, publicId: string}; export type GetApiWebAccessSessionRecordingsPublicIdDownloadOptions = {baseUrl?: string | undefined, bearerToken?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiWebAccessSessionRecordingsPublicIdDownloadResponse = z.object({status: z.string(), type: z.string(), data: z.object({url: z.string().max(255)})}); 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 }; /** * WebaccessSessionRecordingDownload * * GET /web-access/session-recordings/{publicId}/download */ export const getApiWebAccessSessionRecordingsPublicIdDownload = async (args: GetApiWebAccessSessionRecordingsPublicIdDownloadArgs, options?: GetApiWebAccessSessionRecordingsPublicIdDownloadOptions) => { const {baseUrl = "https://portal.ixon.cloud:443/api", fetch: fetchFn = fetch, bearerToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['Api-Version'] != null) headers.set("Api-Version", String(args['Api-Version'])) if (args['Api-Application'] != null) headers.set("Api-Application", String(args['Api-Application'])) if (args['Api-Company'] != null) headers.set("Api-Company", String(args['Api-Company'])) if (args['Api-Branding'] != null) headers.set("Api-Branding", String(args['Api-Branding'])) if (bearerToken !== undefined) headers.set('authorization', `Bearer ${bearerToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/web-access/session-recordings/${encodeURIComponent(String(args.publicId))}/download${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(getApiWebAccessSessionRecordingsPublicIdDownloadResponse, await res.json()) };