export type GetApiJadualSolatZoneArgs = {year?: number | undefined, month?: number | undefined}; export type GetApiJadualSolatZoneOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download monthly prayer timetable in PDF. * * GET /jadual_solat/{zone} */ export const getApiJadualSolatZone = async (args: GetApiJadualSolatZoneArgs, options?: GetApiJadualSolatZoneOptions) => { const {baseUrl = "https://api.waktusolat.app", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.year != null) query.append("year", String(args.year)) if (args.month != null) query.append("month", String(args.month)) const url = `${baseUrl.replace(/\/+$/, '')}/jadual_solat/${encodeURIComponent(String(args.zone))}${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() };