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 BroadcastFlow = {_id?: IdParam | undefined, user?: UserParam | undefined, deleted?: DeletedParam | undefined, createdBy?: CreatedByParam | undefined, updatedBy?: UpdatedByParam | undefined, createdAt?: CreatedAtParam | undefined, updatedAt?: UpdatedAtParam | undefined, title?: string | undefined, type?: ('scheduled' | 'uploaded' | 'sftp') | undefined, parentBroadcastFlow?: IdParam | undefined, campaign?: IdParam | undefined, broadcastTemplate?: IdParam | undefined, patientMessageTemplate?: IdParam | undefined, review?: ({user?: IdParam | undefined, status?: ('approved' | 'declined') | undefined, declinedReason?: string | undefined}) | undefined, message?: string | undefined, messageOverrides?: (Array<{text?: string | undefined, language?: string | undefined, channel?: string | undefined, subject?: string | undefined, patientMessageTemplate?: IdParam | undefined, secureChat?: boolean | undefined}>) | undefined, sendAt?: string | undefined, sentAt?: string | undefined, configuration?: ({secureChat?: boolean | undefined, contactPreference?: ('all-contacts' | 'primary-contact-only' | 'uploaded-contact-only') | undefined, simulate?: boolean | undefined, shouldReprocessFilters?: boolean | undefined}) | undefined, processingStatus?: ('pre-processing' | 'processing-upload' | 'rows-processed' | 'sending-messages' | 'success' | 'failure') | undefined, upload?: IdParam | undefined, fileUpload?: IdParam | undefined, mapping?: IdParam | undefined, rowCount?: number | undefined, stats?: ({totalMessagesSent?: number | undefined, messagesSuccess?: number | undefined, messagesFailed?: number | undefined, messagesSkipped?: number | undefined}) | undefined}; export type CreateApiBroadcastFlowsArgs = {body: BroadcastFlow}; export type CreateApiBroadcastFlowsOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create broadcast flow * * POST /broadcastFlows */ export const createApiBroadcastFlows = async (args: CreateApiBroadcastFlowsArgs, options?: CreateApiBroadcastFlowsOptions) => { 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(/\/+$/, '')}/broadcastFlows${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 };