export type GetApiV1MacroEconomyIndicatorIndicatorArgs = {indicator: 'gdp' | 'gdp-per-capita' | 'treasury-yield' | 'fed-funds' | 'cpi' | 'inflation' | 'retail-sales' | 'durables' | 'unemployment' | 'payrolls', interval?: ('daily' | 'weekly' | 'monthly' | 'quarterly' | 'annual' | 'semiannual') | undefined, maturity?: ('3month' | '2year' | '5year' | '7year' | '10year' | '30year') | undefined}; export type GetApiV1MacroEconomyIndicatorIndicatorOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * US macro indicator time series (on-demand materialization) * * GET /v1/macro/economy-indicator/{indicator} */ export const getApiV1MacroEconomyIndicatorIndicator = async (args: GetApiV1MacroEconomyIndicatorIndicatorArgs, options?: GetApiV1MacroEconomyIndicatorIndicatorOptions) => { const {baseUrl = "https://api.yehangshe.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.interval != null) query.append("interval", String(args.interval)) if (args.maturity != null) query.append("maturity", String(args.maturity)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/macro/economy-indicator/${encodeURIComponent(String(args.indicator))}${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 };