import {z} from 'zod' export type GettyImagesServicesConnectPublicControllersEventsSingleEventDetailFieldValues = 'id' | 'child_event_count' | 'child_events' | 'editorial_segments' | 'hero_image' | 'image_count' | 'keywords' | 'location' | 'name' | 'start_date' | 'type'; export type GetApiV3EventsIdArgs = {'Accept-Language'?: string | undefined, id: number, fields?: Array | undefined}; export type GetApiV3EventsIdOptions = {baseUrl: string, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const gettyImagesServicesConnectPublicModelsHeroImageDisplaySize = z.object({name: z.string().nullable().optional(), is_watermarked: z.boolean().optional(), uri: z.string().nullable().optional()}); export const gettyImagesServicesConnectPublicModelsHeroImage = z.object({id: z.string().nullable().optional(), display_sizes: z.array(gettyImagesServicesConnectPublicModelsHeroImageDisplaySize).nullable().optional()}); export const gettyImagesServicesConnectPublicModelsEventsEventKeyword = z.object({keyword_id: z.string().nullable().optional(), text: z.string().nullable().optional(), type: z.string().nullable().optional(), relevance: z.number().int().nullable().optional()}); export const gettyImagesServicesConnectPublicModelsLocationEvent = z.object({city: z.string().nullable().optional(), country: z.string().nullable().optional(), state_province: z.string().nullable().optional(), venue: z.string().nullable().optional()}); export const gettyImagesServicesConnectPublicModelsEventsChildEvent = z.object({editorial_segments: z.array(z.string()).nullable().optional(), hero_image: gettyImagesServicesConnectPublicModelsHeroImage.optional(), id: z.number().int().optional(), image_count: z.number().int().nullable().optional(), keywords: z.array(gettyImagesServicesConnectPublicModelsEventsEventKeyword).nullable().optional(), location: gettyImagesServicesConnectPublicModelsLocationEvent.optional(), name: z.string().nullable().optional(), start_date: z.string().nullable().optional(), type: z.string().nullable().optional()}); export const gettyImagesServicesConnectPublicModelsEventsEvent = z.object({child_event_count: z.number().int().nullable().optional(), child_events: z.array(gettyImagesServicesConnectPublicModelsEventsChildEvent).nullable().optional(), editorial_segments: z.array(z.string()).nullable().optional(), hero_image: gettyImagesServicesConnectPublicModelsHeroImage.optional(), id: z.number().int().optional(), image_count: z.number().int().nullable().optional(), keywords: z.array(gettyImagesServicesConnectPublicModelsEventsEventKeyword).nullable().optional(), location: gettyImagesServicesConnectPublicModelsLocationEvent.optional(), name: z.string().nullable().optional(), start_date: z.string().nullable().optional(), type: z.string().nullable().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 metadata for a single event * * GET /v3/events/{id} * * Also accepts auth: OAuth2 */ export const getApiV3EventsId = async (args: GetApiV3EventsIdArgs, options: GetApiV3EventsIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['Accept-Language'] != null) headers.set("Accept-Language", String(args['Accept-Language'])) if (args.fields != null) query.append("fields", args.fields.join(',')) if (ApiKey !== undefined) headers.set("Api-Key", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v3/events/${encodeURIComponent(String(args.id))}${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(gettyImagesServicesConnectPublicModelsEventsEvent, await res.json()) };