export type GetApiHistoricalStockquoteTickerArgs = {ticker: string, date?: string | undefined, time?: string | undefined}; export type GetApiHistoricalStockquoteTickerOptions = {baseUrl: string, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * GET /historical/stockquote/{ticker} */ export const getApiHistoricalStockquoteTicker = async (args: GetApiHistoricalStockquoteTickerArgs, options: GetApiHistoricalStockquoteTickerOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.date != null) query.append("date", String(args.date)) if (args.time != null) query.append("time", String(args.time)) if (ApiKey !== undefined) headers.set("X-Api-Key", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/historical/stockquote/${encodeURIComponent(String(args.ticker))}${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 };