export type IdParam = string; export type UserParam = string; export type DeletedParam = number; export type CreatedByParam = string; export type UpdatedByParam = string; export type CreatedAtParam = string; export type UpdatedAtParam = string; export type BroadcastEvent = {_id?: IdParam | undefined, user?: UserParam | undefined, deleted?: DeletedParam | undefined, createdBy?: CreatedByParam | undefined, updatedBy?: UpdatedByParam | undefined, createdAt?: CreatedAtParam | undefined, updatedAt?: UpdatedAtParam | undefined, broadcastFlow?: IdParam | undefined, patient?: IdParam | undefined, statuses?: (Array<{step?: ('RowProcess' | 'MessageProcess') | undefined, status?: ('in-progress' | 'success' | 'failure' | 'skipped') | undefined, stepCreatedAt?: string | undefined, stepUpdatedAt?: string | undefined, patient?: IdParam | undefined, retryCount?: number | undefined}>) | undefined, row?: number | undefined, rowRecord?: {[key: string]: string} | undefined}; export type CreateApiBroadcastEventsArgs = {body: BroadcastEvent}; export type CreateApiBroadcastEventsOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create broadcast event * * POST /broadcastEvents */ export const createApiBroadcastEvents = async (args: CreateApiBroadcastEventsArgs, options?: CreateApiBroadcastEventsOptions) => { const {baseUrl = "https://api.lumahealth.io/api/v2", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/broadcastEvents${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 undefined };