export type GetApiFinanceExchangeRatesCodeArgs = {code: string}; export type GetApiFinanceExchangeRatesCodeOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Exchange Rate by ID * * GET /finance/exchange-rates/{code} */ export const getApiFinanceExchangeRatesCode = async (args: GetApiFinanceExchangeRatesCodeArgs, options?: GetApiFinanceExchangeRatesCodeOptions) => { const {baseUrl = "https://api.roapp.io/v2", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/finance/exchange-rates/${encodeURIComponent(String(args.code))}${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 };