export type GetApiV1AssetsAssetIdSegmentsCsvArgs = {'App-ID': string, 'Auth-Token': string, asset_id: string, ids?: string | undefined, query?: string | undefined, transcription_id?: string | undefined, version_id?: string | undefined, segment_type?: string | undefined, segment_color?: string | undefined, status?: string | undefined}; export type GetApiV1AssetsAssetIdSegmentsCsvOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * List of segments as CSV file * * GET /v1/assets/{asset_id}/segments/csv/ */ export const getApiV1AssetsAssetIdSegmentsCsv = async (args: GetApiV1AssetsAssetIdSegmentsCsvArgs, options: GetApiV1AssetsAssetIdSegmentsCsvOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args['App-ID'] != null) headers.set("App-ID", String(args['App-ID'])) if (args['Auth-Token'] != null) headers.set("Auth-Token", String(args['Auth-Token'])) if (args.ids != null) query.append("ids", String(args.ids)) if (args.query != null) query.append("query", String(args.query)) if (args.transcription_id != null) query.append("transcription_id", String(args.transcription_id)) if (args.version_id != null) query.append("version_id", String(args.version_id)) if (args.segment_type != null) query.append("segment_type", String(args.segment_type)) if (args.segment_color != null) query.append("segment_color", String(args.segment_color)) if (args.status != null) query.append("status", String(args.status)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/assets/${encodeURIComponent(String(args.asset_id))}/segments/csv/${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 res.text() };