import {z} from 'zod' export type OrgEventsAppDomainApiProductEventSpeakerDtosSpeakerCreateRequest = {firstName: string, lastName: string, company?: string | undefined, designation?: string | undefined, bio?: string | undefined, linkedInProfile?: string | undefined, twitterProfile?: string | undefined, facebookProfile?: string | undefined, websiteUrl?: string | undefined, externalRefId?: string | undefined, email: string}; export type CreateApiV1EventsEventIdSpeakersArgs = {eventId: string, body: OrgEventsAppDomainApiProductEventSpeakerDtosSpeakerCreateRequest}; export type CreateApiV1EventsEventIdSpeakersOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const orgEventsAppDomainApiProductEventSpeakerDtosSpeakerDetailsProfile = z.object({firstName: z.string().optional(), lastName: z.string().optional(), bio: z.string().optional(), company: z.string().optional(), designation: z.string().optional(), headline: z.string().optional(), picUrl: z.string().optional()}); export const orgEventsAppDomainApiProductEventSpeakerDtosSpeakerDetailsSocialLinks = z.object({linkedInProfile: z.string().optional(), twitterProfile: z.string().optional(), facebookProfile: z.string().optional(), websiteUrl: z.string().optional()}); export const orgEventsAppDomainApiProductEventSpeakerDtosSpeakerDetailsSessionRef = z.object({sessionId: z.string().optional(), url: z.string().optional()}); export const orgEventsAppDomainApiProductEventSpeakerDtosSpeakerDetails = z.object({kind: z.string().optional(), url: z.string().optional(), id: z.string().optional(), speakerOrder: z.number().int().optional(), profile: orgEventsAppDomainApiProductEventSpeakerDtosSpeakerDetailsProfile.optional(), socialLinks: orgEventsAppDomainApiProductEventSpeakerDtosSpeakerDetailsSocialLinks.optional(), sessions: z.array(orgEventsAppDomainApiProductEventSpeakerDtosSpeakerDetailsSessionRef).optional(), externalRefId: z.string().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 }; /** * Create a new speaker * * POST /v1/events/{eventId}/speakers */ export const createApiV1EventsEventIdSpeakers = async (args: CreateApiV1EventsEventIdSpeakersArgs, options: CreateApiV1EventsEventIdSpeakersOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v1/events/${encodeURIComponent(String(args.eventId))}/speakers${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(orgEventsAppDomainApiProductEventSpeakerDtosSpeakerDetails, await res.json()) };