import {z} from 'zod' export type GetApiApiV2CoreUserCalendarEventsArgs = {Authorization: string, start?: number | undefined, limit?: number | undefined, queryLimit?: string | undefined, creatorUserId?: string | undefined, positionId?: string | undefined, profileId?: string | undefined, candidateEmail?: string | undefined, meetingTime?: string | undefined, assigneeUserId?: string | undefined, status?: string | undefined, eventType?: string | undefined, entityIds?: string | undefined, exclude?: string | undefined, keyList?: string | undefined}; export type GetApiApiV2CoreUserCalendarEventsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const registerButton = z.object({textColor: z.string().nullable().optional(), backgroundColor: z.string().nullable().optional(), text: z.string().nullable().optional()}); export const homePageBanner = z.object({useImage: z.boolean().nullable().optional(), image: z.string().nullable().optional(), title: z.string().nullable().optional()}); export const plannedEvent = z.object({createdAt: z.number().int().nullable().optional(), isCancelled: z.boolean().nullable().optional(), eventSpeakers: z.array(z.string()).nullable().optional(), activeRegistrations: z.string().nullable().optional(), registerButton: registerButton.nullable().optional(), eventTeamDataJson: z.object({}).nullable().optional(), eventBucket: z.string().nullable().optional(), address: z.string().nullable().optional(), eventCustomFieldsJson: z.object({}).nullable().optional(), eventType: z.string().nullable().optional(), institution: z.string().nullable().optional(), selectedTimezone: z.string().nullable().optional(), name: z.string(), homePageBanner: homePageBanner.nullable().optional(), eventLocationType: z.string().nullable().optional(), id: z.string().nullable().optional(), plannedEventEncId: z.string().nullable().optional(), parentId: z.string().nullable().optional(), venue: z.string().nullable().optional(), endTimestamp: z.number().int().nullable(), isPublished: z.boolean().nullable().optional(), eventLandingPage: z.string().nullable().optional(), status: z.string().nullable().optional(), createdBy: z.string().nullable().optional(), eventCategory: z.string().nullable().optional(), startTimestamp: z.number().int().nullable(), when: z.string().nullable().optional(), description: z.string().nullable().optional()}); export const userCalendarEventsSchema = z.object({createdAt: z.number().int().nullable().optional(), plannedEventId: z.number().int().nullable().optional(), assigneeUserId: z.string().nullable().optional(), profileId: z.string().nullable().optional(), eventType: z.string().nullable().optional(), meetingTime: z.number().int().nullable().optional(), creatorUserId: z.string().nullable().optional(), interviewSlotsJson: z.object({}).nullable().optional(), templateId: z.number().int().nullable().optional(), id: z.number().int().nullable().optional(), candidateEmail: z.string().nullable().optional(), durationMinutes: z.number().int().nullable().optional(), updatedAt: z.number().int().nullable().optional(), plannedEvent: plannedEvent.nullable().optional(), status: z.string().nullable().optional(), timezone: z.string().nullable().optional(), positionId: z.number().int().nullable().optional()}); export const metaSchema = z.object({totalCount: z.number().int().nullable().optional(), pageTotalCount: z.number().int().nullable().optional(), pageStartIndex: z.number().int().nullable().optional()}); export const getApiApiV2CoreUserCalendarEventsResponse = z.object({data: z.array(userCalendarEventsSchema).optional(), meta: metaSchema.optional()}); 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 }; /** * List User Calendar Events * * GET /api/v2/core/user-calendar-events */ export const getApiApiV2CoreUserCalendarEvents = async (args: GetApiApiV2CoreUserCalendarEventsArgs, options?: GetApiApiV2CoreUserCalendarEventsOptions) => { const {baseUrl = "https://apiv2.eightfold.ai", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args.start != null) query.append("start", String(args.start)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.queryLimit != null) query.append("queryLimit", String(args.queryLimit)) if (args.creatorUserId != null) query.append("creatorUserId", String(args.creatorUserId)) if (args.positionId != null) query.append("positionId", String(args.positionId)) if (args.profileId != null) query.append("profileId", String(args.profileId)) if (args.candidateEmail != null) query.append("candidateEmail", String(args.candidateEmail)) if (args.meetingTime != null) query.append("meetingTime", String(args.meetingTime)) if (args.assigneeUserId != null) query.append("assigneeUserId", String(args.assigneeUserId)) if (args.status != null) query.append("status", String(args.status)) if (args.eventType != null) query.append("eventType", String(args.eventType)) if (args.entityIds != null) query.append("entityIds", String(args.entityIds)) if (args.exclude != null) query.append("exclude", String(args.exclude)) if (args.keyList != null) query.append("keyList", String(args.keyList)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/core/user-calendar-events${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 validateResponse(getApiApiV2CoreUserCalendarEventsResponse, await res.json()) };