export type GetApiPayrollReportIdArgs = {token: string, id: number}; export type GetApiPayrollReportIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download payroll report * * GET /payroll/report/{id} */ export const getApiPayrollReportId = async (args: GetApiPayrollReportIdArgs, options?: GetApiPayrollReportIdOptions) => { const {baseUrl = "https://hurma.work/api/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.token != null) headers.set("token", String(args.token)) const url = `${baseUrl.replace(/\/+$/, '')}/payroll/report/${encodeURIComponent(String(args.id))}${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 };