import {z} from 'zod' export type RcwEmailModel = string; export type RcwDomainUserModel = {userId: string, accountId: string, domain: 'pbx' | 'ilm'}; export type RcwRoleEnum = 'Panelist' | 'CoHost' | 'Host' | 'Attendee'; export type RcwInviteeTypeEnum = 'User' | 'Room'; export type AddInviteeRequest = {firstName?: string | undefined, lastName?: string | undefined, email?: RcwEmailModel | undefined, jobTitle?: string | undefined, linkedUser?: RcwDomainUserModel | undefined, role: RcwRoleEnum, type?: RcwInviteeTypeEnum | undefined, sendInvite?: boolean | undefined}; export type RcwResourceIdModel = {id?: string | undefined}; export type BulkUpdateInviteesRequest = {addedInvitees?: Array | undefined, updatedInvitees?: (Array<{id?: string | undefined, firstName?: string | undefined, lastName?: string | undefined, email?: RcwEmailModel | undefined, jobTitle?: string | undefined, role: RcwRoleEnum, type?: RcwInviteeTypeEnum | undefined, sendInvite?: boolean | undefined}>) | undefined, deletedInvitees?: Array | undefined}; export type PatchApiWebinarConfigurationV1WebinarsWebinarIdSessionsSessionIdInviteesArgs = {body: BulkUpdateInviteesRequest}; export type PatchApiWebinarConfigurationV1WebinarsWebinarIdSessionsSessionIdInviteesOptions = {baseUrl?: string | undefined, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; export const rcwEmailModel = z.string().min(1).max(256); export const rcwDomainUserModel = z.object({userId: z.string().max(256), accountId: z.string().max(256), domain: z.enum(["pbx", "ilm"])}); export const rcwRoleEnum = z.enum(["Panelist", "CoHost", "Host", "Attendee"]); export const rcwInviteeTypeEnum = z.enum(["User", "Room"]); export const inviteeResource = z.object({id: z.string().min(1).max(20).optional(), creationTime: z.string(), lastModifiedTime: z.string(), firstName: z.string().max(64).optional(), lastName: z.string().max(64).optional(), email: rcwEmailModel.optional(), jobTitle: z.string().max(64).optional(), linkedUser: rcwDomainUserModel.optional(), role: rcwRoleEnum, type: rcwInviteeTypeEnum.optional(), sendInvite: z.boolean().optional(), joinUri: z.string().min(5).max(256).optional(), phoneParticipantCode: z.string().min(1).max(12).optional()}); export const rcwResourceIdModel = z.object({id: z.string().min(1).max(20).optional()}); export const bulkUpdateInviteesResponse = z.object({addedInvitees: z.array(inviteeResource).optional(), updatedInvitees: z.array(inviteeResource).optional(), deletedInvitees: z.array(rcwResourceIdModel).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 }; /** * Bulk Add/Delete Session Invitees * * PATCH /webinar/configuration/v1/webinars/{webinarId}/sessions/{sessionId}/invitees */ export const patchApiWebinarConfigurationV1WebinarsWebinarIdSessionsSessionIdInvitees = async (args: PatchApiWebinarConfigurationV1WebinarsWebinarIdSessionsSessionIdInviteesArgs, options?: PatchApiWebinarConfigurationV1WebinarsWebinarIdSessionsSessionIdInviteesOptions) => { const {baseUrl = "https://platform.ringcentral.com", fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/webinar/configuration/v1/webinars/${encodeURIComponent(String(args.webinarId))}/sessions/${encodeURIComponent(String(args.sessionId))}/invitees${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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(bulkUpdateInviteesResponse, await res.json()) };