export type GetApiV1WidgetsEventsEventWidgetGuidArgs = {eventWidgetGuid: string, startDateTime?: string | undefined, endDateTime?: string | undefined}; export type GetApiV1WidgetsEventsEventWidgetGuidOptions = {baseUrl: string, https?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Get events * * GET /v1/widgets/events/{eventWidgetGuid} */ export const getApiV1WidgetsEventsEventWidgetGuid = async (args: GetApiV1WidgetsEventsEventWidgetGuidArgs, options: GetApiV1WidgetsEventsEventWidgetGuidOptions) => { const {baseUrl, fetch: fetchFn = fetch, https} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.startDateTime != null) query.append("startDateTime", String(args.startDateTime)) if (args.endDateTime != null) query.append("endDateTime", String(args.endDateTime)) if (https !== undefined) headers.set('authorization', `Basic ${btoa(`${https.username}:${https.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/widgets/events/${encodeURIComponent(String(args.eventWidgetGuid))}${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 };