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