export type GetApiApiCurrenciesArgs = {api_key: string, format?: ('json' | 'xml' | 'csv' | 'tsv') | undefined, callback?: string | undefined}; export type GetApiApiCurrenciesOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * List all available currencies * * GET /api/currencies */ export const getApiApiCurrencies = async (args: GetApiApiCurrenciesArgs, options: GetApiApiCurrenciesOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "currencies") if (args.api_key != null) query.append("api_key", String(args.api_key)) if (args.format != null) query.append("format", String(args.format)) if (args.callback != null) query.append("callback", String(args.callback)) const url = `${baseUrl.replace(/\/+$/, '')}/api/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 res.blob() };