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