import { HttpClient } from '../http/client'; import type { AdvancedWebhook, AdvancedWebhookLog, WebhookStats, CreateAdvancedWebhookData, UpdateAdvancedWebhookData, ListWebhooksParams, GetLogsParams, GetStatsParams, GetLogsResponse } from '../types/advanced-webhooks'; /** * Advanced Webhooks Resource * * Provides full-featured webhook management with JSONPath filtering, * multi-URL delivery, comprehensive logging, and statistics. * * @example * ```typescript * // Create webhook with filters * const webhook = await client.advancedWebhooks.create({ * tenantId: 'tenant_123', * name: 'Group Messages Only', * urls: ['https://api.example.com/webhook'], * eventTypes: ['messages.upsert'], * filters: { * remoteJid: '120363XXX@g.us', * fromMe: false, * textContains: 'urgent' * }, * secret: 'my-secret', * retryCount: 3 * }); * * // Get webhook logs * const logs = await client.advancedWebhooks.getLogs(webhook.id, { * tenantId: 'tenant_123', * success: false, * limit: 50 * }); * * // Get statistics * const stats = await client.advancedWebhooks.getStats(webhook.id, { * tenantId: 'tenant_123', * startDate: '2024-01-01', * endDate: '2024-01-31' * }); * ``` */ export declare class AdvancedWebhooksResource { private readonly http; constructor(http: HttpClient); /** * Create a new advanced webhook * * Creates a webhook with optional filters, multi-URL delivery, and custom headers. * * @param data - Webhook configuration * @returns Created webhook * * @example * ```typescript * const webhook = await client.advancedWebhooks.create({ * tenantId: 'tenant_123', // Required for admin * name: 'Production Webhook', * description: 'All message events for production', * urls: [ * 'https://api.example.com/webhook', * 'https://backup.example.com/webhook' * ], * eventTypes: ['messages.upsert', 'messages.update'], * sessionId: '*', // All sessions * filters: { * fromMe: false, * jsonPath: [{ * path: '$.messages[0].key.participant', * operator: 'exists', * value: true * }] * }, * secret: 'my-webhook-secret', * headers: { * 'X-Custom-Header': 'value' * }, * retryCount: 3, * timeoutMs: 10000, * active: true * }); * ``` */ create(data: CreateAdvancedWebhookData): Promise; /** * List all advanced webhooks * * Supports filtering by tenant, active status, and event type. * * @param params - Query parameters (tenantId, active, eventType) * @returns Array of webhooks * * @example * ```typescript * // List all active webhooks for a tenant * const webhooks = await client.advancedWebhooks.list({ * tenantId: 'tenant_123', * active: true * }); * * // Filter by event type * const messageWebhooks = await client.advancedWebhooks.list({ * tenantId: 'tenant_123', * eventType: 'messages.upsert' * }); * ``` */ list(params?: ListWebhooksParams): Promise; /** * Get a specific advanced webhook by ID * * @param id - Webhook ID * @param params - Query parameters (tenantId for admin) * @returns Webhook details * * @example * ```typescript * const webhook = await client.advancedWebhooks.get('webhook_123', { * tenantId: 'tenant_123' * }); * console.log('Webhook:', webhook.name); * console.log('Trigger count:', webhook.triggerCount); * console.log('Success rate:', webhook.failureCount / webhook.triggerCount); * ``` */ get(id: string, params?: { tenantId?: string; }): Promise; /** * Update an advanced webhook * * All fields are optional. Only provided fields will be updated. * * @param id - Webhook ID * @param data - Fields to update * @param params - Query parameters (tenantId for admin) * @returns Updated webhook * * @example * ```typescript * // Update webhook URLs * const updated = await client.advancedWebhooks.update('webhook_123', { * urls: ['https://new-api.example.com/webhook'], * retryCount: 5 * }, { * tenantId: 'tenant_123' * }); * * // Disable webhook * await client.advancedWebhooks.update('webhook_123', { * active: false * }, { * tenantId: 'tenant_123' * }); * ``` */ update(id: string, data: UpdateAdvancedWebhookData, params?: { tenantId?: string; }): Promise; /** * Delete an advanced webhook * * @param id - Webhook ID * @param params - Query parameters (tenantId for admin) * @returns Success confirmation * * @example * ```typescript * await client.advancedWebhooks.delete('webhook_123', { * tenantId: 'tenant_123' * }); * ``` */ delete(id: string, params?: { tenantId?: string; }): Promise; /** * Get webhook delivery logs * * Returns paginated logs with detailed delivery information per URL. * Supports filtering by success, URL, event type, and date range. * * @param id - Webhook ID * @param params - Filter and pagination parameters * @returns Paginated logs response * * @example * ```typescript * // Get failed deliveries * const failedLogs = await client.advancedWebhooks.getLogs('webhook_123', { * tenantId: 'tenant_123', * success: false, * limit: 50, * offset: 0 * }); * * // Get logs for specific URL * const urlLogs = await client.advancedWebhooks.getLogs('webhook_123', { * tenantId: 'tenant_123', * url: 'https://api.example.com/webhook' * }); * * // Get logs in date range * const logs = await client.advancedWebhooks.getLogs('webhook_123', { * tenantId: 'tenant_123', * startDate: '2024-01-01T00:00:00Z', * endDate: '2024-01-31T23:59:59Z', * eventType: 'messages.upsert', * limit: 100 * }); * * console.log(`Found ${logs.total} logs`); * logs.logs.forEach(log => { * console.log(`${log.url}: ${log.statusCode} (${log.responseTimeMs}ms)`); * }); * ``` */ getLogs(id: string, params?: GetLogsParams): Promise; /** * Get a specific webhook log by ID * * Returns detailed information about a single delivery attempt. * * @param webhookId - Webhook ID * @param logId - Log ID * @param params - Query parameters (tenantId for admin) * @returns Log details * * @example * ```typescript * const log = await client.advancedWebhooks.getLog( * 'webhook_123', * 'log_456', * { tenantId: 'tenant_123' } * ); * * console.log('URL:', log.url); * console.log('Status Code:', log.statusCode); * console.log('Response Time:', log.responseTimeMs, 'ms'); * console.log('Success:', log.success); * if (!log.success) { * console.log('Error:', log.errorMessage); * console.log('Details:', log.errorDetails); * } * console.log('Payload:', JSON.stringify(log.payload, null, 2)); * ``` */ getLog(webhookId: string, logId: string, params?: { tenantId?: string; }): Promise; /** * Get webhook statistics * * Returns comprehensive statistics including success rates, response times, * and breakdowns by URL and event type. * * @param id - Webhook ID * @param params - Query parameters (tenantId, startDate, endDate) * @returns Webhook statistics * * @example * ```typescript * // Get overall stats * const stats = await client.advancedWebhooks.getStats('webhook_123', { * tenantId: 'tenant_123' * }); * * console.log('Total Triggers:', stats.totalTriggers); * console.log('Success Rate:', stats.successRate.toFixed(2) + '%'); * console.log('Avg Response Time:', stats.avgResponseTimeMs, 'ms'); * console.log('Total Retries:', stats.totalRetries); * * // Stats by URL * stats.byUrl.forEach(urlStats => { * console.log(`${urlStats.url}: ${urlStats.successRate}% success`); * }); * * // Stats by event type * stats.byEventType.forEach(eventStats => { * console.log(`${eventStats.eventType}: ${eventStats.triggers} triggers`); * }); * * // Error distribution * stats.errorDistribution.forEach(error => { * console.log(`${error.errorType}: ${error.count} occurrences`); * }); * * // Get stats for specific period * const monthlyStats = await client.advancedWebhooks.getStats('webhook_123', { * tenantId: 'tenant_123', * startDate: '2024-01-01T00:00:00Z', * endDate: '2024-01-31T23:59:59Z' * }); * ``` */ getStats(id: string, params?: GetStatsParams): Promise; } //# sourceMappingURL=advanced-webhooks.d.ts.map