export type GetApiV1EventsEngagementViewArgs = {filter?: Array | undefined, pageSize?: number | undefined, scrollId?: string | undefined, sort?: string | undefined}; export type GetApiV1EventsEngagementViewOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Engagement View events * * GET /v1/events/engagementView */ export const getApiV1EventsEngagementView = async (args: GetApiV1EventsEngagementViewArgs, options?: GetApiV1EventsEngagementViewOptions) => { const {baseUrl = "https://app.aptrinsic.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") for (const item of args.filter ?? []) query.append("filter", String(item)) if (args.pageSize != null) query.append("pageSize", String(args.pageSize)) if (args.scrollId != null) query.append("scrollId", String(args.scrollId)) if (args.sort != null) query.append("sort", String(args.sort)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/events/engagementView${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() };