UNPKG

meta-cloud-api

Version:
537 lines (528 loc) 14.5 kB
import { N as NameObject, h as AddressesObject, C as ContactObject, a as InteractiveObject, L as LocationObject, A as AudioMediaObject, D as DocumentMediaObject, I as ImageMediaObject, V as VideoMediaObject, d as StickerMediaObject, c as MessageTemplateObject, e as TextObject } from '../../../common-BiRA_uz3.js'; import { I as InteractiveTypesEnum, P as ParametersTypesEnum, i as CurrencyCodesEnum, C as ComponentTypesEnum } from '../../../enums-BZd9T2ul.js'; import '../../../base-CdGDdVEl.js'; import '../../../types/config.js'; import '../../../request-vYMaEfk5.js'; /** * Builder class for creating contact messages with a fluent API */ declare class ContactMessageBuilder { private contact; /** * Set the contact name (required) */ setName(name: NameObject): this; /** * Set simple name with first name only */ setSimpleName(firstName: string, lastName?: string): this; /** * Set full name details */ setFullName(firstName: string, lastName?: string, middleName?: string, suffix?: string, prefix?: string): this; /** * Add phone numbers */ addPhone(phone: string, type?: string, waId?: string): this; /** * Add email addresses */ addEmail(email: string, type?: string): this; /** * Add address */ addAddress(address: AddressesObject): this; /** * Add simple address */ addSimpleAddress(street: string, city: string, country: string, type?: string): this; /** * Set organization details */ setOrganization(company: string, department?: string, title?: string): this; /** * Add URL */ addUrl(url: string, type?: string): this; /** * Set birthday (format: YYYY-MM-DD) */ setBirthday(year: number, month: number, day: number): this; /** * Build the final contact object */ build(): ContactObject; /** * Reset the builder for reuse */ reset(): this; } /** * Factory class for common contact patterns */ declare class ContactMessageFactory { /** * Create a simple contact with name and phone */ static createSimpleContact(firstName: string, phone: string): ContactObject; /** * Create a business contact */ static createBusinessContact(firstName: string, lastName: string, company: string, title: string, phone: string, email: string): ContactObject; /** * Create a personal contact with full details */ static createPersonalContact(firstName: string, lastName: string, mobilePhone: string, email?: string, birthday?: { year: number; month: number; day: number; }): ContactObject; } /** * Builder class for creating interactive messages with a fluent API */ declare class InteractiveMessageBuilder { private message; /** * Set the interactive message type */ setType(type: InteractiveTypesEnum): this; /** * Set the body text of the message */ setBody(text: string): this; /** * Set the footer text of the message */ setFooter(text: string): this; /** * Set a text header */ setTextHeader(text: string): this; /** * Set an image header */ setImageHeader(imageUrl: string): this; /** * Add reply buttons (for button type messages) */ addReplyButtons(buttons: Array<{ id: string; title: string; }>): this; /** * Add list sections (for list type messages) * Note: This creates a single section with multiple rows */ addListSections(sections: Array<{ title?: string; rows: Array<{ id: string; title: string; description?: string; }>; }>): this; /** * Set the button text for list messages */ setListButtonText(buttonText: string): this; /** * Set CTA URL action */ setCTAUrl(displayText: string, url: string): this; /** * Build the final interactive object */ build(): InteractiveObject; /** * Reset the builder for reuse */ reset(): this; } /** * Convenience factory functions for common interactive message types */ declare class InteractiveMessageFactory { /** * Create a button message with reply buttons */ static createButtonMessage(bodyText: string, buttons: Array<{ id: string; title: string; }>, options?: { headerText?: string; footerText?: string; }): InteractiveObject; /** * Create a list message with sections */ static createListMessage(bodyText: string, buttonText: string, sections: Array<{ title?: string; rows: Array<{ id: string; title: string; description?: string; }>; }>, options?: { headerText?: string; footerText?: string; }): InteractiveObject; /** * Create a CTA URL message */ static createCTAUrlMessage(bodyText: string, displayText: string, url: string, options?: { headerText?: string; footerText?: string; }): InteractiveObject; } /** * Builder class for creating location messages with a fluent API */ declare class LocationMessageBuilder { private location; /** * Set the latitude coordinate */ setLatitude(latitude: number): this; /** * Set the longitude coordinate */ setLongitude(longitude: number): this; /** * Set coordinates using latitude and longitude */ setCoordinates(latitude: number, longitude: number): this; /** * Set the location name */ setName(name: string): this; /** * Set the location address */ setAddress(address: string): this; /** * Build the final location object */ build(): LocationObject; /** * Reset the builder for reuse */ reset(): this; } /** * Factory class for common location patterns */ declare class LocationMessageFactory { /** * Create a simple location with just coordinates */ static createSimpleLocation(latitude: number, longitude: number): LocationObject; /** * Create a location with name and address */ static createNamedLocation(latitude: number, longitude: number, name: string, address: string): LocationObject; /** * Create a business location */ static createBusinessLocation(latitude: number, longitude: number, businessName: string, fullAddress: string): LocationObject; } /** * Base builder for media messages */ declare abstract class BaseMediaBuilder<T> { protected media: Partial<T>; /** * Set media ID (for uploaded media) */ setId(id: string): this; /** * Set media URL */ setLink(url: string): this; /** * Set media caption */ setCaption(caption: string): this; /** * Build the media object */ build(): T; /** * Reset the builder */ reset(): this; } /** * Builder for image messages */ declare class ImageMessageBuilder extends BaseMediaBuilder<ImageMediaObject> { } /** * Builder for video messages */ declare class VideoMessageBuilder extends BaseMediaBuilder<VideoMediaObject> { } /** * Builder for audio messages */ declare class AudioMessageBuilder extends BaseMediaBuilder<AudioMediaObject> { setCaption(caption: string): this; } /** * Builder for document messages */ declare class DocumentMessageBuilder extends BaseMediaBuilder<DocumentMediaObject> { /** * Set document filename */ setFilename(filename: string): this; } /** * Builder for sticker messages */ declare class StickerMessageBuilder extends BaseMediaBuilder<StickerMediaObject> { setCaption(caption: string): this; } /** * Factory class for common media patterns */ declare class MediaMessageFactory { /** * Create an image with caption */ static createImageWithCaption(linkOrId: string, caption: string, isId?: boolean): ImageMediaObject; /** * Create a video with caption */ static createVideoWithCaption(linkOrId: string, caption: string, isId?: boolean): VideoMediaObject; /** * Create a document with filename */ static createDocument(linkOrId: string, filename: string, caption?: string, isId?: boolean): DocumentMediaObject; /** * Create an audio message */ static createAudio(linkOrId: string, isId?: boolean): AudioMediaObject; /** * Create a sticker message */ static createSticker(linkOrId: string, isId?: boolean): StickerMediaObject; } /** * Builder class for creating reaction messages with a fluent API */ declare class ReactionMessageBuilder { private reaction; /** * Set the message ID to react to */ setMessageId(messageId: string): this; /** * Set the emoji for the reaction */ setEmoji(emoji: string): this; /** * Remove a reaction (by sending empty emoji) */ removeReaction(): this; /** * Build the final reaction object */ build(): { message_id: string; emoji: string; }; /** * Reset the builder for reuse */ reset(): this; } /** * Factory class for common reaction patterns */ declare class ReactionMessageFactory { /** * Create a like reaction */ static createLike(messageId: string): { message_id: string; emoji: string; }; /** * Create a heart reaction */ static createHeart(messageId: string): { message_id: string; emoji: string; }; /** * Create a laughing reaction */ static createLaugh(messageId: string): { message_id: string; emoji: string; }; /** * Create a wow reaction */ static createWow(messageId: string): { message_id: string; emoji: string; }; /** * Create a sad reaction */ static createSad(messageId: string): { message_id: string; emoji: string; }; /** * Create an angry reaction */ static createAngry(messageId: string): { message_id: string; emoji: string; }; /** * Remove a reaction */ static removeReaction(messageId: string): { message_id: string; emoji: string; }; } type CurrencyParameterHelper = { type: ParametersTypesEnum.Currency; currency: { fallback_value: string; code: CurrencyCodesEnum; amount_1000: number; }; }; type DateTimeParameterHelper = { type: ParametersTypesEnum.DateTime; date_time: { fallback_value: string; timestamp: number; }; }; /** * Builder class for creating template messages with a fluent API */ declare class TemplateMessageBuilder { private template; /** * Set the template name */ setName(name: string): this; /** * Set the template language */ setLanguage(code: string): this; /** * Add a header component with text parameters */ addTextHeader(parameters: string[]): this; /** * Add a header component with image */ addImageHeader(imageUrl: string): this; /** * Add a body component with text parameters */ addBody(parameters: string[]): this; /** * Add a footer component (usually no parameters needed) */ addFooter(): this; /** * Add button components (for quick replies, URLs, etc.) */ addButtons(buttons: Array<{ index: number; type: 'quick_reply' | 'url'; parameters?: string[]; }>): this; /** * Add a currency parameter for header/body */ addCurrencyParameter(fallbackValue: string, currencyCode: string, amount: number): CurrencyParameterHelper; /** * Add a date time parameter */ addDateTimeParameter(fallbackValue: string, timestamp: number): DateTimeParameterHelper; /** * Build the final template object */ build(): MessageTemplateObject<ComponentTypesEnum>; /** * Reset the builder for reuse */ reset(): this; } /** * Factory class for common template patterns */ declare class TemplateMessageFactory { /** * Create a simple text-only template */ static createSimpleTextTemplate(name: string, language: string, bodyParameters: string[]): MessageTemplateObject<ComponentTypesEnum>; /** * Create a template with header, body and buttons */ static createCompleteTemplate(name: string, language: string, options: { headerParameters?: string[]; headerImage?: string; bodyParameters: string[]; buttons?: Array<{ index: number; type: 'quick_reply' | 'url'; parameters?: string[]; }>; }): MessageTemplateObject<ComponentTypesEnum>; /** * Create an order confirmation template */ static createOrderConfirmationTemplate(language: string, customerName: string, orderNumber: string, amount: number, currencyCode: string): MessageTemplateObject<ComponentTypesEnum>; } /** * Builder class for creating text messages with a fluent API */ declare class TextMessageBuilder { private textMessage; /** * Set the message body text */ setBody(text: string): this; /** * Enable or disable URL preview */ setPreviewUrl(enable?: boolean): this; /** * Build the final text object */ build(): TextObject; /** * Reset the builder for reuse */ reset(): this; } /** * Factory class for common text message patterns */ declare class TextMessageFactory { /** * Create a simple text message */ static createSimpleText(body: string): TextObject; /** * Create a text message with URL preview */ static createTextWithPreview(body: string): TextObject; /** * Create a notification message */ static createNotification(title: string, message: string): TextObject; } export { AudioMessageBuilder, ContactMessageBuilder, ContactMessageFactory, DocumentMessageBuilder, ImageMessageBuilder, InteractiveMessageBuilder, InteractiveMessageFactory, LocationMessageBuilder, LocationMessageFactory, MediaMessageFactory, ReactionMessageBuilder, ReactionMessageFactory, StickerMessageBuilder, TemplateMessageBuilder, TemplateMessageFactory, TextMessageBuilder, TextMessageFactory, VideoMessageBuilder };