import { ClientMessage, ClientLimitedMessageComponent, Section, type InteractiveAction } from "../types.js"; import type { AtLeastOne } from "../utils"; import type { Document, Image, Video } from "./media"; import { Product, ProductSection } from "./globals.js"; /** * Interactive API object * * @group Interactive */ export declare class Interactive extends ClientMessage { /** * The action for the interactive message */ readonly action: InteractiveAction; /** * The body for the interactive message */ readonly body?: Body; /** * The header for the interactive message */ readonly header?: Header; /** * The footer for the interactive message */ readonly footer?: Footer; /** * The type of the interactive message */ readonly type: InteractiveAction["_type"]; /** * @override * @internal */ get _type(): "interactive"; /** * Creates an Interactive Reply Buttons object for the API * * @example * ```ts * import { * Interactive, * ActionButtons, * Button, * Body * } from "whatsapp-api-js/messages"; * * const interactive_button_message = new Interactive( * new ActionButtons( * new Button("reply_1", "Hello"), * new Button("reply_2", "World") * ), * new Body("Hello World") * ); * ``` * * @param action - The action for the interactive message * @param body - The body for the interactive message * @param header - The header for the interactive message, it may be undefined if not needed * @param footer - The footer for the interactive message, it may be undefined if not needed */ constructor(action: ActionButtons, body: Body, header?: Header, footer?: Footer); /** * Creates an Interactive List object for the API * * @example * ```ts * import { Interactive, ActionList, Row, Body } from "whatsapp-api-js/messages"; * * const interactive_list_message = new Interactive( * new ActionList( * "Button text", * new ListSection( * "Section title", * new Row("reply_1", "Hello", "Hello description"), * new Row("reply_2", "World", "World description") * ) * ), * new Body("Hello World") * ); * ``` * * @param action - The action for the interactive message * @param body - The body for the interactive message * @param header - The header of type text for the interactive message, it may be undefined if not needed * @param footer - The footer for the interactive message, it may be undefined if not needed * @throws If a header is provided and it's not of type "text" */ constructor(action: ActionList, body: Body, header?: Header, footer?: Footer); /** * Creates an Interactive Catalog object for the API * * @example * ```ts * import { * Interactive, * ActionCatalog, * Product, * Body * } from "whatsapp-api-js/messages"; * * const interactive_catalog_message = new Interactive( * new ActionCatalog(new Product("hello")), * new Body("Hello World") * ); * ``` * * @param action - The action for the interactive message * @param body - The body for the interactive message * @param header - Undefined * @param footer - The footer for the interactive message, it may be undefined if not needed */ constructor(action: ActionCatalog, body: Body, header?: undefined, footer?: Footer); /** * Creates an Interactive Single Product object for the API * * @example * ```ts * import { Interactive, ActionProduct, Product } from "whatsapp-api-js/messages"; * * const interactive_single_product_message = new Interactive( * new ActionProduct("catalog_id", new Product("product_id")) * ); * ``` * * @param action - The action for the interactive message * @param body - The body for the interactive message * @param header - Undefined * @param footer - The footer for the interactive message, it may be undefined if not needed */ constructor(action: ActionProduct, body?: Body, header?: undefined, footer?: Footer); /** * Creates an Interactive Multi Product object for the API * * @example * ```ts * import { * Interactive, * ActionProductList, * ProductSection, * Product * } from "whatsapp-api-js/messages"; * * const interactive_multi_product_message = new Interactive( * new ActionProductList( * "catalog_id", * new ProductSection( * "Product section title", * new Product("product_id"), * new Product("product_id") * ) * ), * new Body("Hello World"), * new Header("Hello World Header") * ); * ``` * * @param action - The action for the interactive message * @param body - The body for the interactive message * @param header - The header of type text for the interactive message * @param footer - The footer for the interactive message, it may be undefined if not needed * @throws If header is not of type "text" */ constructor(action: ActionProductList, body: Body, header: Header, footer?: Footer); /** * Creates an Interactive CTA object for the API * * @example * ```ts * import { Interactive, ActionCTA, Body } from "whatsapp-api-js/messages"; * * const interactive_catalog_message = new Interactive( * new ActionCTA("Open Google", "https://google.com"), * new Body("You should google it") * ); * ``` * * @param action - The action for the interactive message * @param body - The body for the interactive message * @param header - The header of type text for the interactive message, it may be undefined if not needed * @param footer - The footer for the interactive message, it may be undefined if not needed * @throws If a header is provided and it's not of type "text" */ constructor(action: ActionCTA, body: Body, header?: Header, footer?: Footer); /** * Creates an Interactive Flow object for the API * * @example * ```ts * import { * Interactive, * ActionNavigateFlow, * Body * } from "whatsapp-api-js/messages"; * * const interactive_navigate_flow_message = new Interactive( * new ActionNavigateFlow( * "5f9b3b4f-2b7a-4f4f-8f4f-4f4f4f4f4f4f", * "5f9b3b4f-2b7a-4f4f-8f4f-4f4f4f4f4f4f", * "Hello World", * "form_screen", * { * name: "John Doe", * age: 42 * } * ), * new Body("How was your experience today?") * ); * ``` * * @example * ```ts * import { * Interactive, * ActionDataExchangeFlow, * Body * } from "whatsapp-api-js/messages"; * * const interactive_data_exchange_flow_message = new Interactive( * new ActionDataExchangeFlow( * "5f9b3b4f-2b7a-4f4f-8f4f-4f4f4f4f4f4f", * "5f9b3b4f-2b7a-4f4f-8f4f-4f4f4f4f4f4f", * "Hello World" * ), * new Body("Hello World") * ); * ``` * * @param action - The action for the interactive message * @param body - The body for the interactive message * @param header - The header of type text for the interactive message, it may be undefined if not needed * @param footer - The footer for the interactive message, it may be undefined if not needed * @throws If a header is provided and it's not of type "text" */ constructor(action: ActionFlow, body: Body, header?: Header, footer?: Footer); /** * Creates an Interactive Location request object for the API * * @example * ```ts * import { Interactive, ActionLocation, Body } from "whatsapp-api-js/messages"; * * const interactive_catalog_message = new Interactive( * new ActionLocation(), * new Body("Show me where you live") * ); * ``` * * @param action - The action for the interactive message * @param body - The body of the interactive message */ constructor(action: ActionLocation, body: Body); } /** * Body API object * * @group Interactive */ export declare class Body { /** * The text of the body */ readonly text: string; /** * Builds a body component for an Interactive message * * @param text - The text of the message. Maximum length: 1024 characters. * @throws If text is over 1024 characters */ constructor(text: string); } /** * Footer API object * * @group Interactive */ export declare class Footer { /** * The text of the footer */ readonly text: string; /** * Builds a footer component for an Interactive message * * @param text - Text of the footer. Maximum length: 60 characters. * @throws If text is over 60 characters */ constructor(text: string); } /** * Header API object * * @group Interactive */ export declare class Header { /** * The type of the header */ readonly type: "text" | "image" | "video" | "document"; /** * The text of the parameter */ readonly text?: string; /** * The image of the parameter */ readonly image?: Image; /** * The document of the parameter */ readonly document?: Document; /** * The video of the parameter */ readonly video?: Video; /** * Builds a header component for an Interactive message * * @param object - The message object for the header * @throws If object is a string and is over 60 characters * @throws If object is a Media and has a caption */ constructor(object: Document | Image | Video | string); } /** * Action API object * * @group Interactive */ export declare class ActionButtons extends ClientLimitedMessageComponent implements InteractiveAction { /** * The buttons of the action */ readonly buttons: Button[]; /** * @override * @internal */ get _type(): "button"; /** * Builds a reply buttons component for an Interactive message * * @param button - Buttons to be used in the reply buttons. Each button title must be unique within the message. Emojis are supported, markdown is not. Must be between 1 and 3 buttons. * @throws If more than 3 buttons are provided * @throws If two or more buttons have the same id * @throws If two or more buttons have the same title */ constructor(...button: AtLeastOne