export type ComplianceRequestFilters = {device_types?: (Array<'email' | 'sms'>) | undefined, latency?: number | undefined}; export type Subset = {count?: number | undefined, proportion?: number | undefined, selection?: number | undefined, type?: ('SAMPLE' | 'PARTITION') | undefined}; export type ComplianceRequest = {filters?: Array | undefined, resume_offset?: string | undefined, start?: ('EARLIEST' | 'LATEST') | undefined, subset?: Subset | undefined}; export type CreateApiApiEventsGeneralArgs = {'X-UA-Appkey': string, body: ComplianceRequest}; export type CreateApiApiEventsGeneralOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Open a compliance event stream * * POST /api/events/general */ export const createApiApiEventsGeneral = async (args: CreateApiApiEventsGeneralArgs, options?: CreateApiApiEventsGeneralOptions) => { const {baseUrl = "https://connect.urbanairship.com", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/vnd.urbanairship+x-ndjson; version=3;") if (args['X-UA-Appkey'] != null) headers.set("X-UA-Appkey", String(args['X-UA-Appkey'])) if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/events/general${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };