export type GetApiNewsIndicatorIndicatorArgs = {indicator: string, type?: string | undefined, d1?: string | undefined, d2?: string | undefined, f?: ('json' | 'csv' | 'html') | undefined}; export type GetApiNewsIndicatorIndicatorOptions = {baseUrl: string, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * GET /news/indicator/{indicator} */ export const getApiNewsIndicatorIndicator = async (args: GetApiNewsIndicatorIndicatorArgs, options: GetApiNewsIndicatorIndicatorOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.type != null) query.append("type", String(args.type)) if (args.d1 != null) query.append("d1", String(args.d1)) if (args.d2 != null) query.append("d2", String(args.d2)) if (args.f != null) query.append("f", String(args.f)) if (OAuth2 !== undefined) query.set("c", OAuth2) const url = `${baseUrl.replace(/\/+$/, '')}/news/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 };