export type GetApiRestApiV1ProjectsProjectIdEconomicCalendarIcsArgs = {projectId: string, token: string}; export type GetApiRestApiV1ProjectsProjectIdEconomicCalendarIcsOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * iCal subscription feed * * GET /rest/api/v1/projects/{projectId}/economicCalendar.ics */ export const getApiRestApiV1ProjectsProjectIdEconomicCalendarIcs = async (args: GetApiRestApiV1ProjectsProjectIdEconomicCalendarIcsArgs, options?: GetApiRestApiV1ProjectsProjectIdEconomicCalendarIcsOptions) => { const {baseUrl = "https://api.metacopier.io", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/calendar;charset=UTF-8") if (args.token != null) query.append("token", String(args.token)) if (ApiKeyAuth !== undefined) headers.set("X-API-KEY", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/rest/api/v1/projects/${encodeURIComponent(String(args.projectId))}/economicCalendar.ics${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.text() };