export type CallId = string; export type CreateApiWhatsappAcceptArgs = {body: {callId: CallId, sdp: string, sdpType: string, reconnect?: boolean | undefined, deviceId?: string | undefined}}; export type CreateApiWhatsappAcceptOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Accept incoming call * * POST /whatsapp/accept */ export const createApiWhatsappAccept = async (args: CreateApiWhatsappAcceptArgs, options?: CreateApiWhatsappAcceptOptions) => { const {baseUrl = "https://public.doubletick.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/whatsapp/accept${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 };