export type NotificationMethod = 'email' | 'sms'; export type Lang = 'sv' | 'en' | 'de' | 'fr' | 'it' | 'es' | 'pt' | 'nl' | 'da' | 'no' | 'el' | 'fi' | 'is' | 'et' | 'lv' | 'lt' | 'cs' | 'pl' | 'hu'; export type Message = string; export type EventNotifyParticipant = {participant_id: string, method: NotificationMethod, language?: Lang | undefined, message: Message}; export type CreateApiExperimentalFlowInstancesInstanceIdNotifyParticipantsArgs = {instance_id: string, body: Array}; export type CreateApiExperimentalFlowInstancesInstanceIdNotifyParticipantsOptions = {baseUrl?: string | undefined, OAuth10?: string | undefined, fetch?: typeof fetch | undefined}; /** * Notify participants * * POST /experimental/flow/instances/{instance_id}/notify_participants * * Also accepts auth: OAuth2.0, SessionCookie + XToken */ export const createApiExperimentalFlowInstancesInstanceIdNotifyParticipants = async (args: CreateApiExperimentalFlowInstancesInstanceIdNotifyParticipantsArgs, options?: CreateApiExperimentalFlowInstancesInstanceIdNotifyParticipantsOptions) => { const {baseUrl = "https://scrive.com", fetch: fetchFn = fetch, OAuth10} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json;charset=utf-8") if (OAuth10 !== undefined) headers.set('authorization', `oauth1 ${OAuth10}`) const url = `${baseUrl.replace(/\/+$/, '')}/experimental/flow/instances/${encodeURIComponent(String(args.instance_id))}/notify_participants${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 };