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