import {z} from 'zod' export type IntectWebAPIControllersTimeEntryControllerTimeEntryRecordsRequest = {TimeEntryStatusIds?: Array | undefined, TimeEntryRecordIds?: Array | undefined, PeriodId?: number | undefined, CycleId?: number | undefined, EmploymentId?: number | undefined, FromDate?: string | undefined, ToDate?: string | undefined, ManagerId?: number | undefined, DepartmentId?: number | undefined}; export type CreateApiApiTimeentryEligibleEmploymentSumsRequestArgs = {body: IntectWebAPIControllersTimeEntryControllerTimeEntryRecordsRequest}; export type CreateApiApiTimeentryEligibleEmploymentSumsRequestOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; export const intectBusinessLogicTimeEntryTimeEntryLogicTimeEntryRecordEmployeeSumsResult = z.object({UserEmploymentId: z.number().int().optional(), FullName: z.string().optional(), Days: z.number().optional(), Hours: z.number().optional(), ManagerName: z.string().optional(), KilometersDriven: z.number().optional(), DepartmentName: z.string().optional(), Dimension1Value: z.string().optional(), Dimension2Value: z.string().optional(), Dimension3Value: z.string().optional(), Title: z.string().optional(), Template: z.string().optional()}); export const createApiApiTimeentryEligibleEmploymentSumsRequestResponse = z.array(intectBusinessLogicTimeEntryTimeEntryLogicTimeEntryRecordEmployeeSumsResult); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Retrieves a list of sums based upon time entry records that you can approve which match the provided request. * * POST /api/timeentry/eligible/employment/sums/request * * Also accepts auth: ApiKey */ export const createApiApiTimeentryEligibleEmploymentSumsRequest = async (args: CreateApiApiTimeentryEligibleEmploymentSumsRequestArgs, options?: CreateApiApiTimeentryEligibleEmploymentSumsRequestOptions) => { const {baseUrl = "https://api.intect.app", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/timeentry/eligible/employment/sums/request${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 validateResponse(createApiApiTimeentryEligibleEmploymentSumsRequestResponse, await res.json()) };