import {z} from 'zod' export type GetApiV2BookingsBookingUidAttendeesArgs = {'cal-api-version': string, bookingUid: string, Authorization: string}; export type GetApiV2BookingsBookingUidAttendeesOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const bookingAttendeeWithId20240813 = z.object({name: z.string(), email: z.string(), displayEmail: z.string(), timeZone: z.string(), language: z.enum(["ar", "ca", "de", "es", "eu", "he", "id", "ja", "lv", "pl", "ro", "sr", "th", "vi", "az", "cs", "el", "es-419", "fi", "hr", "it", "km", "nl", "pt", "ru", "sv", "tr", "zh-CN", "bg", "da", "en", "et", "fr", "hu", "iw", "ko", "no", "pt-BR", "sk", "ta", "uk", "zh-TW", "bn"]).optional(), absent: z.boolean(), phoneNumber: z.string().optional(), id: z.number()}); export const getBookingAttendeesOutput20240813 = z.object({status: z.enum(["success", "error"]), data: z.array(bookingAttendeeWithId20240813)}); 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 }; /** * Get all attendees for a booking * * GET /v2/bookings/{bookingUid}/attendees */ export const getApiV2BookingsBookingUidAttendees = async (args: GetApiV2BookingsBookingUidAttendeesArgs, options: GetApiV2BookingsBookingUidAttendeesOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['cal-api-version'] != null) headers.set("cal-api-version", String(args['cal-api-version'])) if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) const url = `${baseUrl.replace(/\/+$/, '')}/v2/bookings/${encodeURIComponent(String(args.bookingUid))}/attendees${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(getBookingAttendeesOutput20240813, await res.json()) };