import {z} from 'zod' export type GetApiV1StocksTickerInvestorEventsArgs = {ticker: string, limit?: number | undefined, offset?: number | undefined, eventType?: string | undefined, includeUncaptured?: boolean | undefined}; export type GetApiV1StocksTickerInvestorEventsOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const listingNotice = z.object({status: z.string().nullable().optional(), ticker: z.string().nullable().optional(), delistedOn: z.string().nullable().optional(), successorTicker: z.string().nullable().optional()}); export const materialStatusDto = z.object({status: z.string().nullable().optional(), reason: z.string().nullable().optional(), lastAttemptAt: z.string().nullable().optional(), nextAttemptAt: z.string().nullable().optional()}); export const investorEventMaterialsDto = z.object({transcript: materialStatusDto.optional(), audio: materialStatusDto.optional(), slides: materialStatusDto.optional()}); export const investorEventDto = z.object({id: z.string().optional(), eventType: z.string().nullable().optional(), eventTypeName: z.string().nullable().optional(), title: z.string().nullable().optional(), callDate: z.string().optional(), callDateIsPeriodEnd: z.boolean().optional(), fiscalYear: z.number().int().nullable().optional(), fiscalQuarter: z.number().int().nullable().optional(), status: z.string().nullable().optional(), statusName: z.string().nullable().optional(), webcastUrl: z.string().nullable().optional(), transcriptDocumentId: z.string().nullable().optional(), earningsReleaseDocumentId: z.string().nullable().optional(), hasAudio: z.boolean().optional(), hasSlides: z.boolean().optional(), hasTranscript: z.boolean().optional(), materials: investorEventMaterialsDto.optional(), isTombstoned: z.boolean().nullable().optional(), presentationOnly: z.boolean().nullable().optional(), partialRecording: z.boolean().nullable().optional()}); export const pageMeta = z.object({limit: z.number().int().optional(), offset: z.number().int().optional(), count: z.number().int().optional(), hasMore: z.boolean().optional(), total: z.number().int().nullable().optional()}); export const investorEventDtoPagedResponse = z.object({listingNotice: listingNotice.optional(), data: z.array(investorEventDto).nullable().optional(), meta: pageMeta.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 }; /** * A company's investor events — earnings calls plus other webcast events (conferences, investor days, shareholder meetings) — newest first. Event ids feed the per-event speakers and slides endpoints. * * GET /v1/stocks/{ticker}/investor-events */ export const getApiV1StocksTickerInvestorEvents = async (args: GetApiV1StocksTickerInvestorEventsArgs, options?: GetApiV1StocksTickerInvestorEventsOptions) => { const {baseUrl = "https://api.equibles.com", fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) if (args.eventType != null) query.append("eventType", String(args.eventType)) if (args.includeUncaptured != null) query.append("includeUncaptured", String(args.includeUncaptured)) if (ApiKey !== undefined) headers.set('authorization', `Bearer ${ApiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/stocks/${encodeURIComponent(String(args.ticker))}/investor-events${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(investorEventDtoPagedResponse, await res.json()) };