export type ExportTimesheetRequest = {fromDate: number, toDate: number, skillNames?: Array | undefined, teamNames?: Array | undefined, locationNames?: Array | undefined, forMemberIds?: Array | undefined, lockedOnly?: boolean | undefined, validatedOnly?: boolean | undefined, withCancelled?: boolean | undefined}; export type GetApiV1PublicTimesheetsArgs = {body: ExportTimesheetRequest}; export type GetApiV1PublicTimesheetsOptions = {baseUrl?: string | undefined, basic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Get time entries (timesheet) for a specific period * * GET /v1/public/timesheets */ export const getApiV1PublicTimesheets = async (args: GetApiV1PublicTimesheetsArgs, options?: GetApiV1PublicTimesheetsOptions) => { const {baseUrl = "https://api.evolia.com", fetch: fetchFn = fetch, basic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (basic !== undefined) headers.set('authorization', `Basic ${btoa(`${basic.username}:${basic.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/public/timesheets${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 };