import { KiotVietClient } from '../client'; import { Webhook, WebhookCreateParams, WebhookUpdateParams, WebhookListParams, WebhookListResponse, WebhookPayload, WebhookEvent, TypedWebhookPayload } from '../types/webhook'; import { CustomerUpdateWebhookPayload, ProductUpdateWebhookPayload, OrderUpdateWebhookPayload } from '../types/webhook-payloads'; export declare class WebhookHandler { private client; constructor(client: KiotVietClient); /** * List webhooks with optional filtering * @param params Filter parameters */ list(params?: WebhookListParams): Promise; /** * Get a webhook by its ID * @param webhookId The ID of the webhook to retrieve */ getById(webhookId: number): Promise; /** * Create a new webhook * @param webhookData The webhook configuration data */ create(webhookData: WebhookCreateParams): Promise; /** * Update an existing webhook * @param webhookId The ID of the webhook to update * @param webhookData The webhook data to update */ update(webhookId: number, webhookData: Partial): Promise; /** * Delete a webhook * @param webhookId The ID of the webhook to delete */ delete(webhookId: number): Promise; /** * Enable a webhook * @param webhookId The ID of the webhook to enable */ enable(webhookId: number): Promise; /** * Disable a webhook * @param webhookId The ID of the webhook to disable */ disable(webhookId: number): Promise; /** * Verify webhook signature * @param payload The raw webhook payload * @param signature The signature from X-Hub-Signature header * @param secret The webhook secret */ verifySignature(payload: string, signature: string, secret: string): boolean; /** * Parse and verify webhook payload * @param payload The raw webhook payload string * @param signature The signature from X-Hub-Signature header * @param secret The webhook secret */ parseWebhookPayload(payload: string, signature: string, secret: string): WebhookPayload; /** * Parse and verify a webhook payload with automatic type casting based on the event type * @param payload The raw webhook payload string * @param signature The signature from X-Hub-Signature header * @param secret The webhook secret */ parseTypedWebhookPayload(payload: string, signature: string, secret: string, expectedEvent: E): TypedWebhookPayload; /** * Parse and verify customer update webhook payload * @param payload The raw webhook payload string * @param signature The signature from X-Hub-Signature header * @param secret The webhook secret */ parseCustomerUpdateWebhook(payload: string, signature: string, secret: string): TypedWebhookPayload; /** * Parse and verify product update webhook payload * @param payload The raw webhook payload string * @param signature The signature from X-Hub-Signature header * @param secret The webhook secret */ parseProductUpdateWebhook(payload: string, signature: string, secret: string): TypedWebhookPayload; /** * Parse and verify order update webhook payload * @param payload The raw webhook payload string * @param signature The signature from X-Hub-Signature header * @param secret The webhook secret */ parseOrderUpdateWebhook(payload: string, signature: string, secret: string): TypedWebhookPayload; /** * Parse and verify invoice update webhook payload * @param payload The raw webhook payload string * @param signature The signature from X-Hub-Signature header * @param secret The webhook secret */ parseInvoiceUpdateWebhook(payload: string, signature: string, secret: string): TypedWebhookPayload; /** * Parse and verify stock update webhook payload * @param payload The raw webhook payload string * @param signature The signature from X-Hub-Signature header * @param secret The webhook secret */ parseStockUpdateWebhook(payload: string, signature: string, secret: string): TypedWebhookPayload; /** * Kiểm tra cấu trúc chung của webhook payload (trường hợp update) * @param payload Webhook payload dạng object (đã parse từ JSON) */ validateGenericUpdatePayload(payload: any): boolean; /** * Kiểm tra cấu trúc của payload xóa (RemoveId) * @param payload Webhook payload dạng object (đã parse từ JSON) */ validateDeletePayload(payload: any): boolean; /** * Kiểm tra xem webhook payload có hợp lệ không và có đúng cấu trúc cho customer.update không * @param payload Webhook payload dạng object (đã parse từ JSON) */ validateCustomerUpdatePayload(payload: any): payload is CustomerUpdateWebhookPayload; /** * Kiểm tra xem webhook payload có hợp lệ không và có đúng cấu trúc cho product.update không * @param payload Webhook payload dạng object (đã parse từ JSON) */ validateProductUpdatePayload(payload: any): payload is ProductUpdateWebhookPayload; /** * Kiểm tra xem webhook payload có hợp lệ không và có đúng cấu trúc cho order.update không * @param payload Webhook payload dạng object (đã parse từ JSON) */ validateOrderUpdatePayload(payload: any): payload is OrderUpdateWebhookPayload; }