export type GetApiExchangeRatesV1HistoricalArgs = {base: string, target?: string | undefined, date: string}; export type GetApiExchangeRatesV1HistoricalOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get exchange rates for a specific historical date. * * GET /exchange-rates/v1/historical */ export const getApiExchangeRatesV1Historical = async (args: GetApiExchangeRatesV1HistoricalArgs, options?: GetApiExchangeRatesV1HistoricalOptions) => { 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)) if (args.date != null) query.append("date", String(args.date)) const url = `${baseUrl.replace(/\/+$/, '')}/exchange-rates/v1/historical${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 };