import { RequesterResponseData } from "./requester"; export declare const enum MessageTypesEnum { Template = "template", Text = "text", Image = "image", Document = "document", Video = "video", Audio = "audio", Sticker = "sticker", Reaction = "reaction" } export type ComponentTypes = "header" | "body" | "button"; export type GeneralMessageBody = { messaging_product: "whatsapp"; }; export type ParametersTypes = "currency" | "date_time" | "document" | "image" | "text" | "video" | "payload"; type ParametersObject = { type: T; }; type ConTextObject = { message_id: string; }; export type MessageRequestBody = GeneralMessageBody & { recipient_type?: "individual"; to: string; context?: ConTextObject; type: T; } & { [K in T]: T extends keyof MessageObjectMap ? MessageObjectMap[T] : never; }; export type MessagesResponse = GeneralMessageBody & { contacts: [ { input: string; wa_id: string; } ]; messages: [ { id: string; message_status: string; } ]; }; type SimpleTextObject = { text: string; }; type TextParametersObject = ParametersObject<"text"> & SimpleTextObject; type CurrencyObject = { fallback_value: string; code: CurrencyCodes; amount_1000: number; }; type CurrencyParametersObject = ParametersObject<"currency"> & { currency: CurrencyObject; }; type DateTimeObject = { fallback_value: string; }; type DateTimeParametersObject = ParametersObject<"date_time"> & { date_time: DateTimeObject; }; type MetaDocumentMediaObject = { id: string; link?: never; caption?: string; filename?: string; }; type HostedDocumentMediaObject = { id?: never; link: string; caption?: string; filename?: string; }; type DocumentParametersObject = ParametersObject<"document"> & DocumentMediaObject; type MetaImageMediaObject = { id: string; link?: never; caption?: string; }; type HostedImageMediaObject = { id?: never; link: string; caption?: string; }; type ImageParametersObject = ParametersObject<"image"> & ImageMediaObject; type MetaHostedVideoMediaObject = { id: string; link?: never; caption?: string; }; type SelfHostedVideoMediaObject = { id?: never; link: string; caption?: string; }; type MetaAudioMediaObject = { id: string; link?: never; }; type HostedAudioMediaObject = { id?: never; link: string; }; type VideoParametersObject = ParametersObject<"video"> & VideoMediaObject; type QuickReplyButtonParametersObject = { type: "payload"; payload: string; }; type URLButtonParametersObject = SimpleTextObject & { type: "text"; }; type ButtonParameterObject = QuickReplyButtonParametersObject | URLButtonParametersObject; type ComponentObject = { type: T; parameters: (CurrencyParametersObject | DateTimeParametersObject | DocumentParametersObject | ImageParametersObject | TextParametersObject | VideoParametersObject)[]; }; type ButtonComponentObject = ComponentObject<"button"> & { parameters: ButtonParameterObject; sub_type: ButtonTypes; index: ButtonPosition; }; export type MessageTemplateObject = { name: string; language: LanguageObject; components?: (ComponentObject | ButtonComponentObject)[]; }; export type MessageTemplateRequestBody = MessageRequestBody & MessageTemplateObject; export type ImageMediaObject = MetaImageMediaObject | HostedImageMediaObject; export type TextObject = { body: string; preview_url?: boolean; }; export type DocumentMediaObject = MetaDocumentMediaObject | HostedDocumentMediaObject; export type VideoMediaObject = MetaHostedVideoMediaObject | SelfHostedVideoMediaObject; export type AudioMediaObject = MetaAudioMediaObject | HostedAudioMediaObject; type MetaStickerMediaObject = { id: string; link?: never; }; type ReactionObject = { message_id: string; emoji: string; }; type HostedStickerMediaObject = { id?: never; link: string; }; export type StickerMediaObject = MetaStickerMediaObject | HostedStickerMediaObject; type LanguageObject = { policy?: "deterministic"; code: Language; }; type CurrencyCodes = "EUR" | "USD" | "NGN"; type Language = "en" | "en_GB" | "en_US"; export type ButtonTypes = "quick_reply" | "url"; export type ButtonPosition = 0 | 1 | 2; export interface BodyBuilderOptions { type: TMessageType; toNumber: string; replyMessageId?: string; payload: TMessageType extends keyof MessageObjectMap ? MessageObjectMap[TMessageType] : never; } type MessageObjectMap = { [MessageTypesEnum.Audio]: AudioMediaObject; [MessageTypesEnum.Document]: DocumentMediaObject; [MessageTypesEnum.Image]: ImageMediaObject; [MessageTypesEnum.Template]: MessageTemplateObject; [MessageTypesEnum.Text]: TextObject; [MessageTypesEnum.Video]: VideoMediaObject; [MessageTypesEnum.Sticker]: StickerMediaObject; [MessageTypesEnum.Reaction]: ReactionObject; }; export interface SendMessageOptions { recipient: string; replyMessageId?: string; body: TMessageType extends keyof MessageObjectMap ? MessageObjectMap[TMessageType] : never; } export interface IMessageAPI { template(options: SendMessageOptions): Promise>; text(options: SendMessageOptions): Promise>; image(options: SendMessageOptions): Promise>; video(options: SendMessageOptions): Promise>; audio(options: SendMessageOptions): Promise>; document(options: SendMessageOptions): Promise>; sticker(options: SendMessageOptions): Promise>; reaction(options: SendMessageOptions): Promise>; } export {};