export type DtosHoursTracked = {employee_id: string, type: string, from_date: string, to_date: string, hours: number}; export type CreateApiVVersionAcaHoursArgs = {version: string, body: Array}; export type CreateApiVVersionAcaHoursOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * ACA hours * * POST /v{version}/aca/hours */ export const createApiVVersionAcaHours = async (args: CreateApiVVersionAcaHoursArgs, options: CreateApiVVersionAcaHoursOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v${encodeURIComponent(String(args.version))}/aca/hours${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 };