export type CreateApiExternalPayrollsArgs = {body: {company: string, period_start: string, period_end: string, payday: string, pay_frequency?: string | undefined, correction?: string | undefined, items?: (Array<{employee?: string | undefined, earnings?: (Array<{amount?: string | undefined, hours?: string | undefined, type?: string | undefined, workplace?: string | undefined, earning_code?: string | undefined}>) | undefined, reimbursements?: Array<{amount: string}> | undefined, taxes?: (Array<{tax: string, amount: string, taxable_wages?: string | undefined, gross_taxable_wages?: string | undefined}>) | undefined, benefits?: (Array<{id?: string | undefined, benefit?: string | undefined, description?: string | undefined, employee_contribution_amount?: string | undefined, company_contribution_amount?: string | undefined}>) | undefined, post_tax_deductions?: (Array<{id?: string | undefined, amount?: string | undefined, description?: string | undefined}>) | undefined}>) | undefined, contractor_payments?: (Array<{amount?: string | undefined, reimbursement_amount?: string | undefined, contractor?: string | undefined}>) | undefined, metadata?: unknown | undefined}}; export type CreateApiExternalPayrollsOptions = {baseUrl?: string | undefined, sec0?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create an external payroll * * POST /external_payrolls */ export const createApiExternalPayrolls = async (args: CreateApiExternalPayrollsArgs, options?: CreateApiExternalPayrollsOptions) => { const {baseUrl = "https://sandbox.checkhq.com", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (sec0 !== undefined) headers.set("Authorization", sec0) const url = `${baseUrl.replace(/\/+$/, '')}/external_payrolls${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 (await res.json()) as unknown };