export type Holiday = {id: string, name: string, occurs_on: string, starts_on: string, ends_on?: string | undefined, working?: boolean | undefined, created_at?: string | undefined, updated_at?: string | undefined, holiday_policy_id?: number | undefined, compensated_on?: string | undefined, observed_on?: string | undefined}; export type Pagination = {page?: number | undefined, pages?: number | undefined, count?: number | undefined, items?: number | undefined}; export type GetApiEmployeesEmployeeIdHolidaysArgs = {starts_on: string, ends_on: string, page?: number | undefined, body: {data?: Array | undefined, metadata?: Pagination | undefined}}; export type GetApiEmployeesEmployeeIdHolidaysOptions = {baseUrl?: string | undefined, XAPIKEY?: string | undefined, fetch?: typeof fetch | undefined}; /** * List employee holidays * * GET /employees/{employee_id}/holidays */ export const getApiEmployeesEmployeeIdHolidays = async (args: GetApiEmployeesEmployeeIdHolidaysArgs, options?: GetApiEmployeesEmployeeIdHolidaysOptions) => { const {baseUrl = "https://app.peopleforce.io/api/public/v3", fetch: fetchFn = fetch, XAPIKEY} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.starts_on != null) query.append("starts_on", String(args.starts_on)) if (args.ends_on != null) query.append("ends_on", String(args.ends_on)) if (args.page != null) query.append("page", String(args.page)) if (XAPIKEY !== undefined) headers.set("X-API-KEY", XAPIKEY) const url = `${baseUrl.replace(/\/+$/, '')}/employees/${encodeURIComponent(String(args.employee_id))}/holidays${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", 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 };