export type GetApiAstrologyChartArgs = {ayanamsa: number, coordinates: string, datetime: string, chart_type: string, chart_style: string, format: string, la?: string | undefined, upagraha_position?: string | undefined}; export type GetApiAstrologyChartOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Chart * * GET /astrology/chart */ export const getApiAstrologyChart = async (args: GetApiAstrologyChartArgs, options?: GetApiAstrologyChartOptions) => { const {baseUrl = "https://api.prokerala.com/v2", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/svg+xml") if (args.ayanamsa != null) query.append("ayanamsa", String(args.ayanamsa)) if (args.coordinates != null) query.append("coordinates", String(args.coordinates)) if (args.datetime != null) query.append("datetime", String(args.datetime)) if (args.chart_type != null) query.append("chart_type", String(args.chart_type)) if (args.chart_style != null) query.append("chart_style", String(args.chart_style)) if (args.format != null) query.append("format", String(args.format)) if (args.la != null) query.append("la", String(args.la)) if (args.upagraha_position != null) query.append("upagraha_position", String(args.upagraha_position)) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/astrology/chart${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() };