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