export type GetApiApiCalendarValueDateArgs = {api_key: string, pair: string, trade_date?: string | undefined, format?: ('json' | 'xml') | undefined, callback?: string | undefined}; export type GetApiApiCalendarValueDateOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * FX spot value (settlement) date for a currency pair and trade date. Pro subscription required. * * GET /api/calendar/value-date */ export const getApiApiCalendarValueDate = async (args: GetApiApiCalendarValueDateArgs, options: GetApiApiCalendarValueDateOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "eurusd_easter") if (args.api_key != null) query.append("api_key", String(args.api_key)) if (args.pair != null) query.append("pair", String(args.pair)) if (args.trade_date != null) query.append("trade_date", String(args.trade_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/value-date${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() };