export type GetApiV1WidgetsEventsFacilityFacilityCodeArgs = {facilityCode: string, includeInactiveWidgets?: number | undefined, limit?: number | undefined, page?: number | undefined}; export type GetApiV1WidgetsEventsFacilityFacilityCodeOptions = {baseUrl: string, https?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * List event widget GUIDs for a specific facility * * GET /v1/widgets/events/facility/{facilityCode} */ export const getApiV1WidgetsEventsFacilityFacilityCode = async (args: GetApiV1WidgetsEventsFacilityFacilityCodeArgs, options: GetApiV1WidgetsEventsFacilityFacilityCodeOptions) => { const {baseUrl, fetch: fetchFn = fetch, https} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.includeInactiveWidgets != null) query.append("includeInactiveWidgets", String(args.includeInactiveWidgets)) 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/widgets/events/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 };