import { Integration } from '@rabid/pipeline-manager'; import { TextInput, TextMessage, LocationInput, LocationMessage, InteractiveInput, InteractiveMessage } from './models'; /** * Interface representing the configuration settings required for accessing the WhatsApp API. * * @interface * @property {string} accessToken - A valid access token for authenticating API requests. * @property {string} apiVersion - The version of the API to be used. */ interface WhatsAppConfig { accessToken: string; apiVersion: string; } /** * Represents the response from sending a message through WhatsApp. * * This interface captures the structure of the response obtained after * attempting to send a message via the WhatsApp API, including details * about the messaging product used, the contacts involved, and the messages sent. * * @interface * @property {string} messaging_product - The name of the product used for messaging, typically "whatsapp". * @property {Object[]} contacts - An array containing information about the contacts involved in the messaging. * @property {string} contacts[].input - The input provided, usually the phone number of the contact in string format. * @property {string} contacts[].wa_id - The WhatsApp ID corresponding to the provided input. * @property {Object[]} messages - An array containing information about the messages that were attempted to be sent. * @property {string} messages[].id - The unique identifier assigned to each message by the WhatsApp system. */ interface WhatsAppSendResponse { messaging_product: string; contacts: { input: string; wa_id: string; }[]; messages: { id: string; }[]; } /** * Represents the response obtained after executing an operation related to message handling. * * @interface ExecutionResponse * * @property {TextMessage | LocationMessage | InteractiveMessage} model * The message model relevant to the operation being executed. This can be one of three types: * - TextMessage: Represents a text-based message. * - LocationMessage: Represents a location-sharing message. * - InteractiveMessage: Represents an interactive message, which might include elements like buttons or other interactive features. * * @property {WhatsAppSendResponse} messageResponse * The response returned from sending a message through WhatsApp. This encapsulates details about the success or failure of the message delivery, as well as any metadata or information related to the delivery status. */ interface ExecutionResponse { model: TextMessage | LocationMessage | InteractiveMessage; messageResponse: WhatsAppSendResponse; } /** * Represents a service for sending messages via WhatsApp using the Facebook Graph API. * Implements the Integration interface for executing message sends. */ export declare class WhatsAppSend implements Integration { private readonly httpClient; /** * Constructs a new instance configured to interact with the WhatsApp API. * * @param {WhatsAppConfig} config - The configuration object containing necessary API details. * @param {string} config.apiVersion - The version of the API to interact with. * @param {string} config.accessToken - The access token used for authenticating API requests. */ constructor(config: WhatsAppConfig); /** * Executes a message sending operation based on the input type. It constructs * a model specific to the message type and sends it using an HTTP client. * * @param {TextInput | LocationInput | InteractiveInput} input - The input object containing the details needed to send a message, including sender information and message type. * @return {Promise} A promise that resolves to an ExecutionResponse object containing the model and message response if successful; otherwise, it throws an error for unsupported message types. * @throws {Error} Throws an error if the message type is not defined or supported. */ execute(input: TextInput | LocationInput | InteractiveInput): Promise; } export {};