export type SubtitleRequestSchema = {create_transcription?: boolean | undefined, delete_old_transcriptions?: boolean | undefined, priority?: (number | null) | undefined}; export type CreateApiV1AssetsAssetIdFilesFileIdSubtitlesArgs = {'Auth-Token': string, 'App-ID': string, asset_id: string, file_id: string, body: SubtitleRequestSchema}; export type CreateApiV1AssetsAssetIdFilesFileIdSubtitlesOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Create a transcode job for subtitle files * * POST /v1/assets/{asset_id}/files/{file_id}/subtitles/ */ export const createApiV1AssetsAssetIdFilesFileIdSubtitles = async (args: CreateApiV1AssetsAssetIdFilesFileIdSubtitlesArgs, options: CreateApiV1AssetsAssetIdFilesFileIdSubtitlesOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Auth-Token'] != null) headers.set("Auth-Token", String(args['Auth-Token'])) if (args['App-ID'] != null) headers.set("App-ID", String(args['App-ID'])) const url = `${baseUrl.replace(/\/+$/, '')}/v1/assets/${encodeURIComponent(String(args.asset_id))}/files/${encodeURIComponent(String(args.file_id))}/subtitles/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };