import { HttpClient } from '../http/client'; import type { DeviceWithTenant, DeviceSnapshot, QRResponse, OperationResult, ConnectOptions, ReconnectOptions, DeviceOperationOptions, GenerateQRLinkOptions, QRLinkResponse, SendQRLinkData, SendMessageData, OperationResponse } from '../types/devices'; /** * Devices Resource * * Manages WhatsApp device connections, QR codes, and session lifecycle. * * @example * ```typescript * // List all devices * const devices = await client.devices.list(); * * // Get device snapshot with operations * const snapshot = await client.devices.getSnapshot('tenant_123'); * * // Connect device * await client.devices.connect('tenant_123', { * correlationId: 'my-correlation-id' * }); * * // Get QR code * const { qr, status } = await client.devices.getQR('tenant_123'); * ``` */ export declare class DevicesResource { private readonly http; constructor(http: HttpClient); /** * List all devices across all tenants (admin only) * * @returns Array of devices with tenant information * * @example * ```typescript * const devices = await client.devices.list(); * console.log(`Found ${devices.length} devices`); * devices.forEach(device => { * console.log(`${device.tenantName}: ${device.status}`); * }); * ``` */ list(): Promise; /** * Get device snapshot with operations info * * Returns device info, QR status, last operation, and pending operations count. * * @param tenantId - Tenant ID * @returns Device snapshot with operation details * * @example * ```typescript * const snapshot = await client.devices.getSnapshot('tenant_123'); * console.log('Status:', snapshot.device?.status); * console.log('QR Expired:', snapshot.qrExpired); * console.log('Last Operation:', snapshot.lastOperation?.operation); * console.log('Pending Operations:', snapshot.pendingOperationsCount); * ``` */ getSnapshot(tenantId: string): Promise; /** * Get current QR code for device * * QR codes expire after 20-40 seconds. Returns null if expired or device is already connected. * * @param tenantId - Tenant ID * @returns QR code response with status * * @example * ```typescript * const { qr, status, expiresInSeconds } = await client.devices.getQR('tenant_123'); * if (qr) { * console.log('QR Code:', qr); * console.log('Expires in:', expiresInSeconds, 'seconds'); * } else { * console.log('No QR available. Status:', status); * } * ``` */ getQR(tenantId: string): Promise; /** * Connect device and generate QR code * * Starts a new WhatsApp session or resumes existing one. Generates QR code for pairing. * * @param tenantId - Tenant ID * @param options - Connection options (callbackUrl, correlationId) * @returns Operation response * * @example * ```typescript * const result = await client.devices.connect('tenant_123', { * correlationId: 'connect-123', * callbackUrl: 'https://api.example.com/webhook' * }); * console.log('Operation ID:', result.correlationId); * * // Poll for QR code * const { qr } = await client.devices.getQR('tenant_123'); * ``` */ connect(tenantId: string, options?: ConnectOptions): Promise; /** * Reconnect device * * Forces socket recreation. Useful for stuck sessions or connection issues. * * @param tenantId - Tenant ID * @param options - Reconnect options (force, callbackUrl, correlationId) * @returns Operation response * * @example * ```typescript * // Force reconnect * await client.devices.reconnect('tenant_123', { * force: true, * correlationId: 'reconnect-123' * }); * ``` */ reconnect(tenantId: string, options?: ReconnectOptions): Promise; /** * Disconnect device * * Gracefully closes WhatsApp connection without deleting auth state. * Device can reconnect without re-scanning QR. * * @param tenantId - Tenant ID * @param options - Operation options (callbackUrl, correlationId) * @returns Operation response * * @example * ```typescript * await client.devices.disconnect('tenant_123'); * ``` */ disconnect(tenantId: string, options?: DeviceOperationOptions): Promise; /** * Reset device session * * Closes connection and deletes auth state. Next connect will require QR scan. * * @param tenantId - Tenant ID * @param options - Operation options (callbackUrl, correlationId) * @returns Operation response * * @example * ```typescript * // Reset session (user will need to scan QR again) * await client.devices.reset('tenant_123'); * ``` */ reset(tenantId: string, options?: DeviceOperationOptions): Promise; /** * Ping device to check connectivity * * Sends a ping to verify device is online and responding. * * @param tenantId - Tenant ID * @param options - Operation options (callbackUrl, correlationId) * @returns Operation response * * @example * ```typescript * const result = await client.devices.ping('tenant_123'); * console.log('Ping result:', result.status); * ``` */ ping(tenantId: string, options?: DeviceOperationOptions): Promise; /** * Get operation result by correlation ID * * Check status of async operations (connect, send message, etc). * * @param correlationId - Correlation ID from operation * @returns Operation result with status and details * * @example * ```typescript * const operation = await client.devices.getOperation('my-correlation-id'); * console.log('Status:', operation.status); * if (operation.status === 'success') { * console.log('Result:', operation.result); * } else if (operation.status === 'failed') { * console.error('Error:', operation.error); * } * ``` */ getOperation(correlationId: string): Promise; /** * Send message as admin * * Send WhatsApp message on behalf of a tenant. Device must be connected. * * @param tenantId - Tenant ID * @param data - Message data (jid, text, callbackUrl, correlationId) * @returns Operation response * * @example * ```typescript * await client.devices.sendMessage('tenant_123', { * jid: '5511999999999@s.whatsapp.net', * text: 'Hello from admin!', * correlationId: 'msg-123' * }); * ``` */ sendMessage(tenantId: string, data: SendMessageData): Promise; /** * Generate QR link for support * * Creates a shareable link that displays QR code for remote connection setup. * Useful for support teams to help users connect their WhatsApp. * * @param tenantId - Tenant ID * @param options - QR link options (deviceId, expirationHours) * @returns QR link response with token and URL * * @example * ```typescript * const { url, token, expiresAt } = await client.devices.generateQRLink('tenant_123', { * expirationHours: 24 * }); * console.log('Share this link:', url); * console.log('Expires:', expiresAt); * ``` */ generateQRLink(tenantId: string, options?: GenerateQRLinkOptions): Promise; /** * Send QR link via WhatsApp * * Sends a QR connection link to a recipient via WhatsApp message. * Used for support scenarios where admin helps user connect remotely. * * @param tenantId - Sender tenant ID * @param data - Recipient and device information * @returns Operation response * * @example * ```typescript * await client.devices.sendQRLink('support_tenant', { * recipientTenantId: 'customer_tenant', * recipientJid: '5511999999999@s.whatsapp.net' * }); * ``` */ sendQRLink(tenantId: string, data: SendQRLinkData): Promise; } //# sourceMappingURL=devices.d.ts.map