export type GetApiVedicCalendarIcsArgs = {year: number, latitude: number, longitude: number, timezone?: string | undefined, include?: string | undefined, tradition?: ('smarta' | 'vaishnava') | undefined, ayanamsaId?: number | undefined, fields?: string | undefined, precision?: number | undefined}; export type GetApiVedicCalendarIcsOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Hindu calendar: ICS feed of festivals and vrats * * GET /vedic/calendar/ics */ export const getApiVedicCalendarIcs = async (args: GetApiVedicCalendarIcsArgs, options?: GetApiVedicCalendarIcsOptions) => { const {baseUrl = "https://api.astroway.info/v1", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/calendar") if (args.year != null) query.append("year", String(args.year)) if (args.latitude != null) query.append("latitude", String(args.latitude)) if (args.longitude != null) query.append("longitude", String(args.longitude)) if (args.timezone != null) query.append("timezone", String(args.timezone)) if (args.include != null) query.append("include", String(args.include)) if (args.tradition != null) query.append("tradition", String(args.tradition)) if (args.ayanamsaId != null) query.append("ayanamsaId", String(args.ayanamsaId)) if (args.fields != null) query.append("fields", String(args.fields)) if (args.precision != null) query.append("precision", String(args.precision)) if (ApiKeyAuth !== undefined) headers.set("X-Api-Key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/vedic/calendar/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() };