export type GetApiV1EarningsCalendarArgs = {days?: number | undefined, symbols?: string | undefined, importance?: number | undefined}; export type GetApiV1EarningsCalendarOptions = {baseUrl: string, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * GET /v1/earnings/calendar */ export const getApiV1EarningsCalendar = async (args: GetApiV1EarningsCalendarArgs, options: GetApiV1EarningsCalendarOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.days != null) query.append("days", String(args.days)) if (args.symbols != null) query.append("symbols", String(args.symbols)) if (args.importance != null) query.append("importance", String(args.importance)) if (ApiKey !== undefined) headers.set("X-Api-Key", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v1/earnings/calendar${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 undefined };