export type GetApiFinancialDatasetsEarningsArgs = {ticker: string, limit?: number | undefined, cursor?: string | undefined}; export type GetApiFinancialDatasetsEarningsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get the most recent earnings snapshot for a ticker. Optional change fields are returned only when available. * * GET /financial-datasets/earnings */ export const getApiFinancialDatasetsEarnings = async (args: GetApiFinancialDatasetsEarningsArgs, options?: GetApiFinancialDatasetsEarningsOptions) => { const {baseUrl = "https://api.orthogonal.com/mpp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.ticker != null) query.append("ticker", String(args.ticker)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.cursor != null) query.append("cursor", String(args.cursor)) const url = `${baseUrl.replace(/\/+$/, '')}/financial-datasets/earnings${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 };