export type CreateApiConnectionsPhoneNumberImportSessionArgs = {phoneNumber: string, body: {session: {noiseCandidates: Array<{private: string, public: string}>, identityKey: {private: string, public: string}, registrationId: number, advSecretKey: string, account: {details: string, accountSignatureKey: string, accountSignature: string, deviceSignature: string}, id: string, lid?: string | undefined, platform?: string | undefined, signedPreKey?: {keyId: number, private: string, public: string, signature: string} | undefined, pushName?: string | undefined, routingInfo?: string | undefined}, candidateIndex?: number | undefined, clientName?: string | undefined, webhookUrl: string, webhookVerifyToken: string, includeMedia?: boolean | undefined, syncFullHistory?: boolean | undefined, groupsEnabled?: boolean | undefined, autoPresenceSubscribe?: boolean | undefined}}; export type CreateApiConnectionsPhoneNumberImportSessionOptions = {baseUrl?: string | undefined, xApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Import an extracted WhatsApp Web session (no QR) * * POST /connections/{phoneNumber}/import-session */ export const createApiConnectionsPhoneNumberImportSession = async (args: CreateApiConnectionsPhoneNumberImportSessionArgs, options?: CreateApiConnectionsPhoneNumberImportSessionOptions) => { const {baseUrl = "http://localhost:3025", fetch: fetchFn = fetch, xApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (xApiKey !== undefined) headers.set("x-api-key", xApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/connections/${encodeURIComponent(String(args.phoneNumber))}/import-session${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 };