export type CreateApiFilesCodeDownloadArgs = {code: string, body: {verify?: {verified: 'true', session_id: string, timestamp: string, nonce: string, account_id: string, signature: string} | undefined, id_token?: string | undefined}}; export type CreateApiFilesCodeDownloadOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * POST /files/{code}/download */ export const createApiFilesCodeDownload = async (args: CreateApiFilesCodeDownloadArgs, options?: CreateApiFilesCodeDownloadOptions) => { const {baseUrl = "https://api.sparkvault.com/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/files/${encodeURIComponent(String(args.code))}/download${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };