export type GetApiV1DailynumbersFacilityFacilityCodeArgs = {facilityCode: string, startDate?: string | undefined, endDate?: string | undefined, tag?: string | undefined, limit?: number | undefined, page?: number | undefined}; export type GetApiV1DailynumbersFacilityFacilityCodeOptions = {baseUrl: string, https?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Get daily numbers for a specific facility * * GET /v1/dailynumbers/facility/{facilityCode} */ export const getApiV1DailynumbersFacilityFacilityCode = async (args: GetApiV1DailynumbersFacilityFacilityCodeArgs, options: GetApiV1DailynumbersFacilityFacilityCodeOptions) => { const {baseUrl, fetch: fetchFn = fetch, https} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.startDate != null) query.append("startDate", String(args.startDate)) if (args.endDate != null) query.append("endDate", String(args.endDate)) if (args.tag != null) query.append("tag", String(args.tag)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.page != null) query.append("page", String(args.page)) if (https !== undefined) headers.set('authorization', `Basic ${btoa(`${https.username}:${https.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/dailynumbers/facility/${encodeURIComponent(String(args.facilityCode))}${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 undefined };