export type GetApiAppsNameVersionsNumDownloadArgs = {name: string, num: string}; export type GetApiAppsNameVersionsNumDownloadOptions = {baseUrl?: string | undefined, AccessTokenAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download app version * * GET /apps/{name}/versions/{num}/download * * Also accepts auth: APIKeyAuth */ export const getApiAppsNameVersionsNumDownload = async (args: GetApiAppsNameVersionsNumDownloadArgs, options?: GetApiAppsNameVersionsNumDownloadOptions) => { const {baseUrl = "https://api.tower.dev/v1", fetch: fetchFn = fetch, AccessTokenAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/gzip") if (AccessTokenAuth !== undefined) headers.set('authorization', `Bearer ${AccessTokenAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/apps/${encodeURIComponent(String(args.name))}/versions/${encodeURIComponent(String(args.num))}/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() };