import {z} from 'zod' export type GetApiV1EventsEventIdSponsorsSponsorIdArgs = {eventId: string, sponsorId: string}; export type GetApiV1EventsEventIdSponsorsSponsorIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const orgEventsAppDomainApiProductEventSponsorDtosSponsorDetailsTier = z.object({tierId: z.string().optional(), tierName: z.string().optional()}); export const orgEventsAppDomainApiProductEventSponsorDtosSponsorDetailsBoothRef = z.object({boothId: z.string().optional(), boothName: z.string().optional()}); export const orgEventsAppDomainApiProductEventSponsorDtosSponsorDetails = z.object({kind: z.string().optional(), url: z.string().optional(), id: z.string().optional(), name: z.string().optional(), title: z.string().optional(), description: z.string().optional(), websiteUrl: z.string().optional(), logoUrl: z.string().optional(), email: z.string().optional(), coverImageUrl: z.string().optional(), tier: orgEventsAppDomainApiProductEventSponsorDtosSponsorDetailsTier.optional(), booth: orgEventsAppDomainApiProductEventSponsorDtosSponsorDetailsBoothRef.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 }; /** * Get sponsor details * * GET /v1/events/{eventId}/sponsors/{sponsorId} */ export const getApiV1EventsEventIdSponsorsSponsorId = async (args: GetApiV1EventsEventIdSponsorsSponsorIdArgs, options: GetApiV1EventsEventIdSponsorsSponsorIdOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v1/events/${encodeURIComponent(String(args.eventId))}/sponsors/${encodeURIComponent(String(args.sponsorId))}${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(orgEventsAppDomainApiProductEventSponsorDtosSponsorDetails, await res.json()) };