export type GetApiRampCurrenciesArgs = {provider?: string | undefined, type?: ('on-ramp' | 'off-ramp') | undefined}; export type GetApiRampCurrenciesOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * List supported fiat currencies * * GET /ramp/currencies */ export const getApiRampCurrencies = async (args: GetApiRampCurrenciesArgs, options?: GetApiRampCurrenciesOptions) => { const {baseUrl = "https://api.chainrails.io/api/v1", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.provider != null) query.append("provider", String(args.provider)) if (args.type != null) query.append("type", String(args.type)) if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/ramp/currencies${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 };