export type GetApiPayrollPayslipPdfArgs = {customer_id?: string | undefined, period?: string | undefined, run_id?: string | undefined, employee_id: string}; export type GetApiPayrollPayslipPdfOptions = {baseUrl?: string | undefined, firebaseToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download an approved payslip * * GET /payroll/payslip/pdf */ export const getApiPayrollPayslipPdf = async (args: GetApiPayrollPayslipPdfArgs, options?: GetApiPayrollPayslipPdfOptions) => { const {baseUrl = "https://api.app.lastaccountingcompany.com/portal", fetch: fetchFn = fetch, firebaseToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (args.customer_id != null) query.append("customer_id", String(args.customer_id)) if (args.period != null) query.append("period", String(args.period)) if (args.run_id != null) query.append("run_id", String(args.run_id)) if (args.employee_id != null) query.append("employee_id", String(args.employee_id)) if (firebaseToken !== undefined) headers.set('authorization', `Bearer ${firebaseToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/payroll/payslip/pdf${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() };