export type GetApiV2ProvidersEmployersPayrolladministrationsPayrollAdministrationIdAttachmentsofearningsreportArgs = {Authorization: string, Accept: string, payrollAdministrationId: string, reportYear: number}; export type GetApiV2ProvidersEmployersPayrolladministrationsPayrollAdministrationIdAttachmentsofearningsreportOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download attachment of earnings report * * GET /v2/providers/employers/payrolladministrations/{payrollAdministrationId}/attachmentsofearningsreport */ export const getApiV2ProvidersEmployersPayrolladministrationsPayrollAdministrationIdAttachmentsofearningsreport = async (args: GetApiV2ProvidersEmployersPayrolladministrationsPayrollAdministrationIdAttachmentsofearningsreportArgs, options?: GetApiV2ProvidersEmployersPayrolladministrationsPayrollAdministrationIdAttachmentsofearningsreportOptions) => { const {baseUrl = "https://api.loket.nl", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args.Accept != null) headers.set("Accept", String(args.Accept)) if (args.reportYear != null) query.append("reportYear", String(args.reportYear)) const url = `${baseUrl.replace(/\/+$/, '')}/v2/providers/employers/payrolladministrations/${encodeURIComponent(String(args.payrollAdministrationId))}/attachmentsofearningsreport${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.text() };