export type GetApiApiCalendarBusinessDayArgs = {api_key: string, country?: string | undefined, subdiv?: string | undefined, currency?: string | undefined, date?: string | undefined, format?: ('json' | 'xml') | undefined, callback?: string | undefined}; export type GetApiApiCalendarBusinessDayOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Is a date a business day in a country (optionally a subdivision) or on a currency's settlement calendar? Returns the holiday name if any, and the previous/next business days. Respects non-Saturday/Sunday weekends (e.g. Friday-Saturday in Saudi Arabia). Available on the FREE tier. Reference only. * * GET /api/calendar/business-day */ export const getApiApiCalendarBusinessDay = async (args: GetApiApiCalendarBusinessDayArgs, options: GetApiApiCalendarBusinessDayOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "target_christmas") if (args.api_key != null) query.append("api_key", String(args.api_key)) if (args.country != null) query.append("country", String(args.country)) if (args.subdiv != null) query.append("subdiv", String(args.subdiv)) if (args.currency != null) query.append("currency", String(args.currency)) if (args.date != null) query.append("date", String(args.date)) 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/business-day${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() };