export type GetApiApiCalendarCountriesArgs = {api_key: string, format?: ('json' | 'xml') | undefined, callback?: string | undefined}; export type GetApiApiCalendarCountriesOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Countries (with subdivision codes) supported by /api/calendar/holidays and /api/calendar/business-day, plus the currencies that have a settlement calendar for /api/calendar/value-date. Available on the FREE tier. * * GET /api/calendar/countries */ export const getApiApiCalendarCountries = async (args: GetApiApiCalendarCountriesArgs, options: GetApiApiCalendarCountriesOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "countries") 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/calendar/countries${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() };