export type GetApiArticlesArticleIdDownloadArgs = {article_id: number, folder_path?: string | undefined}; export type GetApiArticlesArticleIdDownloadOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Public Article Download * * GET /articles/{article_id}/download */ export const getApiArticlesArticleIdDownload = async (args: GetApiArticlesArticleIdDownloadArgs, options?: GetApiArticlesArticleIdDownloadOptions) => { const {baseUrl = "https://api.figshare.com/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.folder_path != null) query.append("folder_path", String(args.folder_path)) const url = `${baseUrl.replace(/\/+$/, '')}/articles/${encodeURIComponent(String(args.article_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 undefined };