export type EmployeeCreateVacation = {id: string, start_date: string, end_date: string, full_day: boolean, busy_day_checking: boolean, approved: boolean, start_time?: (string | null) | undefined, end_time?: (string | null) | undefined}; export type CreateApiEmployeesVacationArgs = {token: string, 'personal-token'?: string | undefined, body: EmployeeCreateVacation}; export type CreateApiEmployeesVacationOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create absence vacation * * POST /employees/vacation */ export const createApiEmployeesVacation = async (args: CreateApiEmployeesVacationArgs, options?: CreateApiEmployeesVacationOptions) => { 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)) if (args['personal-token'] != null) headers.set("personal-token", String(args['personal-token'])) const url = `${baseUrl.replace(/\/+$/, '')}/employees/vacation${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 };