export type DateTime = string; export type GetApiCompaniesCompanyIdFilesDownloadArgs = {date?: DateTime | undefined}; export type GetApiCompaniesCompanyIdFilesDownloadOptions = {baseUrl?: string | undefined, authHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download all files for a company * * GET /companies/{companyId}/files/download */ export const getApiCompaniesCompanyIdFilesDownload = async (args: GetApiCompaniesCompanyIdFilesDownloadArgs, options?: GetApiCompaniesCompanyIdFilesDownloadOptions) => { const {baseUrl = "https://api.codat.io", fetch: fetchFn = fetch, authHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.date != null) query.append("date", String(args.date)) if (authHeader !== undefined) headers.set("Authorization", authHeader) const url = `${baseUrl.replace(/\/+$/, '')}/companies/${encodeURIComponent(String(args.companyId))}/files/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() };