export type GetApiV1AgentNavArgs = {addresses: string, waitForSync?: boolean | undefined, currency?: string | undefined}; export type GetApiV1AgentNavOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get the net asset value of a given address * * GET /v1/agent/nav */ export const getApiV1AgentNav = async (args: GetApiV1AgentNavArgs, options: GetApiV1AgentNavOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.addresses != null) query.append("addresses", String(args.addresses)) if (args.waitForSync != null) query.append("waitForSync", String(args.waitForSync)) if (args.currency != null) query.append("currency", String(args.currency)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/agent/nav${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 };