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