export type EmployeeChangeVacationBalance = {id: string, days: string, action: string, comment: string}; export type CreateApiEmployeesVacationBalanceArgs = {token: string, body: EmployeeChangeVacationBalance}; export type CreateApiEmployeesVacationBalanceOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Change absence vacation balance * * POST /employees/vacation/balance */ export const createApiEmployeesVacationBalance = async (args: CreateApiEmployeesVacationBalanceArgs, options?: CreateApiEmployeesVacationBalanceOptions) => { const {baseUrl = "https://hurma.work/api/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.token != null) headers.set("token", String(args.token)) const url = `${baseUrl.replace(/\/+$/, '')}/employees/vacation/balance${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 undefined };