export type GetApiCompanyWorkScheduleDaysArgs = {page?: number | undefined, date_from: string, date_to: string, employees?: Array | undefined, branches?: Array | undefined, types?: ('working' | 'non_working') | undefined}; export type GetApiCompanyWorkScheduleDaysOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Work Schedule for a Date Range * * GET /company/work-schedule/days */ export const getApiCompanyWorkScheduleDays = async (args: GetApiCompanyWorkScheduleDaysArgs, options?: GetApiCompanyWorkScheduleDaysOptions) => { const {baseUrl = "https://api.roapp.io/v2", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.page != null) query.append("page", String(args.page)) if (args.date_from != null) query.append("date_from", String(args.date_from)) if (args.date_to != null) query.append("date_to", String(args.date_to)) for (const item of args.employees ?? []) query.append("employees", String(item)) for (const item of args.branches ?? []) query.append("branches", String(item)) if (args.types != null) query.append("types", String(args.types)) if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/company/work-schedule/days${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 undefined };