export type Id = number; export type GetApiApiV1TracksTrackIdDownloadArgs = {Authorization: string, track_id: Id, version?: string | undefined}; export type GetApiApiV1TracksTrackIdDownloadOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download a track * * GET /api/v1/tracks/{track_id}/download */ export const getApiApiV1TracksTrackIdDownload = async (args: GetApiApiV1TracksTrackIdDownloadArgs, options?: GetApiApiV1TracksTrackIdDownloadOptions) => { const {baseUrl = "https://api.melod.ie", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/zip") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args.version != null) query.append("version", String(args.version)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/tracks/${encodeURIComponent(String(args.track_id))}/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() };