export type GetApiTracksTrackIdStemsDownloadArgs = {track_id: string, include_parent?: boolean | undefined, user_id?: string | undefined, user_signature?: string | undefined, user_data?: string | undefined}; export type GetApiTracksTrackIdStemsDownloadOptions = {baseUrl: string, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download a track's stems as one zip * * GET /tracks/{track_id}/stems/download */ export const getApiTracksTrackIdStemsDownload = async (args: GetApiTracksTrackIdStemsDownloadArgs, options: GetApiTracksTrackIdStemsDownloadOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/zip") if (args.include_parent != null) query.append("include_parent", String(args.include_parent)) if (args.user_id != null) query.append("user_id", String(args.user_id)) if (args.user_signature != null) query.append("user_signature", String(args.user_signature)) if (args.user_data != null) query.append("user_data", String(args.user_data)) if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/tracks/${encodeURIComponent(String(args.track_id))}/stems/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 res.blob() };