import {z} from 'zod' export type GetApiCrmObjects202609MeetingsArgs = {after?: string | undefined, archived?: boolean | undefined, associations?: Array | undefined, limit?: number | undefined, properties?: Array | undefined, propertiesWithHistory?: Array | undefined}; export type GetApiCrmObjects202609MeetingsOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; export const nextPage = z.object({after: z.string(), link: z.string().optional()}); export const forwardPaging = z.object({next: nextPage.optional()}); export const previousPage = z.object({before: z.string(), link: z.string().optional()}); export const paging = z.object({next: nextPage.optional(), prev: previousPage.optional()}); export const associatedId = z.object({id: z.string(), type: z.string()}); export const collectionResponseAssociatedId = z.object({paging: paging.optional(), results: z.array(associatedId)}); export const valueWithTimestamp = z.object({sourceId: z.string().optional(), sourceLabel: z.string().optional(), sourceType: z.string(), timestamp: z.string(), updatedByUserId: z.number().int().optional(), value: z.string()}); export const publicObjectWarning = z.object({category: z.string(), context: z.record(z.string(), z.string()), message: z.string()}); export const simplePublicObjectWithAssociations = z.object({archived: z.boolean(), archivedAt: z.string().optional(), associations: z.record(z.string(), collectionResponseAssociatedId).optional(), createdAt: z.string(), id: z.string(), objectWriteTraceId: z.string().optional(), properties: z.record(z.string(), z.string()), propertiesWithHistory: z.record(z.string(), z.array(valueWithTimestamp)).optional(), updatedAt: z.string(), url: z.string().optional(), warnings: z.array(publicObjectWarning).optional()}); export const collectionResponseSimplePublicObjectWithAssociationsForwardPaging = z.object({paging: forwardPaging.optional(), results: z.array(simplePublicObjectWithAssociations)}); 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 }; /** * List * * GET /crm/objects/2026-09/meetings * * Also accepts auth: oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2, oauth2 */ export const getApiCrmObjects202609Meetings = async (args: GetApiCrmObjects202609MeetingsArgs, options?: GetApiCrmObjects202609MeetingsOptions) => { const {baseUrl = "https://api.hubapi.com", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.after != null) query.append("after", String(args.after)) if (args.archived != null) query.append("archived", String(args.archived)) for (const item of args.associations ?? []) query.append("associations", String(item)) if (args.limit != null) query.append("limit", String(args.limit)) for (const item of args.properties ?? []) query.append("properties", String(item)) for (const item of args.propertiesWithHistory ?? []) query.append("propertiesWithHistory", String(item)) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/crm/objects/2026-09/meetings${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(collectionResponseSimplePublicObjectWithAssociationsForwardPaging, await res.json()) };