export type GetApiExchangeRatesV1LiveArgs = {base: string, target?: string | undefined}; export type GetApiExchangeRatesV1LiveOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get the latest exchange rates for a given base currency. * * GET /exchange-rates/v1/live */ export const getApiExchangeRatesV1Live = async (args: GetApiExchangeRatesV1LiveArgs, options?: GetApiExchangeRatesV1LiveOptions) => { const {baseUrl = "https://api.orthogonal.com/mpp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.base != null) query.append("base", String(args.base)) if (args.target != null) query.append("target", String(args.target)) const url = `${baseUrl.replace(/\/+$/, '')}/exchange-rates/v1/live${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 };