export type GetApiV1DispersionArgs = {index?: string | undefined, symbols?: string | undefined, weights?: string | undefined, horizon_days?: number | undefined}; export type GetApiV1DispersionOptions = {baseUrl: string, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * GET /v1/dispersion */ export const getApiV1Dispersion = async (args: GetApiV1DispersionArgs, options: GetApiV1DispersionOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.index != null) query.append("index", String(args.index)) if (args.symbols != null) query.append("symbols", String(args.symbols)) if (args.weights != null) query.append("weights", String(args.weights)) if (args.horizon_days != null) query.append("horizon_days", String(args.horizon_days)) if (ApiKey !== undefined) headers.set("X-Api-Key", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v1/dispersion${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 };