import "github.com/wapikit/wapi.go/pkg/components"
type AddressType
const (
HomeAddress AddressType = "HOME"
WorkAddress AddressType = "WORK"
)
const (
HomeUrl AddressType = "HOME"
WorkUrl AddressType = "WORK"
)
type ApiCompatibleJsonConverterConfigs
ApiCompatibleJsonConverterConfigs represents the configuration for converting to JSON.
type ApiCompatibleJsonConverterConfigs struct {
ReplyToMessageId string
SendToPhoneNumber string
}
type AudioMessage
AudioMessage represents an audio message.
type AudioMessage struct {
Id string `json:"id,omitempty"`
Link string `json:"link,omitempty"`
}
func NewAudioMessage
func NewAudioMessage(params AudioMessageConfigs) (*AudioMessage, error)
NewAudioMessage creates a new AudioMessage object.
func (*AudioMessage) ToJson
func (audio *AudioMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the AudioMessage object to JSON.
type AudioMessageApiPayload
AudioMessageApiPayload represents the payload for an audio message API request.
type AudioMessageApiPayload struct {
BaseMessagePayload
Audio AudioMessage `json:"audio" validate:"required"`
}
type AudioMessageConfigs
AudioMessageConfigs is an alias for AudioMessage.
type AudioMessageConfigs = AudioMessage
type BaseMessage
BaseMessage is an interface for sending messages.
type BaseMessage interface {
ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
}
type BaseMessagePayload
BaseMessagePayload represents the base payload to send messages.
type BaseMessagePayload struct {
Context *Context `json:"context,omitempty"`
To string `json:"to"`
Type MessageType `json:"type"`
MessagingProduct string `json:"messaging_product"`
RecipientType string `json:"recipient_type"`
}
func NewBaseMessagePayload
func NewBaseMessagePayload(to string, messageType MessageType) BaseMessagePayload
NewBaseMessagePayload creates a new instance of BaseMessagePayload.
type CatalogMessage
ProductMessage represents a product message.
type CatalogMessage struct {
Type InteractiveMessageType `json:"type" validate:"required"`
Action CatalogMessageAction `json:"action" validate:"required"`
Body CatalogMessageBody `json:"body" validate:"required"`
Footer *CatalogMessageFooter `json:"footer,omitempty"`
Header *CatalogMessageHeader `json:"header,omitempty"`
}
func NewCatalogMessage
func NewCatalogMessage(name, thumbnailProductRetailerId string) (*CatalogMessage, error)
func (*CatalogMessage) SetBody
func (m *CatalogMessage) SetBody(text string)
func (m *CatalogMessage) SetFooter(text string)
func (m *CatalogMessage) SetHeader(text string)
func (*CatalogMessage) ToJson
func (m *CatalogMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the product message to JSON with the given configurations.
type CatalogMessageAction
type CatalogMessageAction struct {
Name string `json:"name" validate:"required"`
Parameters CatalogMessageActionParameter `json:"parameters,omitempty"`
}
type CatalogMessageActionParameter
type CatalogMessageActionParameter struct {
ThumbnailProductRetailerId string `json:"thumbnail_product_retailer_id" validate:"required"`
}
type CatalogMessageApiPayload
ProductMessageApiPayload represents the API payload for a product message.
type CatalogMessageApiPayload struct {
BaseMessagePayload
Interactive CatalogMessage `json:"interactive" validate:"required"`
}
type CatalogMessageBody
type CatalogMessageBody struct {
Text string `json:"text" validate:"required"`
}
type CatalogMessageFooter struct {
Text string `json:"text" validate:"required"`
}
type CatalogMessageHeader struct {
Text string `json:"text" validate:"required"`
}
type Contact struct {
Name ContactName `json:"name" validate:"required"`
Org ContactOrg `json:"org,omitempty"`
Addresses []ContactAddress `json:"addresses,omitempty"`
Urls []ContactUrl `json:"urls,omitempty"`
Emails []ContactEmail `json:"emails,omitempty"`
Phones []ContactPhone `json:"phones,omitempty"`
Birthday string `json:"birthday,omitempty"`
}
func NewContact(name ContactName) *Contact
func (contact *Contact) AddEmail(params ContactEmail)
func (contact *Contact) AddPhone(params ContactPhone)
func (contact *Contact) AddUrl(params ContactUrl)
func (contact *Contact) SetBirthday(params string)
! TODO: add regex check here in the params
func (contact *Contact) SetFirstName(firstName string)
func (contact *Contact) SetLastName(lastName string)
func (contact *Contact) SetMiddleName(middleName string)
func (contact *Contact) SetOrg(params ContactOrg)
type ContactAddress struct {
Street string `json:"street,omitempty"`
City string `json:"city,omitempty"`
State string `json:"state,omitempty"`
Zip string `json:"zip,omitempty"`
Country string `json:"country,omitempty"`
CountryCode string `json:"countryCode,omitempty"`
Type AddressType `json:"type" validate:"required"`
}
type ContactEmail struct {
Email string `json:"email,omitempty"`
Type EmailType `json:"type,omitempty"`
}
type ContactMessage struct {
Contacts []Contact `json:"contacts" validate:"required"`
}
func NewContactMessage(configs []Contact) (*ContactMessage, error)
func (contact *ContactMessage) AddContact(params Contact)
func (m *ContactMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
type ContactMessageApiPayload struct {
BaseMessagePayload
Contacts []Contact `json:"contacts" validate:"required"`
}
type ContactMessageConfigs struct {
Name string `json:"name" validate:"required"`
}
type ContactName struct {
FormattedName string `json:"formatted_name" validate:"required"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
MiddleName string `json:"middle_name,omitempty"`
Suffix string `json:"suffix,omitempty"`
Prefix string `json:"prefix,omitempty"`
}
type ContactOrg struct {
Company string `json:"company,omitempty"`
Title string `json:"title,omitempty"`
Department string `json:"department,omitempty"`
}
type ContactPhone struct {
Phone string `json:"phone,omitempty"`
WaId string `json:"wa_id,omitempty"`
Type PhoneType `json:"type" validate:"required"`
}
type ContactUrl struct {
Url string `json:"url" validate:"required"`
Type UrlType `json:"type" validate:"required"`
}
type Context
Context represents the context of the message.
type Context struct {
MessageId string `json:"message_id,omitempty"`
}
type DocumentMessage
DocumentMessage represents a document message.
type DocumentMessage struct {
Id string `json:"id,omitempty"`
Link *string `json:"link,omitempty"`
Caption *string `json:"caption,omitempty"`
FileName string `json:"filename" validate:"required"`
}
func NewDocumentMessage
func NewDocumentMessage(params DocumentMessageConfigs) (*DocumentMessage, error)
NewDocumentMessage creates a new DocumentMessage instance.
func (*DocumentMessage) ToJson
func (dm *DocumentMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the DocumentMessage instance to JSON.
type DocumentMessageApiPayload
DocumentMessageApiPayload represents the API payload for a document message.
type DocumentMessageApiPayload struct {
BaseMessagePayload
Document DocumentMessage `json:"document" validate:"required"`
}
type DocumentMessageConfigs
DocumentMessageConfigs represents the configurations for a document message.
type DocumentMessageConfigs struct {
Id string `json:"id" validate:"required"`
Link *string `json:"link,omitempty"`
Caption *string `json:"caption,omitempty"`
FileName string `json:"filename" validate:"required"`
}
type EmailType
const (
HomeEmail EmailType = "HOME"
WorkEmail EmailType = "WORK"
)
type ImageMessage
ImageMessage represents a message with an image.
type ImageMessage struct {
Id string `json:"id,omitempty"`
Link string `json:"link,omitempty"`
Caption string `json:"caption,omitempty"`
}
func NewImageMessage
func NewImageMessage(params ImageMessageConfigs) (*ImageMessage, error)
NewImageMessage creates a new ImageMessage instance.
func (*ImageMessage) SetCaption
func (image *ImageMessage) SetCaption(params string)
SetCaption sets the caption for the image message.
func (*ImageMessage) ToJson
func (image *ImageMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the ImageMessage to JSON.
type ImageMessageApiPayload
ImageMessageApiPayload represents the API payload for an image message.
type ImageMessageApiPayload struct {
BaseMessagePayload
Image ImageMessage `json:"image" validate:"required"`
}
type ImageMessageConfigs
ImageMessageConfigs is an alias for ImageMessage.
type ImageMessageConfigs = ImageMessage
type InteractiveMessageType
type InteractiveMessageType string
const (
InteractiveMessageTypeButton InteractiveMessageType = "button"
InteractiveMessageTypeProduct InteractiveMessageType = "product"
InteractiveMessageTypeProductList InteractiveMessageType = "product_list"
InteractiveMessageTypeList InteractiveMessageType = "list"
InteractiveMessageTypeCatalog InteractiveMessageType = "catalog_message"
)
type ListMessageApiPayload
ListMessageApiPayload represents the API payload for the list message.
type ListMessageApiPayload struct {
BaseMessagePayload
Interactive listMessage `json:"interactive" validate:"required"` // Interactive message.
}
type ListMessageBody
ListMessageBody represents the body of the list message.
type ListMessageBody struct {
Text string `json:"text" validate:"required"` // Text of the body.
}
type ListMessageParams
ListMessageParams represents the parameters for creating a list message.
type ListMessageParams struct {
ButtonText string `json:"-" validate:"required"` // Text of the button.
BodyText string `json:"-" validate:"required"` // Text of the body.
}
type LocationMessage
LocationMessage represents a location message with latitude, longitude, address, and name.
type LocationMessage struct {
Latitude float64 `json:"latitude" validate:"required"` // Latitude of the location
Longitude float64 `json:"longitude" validate:"required"` // Longitude of the location
Address string `json:"address,omitempty"` // Address of the location (optional)
Name string `json:"name,omitempty"` // Name of the location (optional)
}
func NewLocationMessage
func NewLocationMessage(latitude float64, longitude float64) (*LocationMessage, error)
NewLocationMessage creates a new LocationMessage with the given latitude and longitude.
func (*LocationMessage) SetAddress
func (location *LocationMessage) SetAddress(params string)
SetAddress sets the address of the location.
func (*LocationMessage) SetName
func (location *LocationMessage) SetName(params string)
SetName sets the name of the location.
func (*LocationMessage) ToJson
func (location *LocationMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the LocationMessage to JSON with the given configurations.
type LocationMessageApiPayload
LocationMessageApiPayload represents the API payload for a location message.
type LocationMessageApiPayload struct {
BaseMessagePayload
Location LocationMessage `json:"location" validate:"required"` // Location message
}
type MessageType
MessageType represents the type of message.
Constants for different message types.
const (
MessageTypeLocation MessageType = "location"
MessageTypeAudio MessageType = "audio"
MessageTypeVideo MessageType = "video"
MessageTypeDocument MessageType = "document"
MessageTypeText MessageType = "text"
MessageTypeContact MessageType = "contacts"
MessageTypeInteractive MessageType = "interactive"
MessageTypeTemplate MessageType = "template"
MessageTypeReaction MessageType = "reaction"
MessageTypeSticker MessageType = "sticker"
MessageTypeImage MessageType = "image"
)
type Order
Order represents an order in the system.
type Order struct {
CatalogID string `json:"catalog_id"` // CatalogID is the ID of the catalog associated with the order.
ProductItems []ProductItem `json:"product_items"` // ProductItems is a list of product items in the order.
Text string `json:"text"` // Text is an additional text associated with the order.
}
type PhoneType
const (
CellPhone PhoneType = "CELL"
MainPhone PhoneType = "MAIN"
IphonePhone PhoneType = "IPHONE"
HomePhone PhoneType = "HOME"
WorkPhone PhoneType = "WORK"
)
type Product
type Product struct {
RetailerId string `json:"product_retailer_id" validate:"required"`
}
func (*Product) SetRetailerId
func (p *Product) SetRetailerId(id string)
type ProductItem
ProductItem represents a product item in an order.
type ProductItem struct {
Currency string `json:"currency"` // Currency is the currency of the product item.
ItemPrice string `json:"item_price"` // ItemPrice is the price of the product item.
ProductRetailerID string `json:"product_retailer_id"` // ProductRetailerID is the ID of the retailer associated with the product item.
Quantity string `json:"quantity"` // Quantity is the quantity of the product item.
}
type ProductListMessage
ProductListMessage represents a product list message.
type ProductListMessage struct {
Action ProductListMessageAction `json:"action" validate:"required"`
Body ProductListMessageBody `json:"body" validate:"required"`
Footer *ProductListMessageFooter `json:"footer,omitempty"`
Header ProductListMessageHeader `json:"header,omitempty"`
Type InteractiveMessageType `json:"type" validate:"required"`
}
func NewProductListMessage
func NewProductListMessage(params ProductListMessageParams) (*ProductListMessage, error)
NewProductListMessage creates a new product list message.
func (*ProductListMessage) AddSection
func (message *ProductListMessage) AddSection(section ProductSection)
func (*ProductListMessage) SetBody
func (message *ProductListMessage) SetBody(text string)
func (*ProductListMessage) SetCatalogId
func (message *ProductListMessage) SetCatalogId(catalogId string)
func (message *ProductListMessage) SetFooter(text string)
func (message *ProductListMessage) SetHeader(text string)
func (*ProductListMessage) SetProductRetailerId
func (message *ProductListMessage) SetProductRetailerId(productRetailerId string)
func (*ProductListMessage) ToJson
func (m *ProductListMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the product list message to JSON.
type ProductListMessageAction
type ProductListMessageAction struct {
Sections []ProductSection `json:"sections" validate:"required"` // minimum 1 and maximum 10
CatalogId string `json:"catalog_id" validate:"required"`
ProductRetailerId string `json:"product_retailer_id" validate:"required"`
}
func (*ProductListMessageAction) AddSection
func (a *ProductListMessageAction) AddSection(section ProductSection)
type ProductListMessageApiPayload
ProductListMessageApiPayload represents the API payload for a product list message.
type ProductListMessageApiPayload struct {
BaseMessagePayload
Interactive ProductListMessage `json:"interactive" validate:"required"`
}
type ProductListMessageBody
type ProductListMessageBody struct {
Text string `json:"text" validate:"required"`
}
type ProductListMessageFooter struct {
Text string `json:"text" validate:"required"`
}
! TODO: support more header types
type ProductListMessageHeader struct {
Type ProductListMessageHeaderType `json:"type" validate:"required"`
Text string `json:"text" validate:"required"`
}
type ProductListMessageHeaderType string
const (
ProductListMessageHeaderTypeText ProductListMessageHeaderType = "text"
)
type ProductListMessageParams
ProductListMessageParams represents the parameters for creating a product list message.
type ProductListMessageParams struct {
CatalogId string `validate:"required"`
ProductRetailerId string `validate:"required"`
BodyText string `validate:"required"`
Sections []ProductSection
}
type ProductMessage
ProductMessage represents a product message.
type ProductMessage struct {
Type InteractiveMessageType `json:"type" validate:"required"`
Body *ProductMessageBody `json:"body" validate:"required"`
Footer *ProductMessageFooter `json:"footer,omitempty"`
Header *ProductMessageHeader `json:"header,omitempty"`
Action productMessageAction `json:"action" validate:"required"`
}
func NewProductMessage
func NewProductMessage(params ProductMessageParams) (*ProductMessage, error)
NewProductMessage creates a new product message with the given parameters.
func (*ProductMessage) SetBody
func (m *ProductMessage) SetBody(text string)
func (*ProductMessage) SetCatalogId
func (m *ProductMessage) SetCatalogId(id string)
func (m *ProductMessage) SetFooter(text string)
func (m *ProductMessage) SetHeader(text string)
func (*ProductMessage) SetProductRetailerId
func (m *ProductMessage) SetProductRetailerId(id string)
func (*ProductMessage) ToJson
func (m *ProductMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the product message to JSON with the given configurations.
type ProductMessageApiPayload
ProductMessageApiPayload represents the API payload for a product message.
type ProductMessageApiPayload struct {
BaseMessagePayload
Interactive ProductMessage `json:"interactive" validate:"required"`
}
type ProductMessageBody
type ProductMessageBody struct {
Text string `json:"text" validate:"required"`
}
type ProductMessageFooter struct {
Text string `json:"text" validate:"required"`
}
type ProductMessageHeader struct {
Text string `json:"text" validate:"required"`
}
type ProductMessageParams
ProductMessageParams represents the parameters for creating a product message.
type ProductMessageParams struct {
CatalogId string `validate:"required"`
ProductRetailerId string `validate:"required"`
BodyText string `validate:"required"`
}
type ProductSection
type ProductSection struct {
Title string `json:"title" validate:"required"`
Products []Product `json:"product_items" validate:"required"`
}
func (*ProductSection) AddProduct
func (ps *ProductSection) AddProduct(product Product)
func (*ProductSection) SetTitle
func (ps *ProductSection) SetTitle(title string)
QuickReplyButtonMessage represents a quick reply button message.
type QuickReplyButtonMessage struct {
Type InteractiveMessageType `json:"type" validate:"required"` // Type of the quick reply button message.
Body QuickReplyButtonMessageBody `json:"body" validate:"required"` // Body of the quick reply button message.
Action QuickReplyButtonMessageAction `json:"action" validate:"required"` // Action of the quick reply button message.
}
func NewQuickReplyButtonMessage(bodyText string) (*QuickReplyButtonMessage, error)
NewQuickReplyButtonMessage creates a new quick reply button message with the given body text.
func (m *QuickReplyButtonMessage) AddButton(id, title string) error
func (m *QuickReplyButtonMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the quick reply button message to JSON.
QuickReplyButtonMessageAction represents the action of a quick reply button message.
type QuickReplyButtonMessageAction struct {
Buttons []quickReplyButtonMessageButton `json:"buttons" validate:"required"` // List of quick reply buttons.
}
QuickReplyButtonMessageApiPayload represents the API payload for a quick reply button message.
type QuickReplyButtonMessageApiPayload struct {
BaseMessagePayload
Interactive QuickReplyButtonMessage `json:"interactive" validate:"required"` // Interactive part of the API payload.
}
type QuickReplyButtonMessageBody
QuickReplyButtonMessageBody represents the body of a quick reply button message.
type QuickReplyButtonMessageBody struct {
Text string `json:"text" validate:"required"` // Text of the quick reply button message.
}
type ReactionMessage
ReactionMessage represents a reaction to a message.
type ReactionMessage struct {
MessageId string `json:"message_id" validate:"required"` // The ID of the message to react to.
Emoji string `json:"emoji" validate:"required"` // The emoji representing the reaction.
}
func NewReactionMessage
func NewReactionMessage(params ReactionMessageParams) (*ReactionMessage, error)
NewReactionMessage creates a new ReactionMessage instance.
func (*ReactionMessage) ToJson
func (reaction *ReactionMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the ReactionMessage to JSON.
type ReactionMessageApiPayload
ReactionMessageApiPayload represents the API payload for a reaction message.
type ReactionMessageApiPayload struct {
BaseMessagePayload
Reaction ReactionMessage `json:"reaction" validate:"required"` // The reaction message.
}
type ReactionMessageParams
ReactionMessageParams is an alias for ReactionMessage.
type ReactionMessageParams = ReactionMessage
type StickerMessage
StickerMessage represents a sticker message.
type StickerMessage struct {
Id string `json:"id,omitempty"`
Link string `json:"link,omitempty"`
}
func NewStickerMessage
func NewStickerMessage(params *StickerMessageConfigs) (*StickerMessage, error)
NewStickerMessage creates a new sticker message based on the provided configurations.
func (*StickerMessage) ToJson
func (sticker *StickerMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the sticker message to JSON based on the provided configurations.
type StickerMessageApiPayload
StickerMessageApiPayload represents the API payload for a sticker message.
type StickerMessageApiPayload struct {
BaseMessagePayload
Sticker StickerMessage `json:"sticker" validate:"required"`
}
type StickerMessageConfigs
StickerMessageConfigs represents the configurations for a sticker message.
type StickerMessageConfigs struct {
Id string `json:"id,omitempty"`
Link string `json:"link,omitempty"`
}
type TemplateMessage
TemplateMessage represents a template message.
type TemplateMessage struct {
Name string `json:"name" validate:"required"` // Template name.
Language TemplateMessageLanguage `json:"language" validate:"required"` // Language configuration.
Components []TemplateMessageComponent `json:"components" validate:"required"` // Array of components.
}
func NewTemplateMessage
func NewTemplateMessage(params *TemplateMessageConfigs) (*TemplateMessage, error)
NewTemplateMessage creates a new TemplateMessage instance.
func (*TemplateMessage) AddBody
func (tm *TemplateMessage) AddBody(params TemplateMessageComponentBodyType)
AddBody adds (or overrides) a body component in the template message. Only one body component is allowed.
func (tm *TemplateMessage) AddButton(params TemplateMessageComponentButtonType) error
AddButton adds a button component to the template message. A maximum of 10 buttons is allowed.
func (tm *TemplateMessage) AddHeader(params TemplateMessageComponentHeaderType)
AddHeader adds (or overrides) a header component in the template message. Only one header is allowed.
func (*TemplateMessage) ToJson
func (m *TemplateMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the template message into a JSON payload compatible with the API.
type TemplateMessageApiPayload
TemplateMessageApiPayload represents the API payload for sending a template message.
type TemplateMessageApiPayload struct {
BaseMessagePayload
Template TemplateMessage `json:"template" validate:"required"`
}
type TemplateMessageBodyAndHeaderParameter
TemplateMessageBodyAndHeaderParameter represents parameters for body and header components.
type TemplateMessageBodyAndHeaderParameter struct {
Type TemplateMessageParameterType `json:"type" validate:"required"` // e.g., "text", "currency", etc.
ParameterName *string `json:"parameter_name,omitempty"` // Optional: name of the parameter (for named parameters).
Currency *TemplateMessageParameterCurrency `json:"currency,omitempty"` // Currency details (if type is currency).
DateTime *TemplateMessageParameterDateTime `json:"date_time,omitempty"` // Date/time details (if type is date_time).
Document *TemplateMessageParameterMedia `json:"document,omitempty"` // Document details (if type is document).
Image *TemplateMessageParameterMedia `json:"image,omitempty"` // Image details (if type is image).
Text *string `json:"text,omitempty"` // Text content (if type is text).
Video *TemplateMessageParameterMedia `json:"video,omitempty"` // Video details (if type is video).
Location *TemplateMessageParameterLocation `json:"location,omitempty"` // Location details (if type is location).
Product *TemplateMessageParameterProduct `json:"product,omitempty"` // Product details (if type is product).
}
func (TemplateMessageBodyAndHeaderParameter) GetParameterType
func (t TemplateMessageBodyAndHeaderParameter) GetParameterType() string
GetParameterType returns the parameter type as a string.
TemplateMessageButtonComponentType represents the subtype of a button component.
type TemplateMessageButtonComponentType string
const (
TemplateMessageButtonComponentTypeQuickReply TemplateMessageButtonComponentType = "quick_reply"
TemplateMessageButtonComponentTypeUrl TemplateMessageButtonComponentType = "url"
TemplateMessageButtonComponentTypeCatalog TemplateMessageButtonComponentType = "catalog"
TemplateMessageButtonComponentTypeCopyCode TemplateMessageButtonComponentType = "copy_code"
TemplateMessageButtonComponentTypeMultiProductMessage TemplateMessageButtonComponentType = "mpm"
)
TemplateMessageButtonParameter represents a parameter for a button component.
type TemplateMessageButtonParameter struct {
Type TemplateMessageButtonParameterType `json:"type" validate:"required"` // e.g., "payload" or "text" or "action"
Payload *string `json:"payload,omitempty"` // Required for quick_reply buttons.
Text *string `json:"text,omitempty"` // Required for URL buttons.
Action *TemplateMessageButtonParameterAction `json:"action,omitempty"` // Required for catalog buttons.
CouponCode *string `json:"coupon_code,omitempty"` // Required for copy code button in coupon_code parameter.
}
func (t TemplateMessageButtonParameter) GetParameterType() string
GetParameterType returns the button parameter type as a string.
type TemplateMessageButtonParameterAction struct {
ThumbnailProductRetailerId string `json:"thumbnail_product_retailer_id" validate:"required"`
Sections *[]TemplateMessageMultiProductButtonActionParameterSection `json:"sections,omitempty"` // Required for MPM buttons. UPTO 10 sections in a buttons parameter
}
TemplateMessageButtonParameterType represents the type for button parameters.
type TemplateMessageButtonParameterType string
const (
TemplateMessageButtonParameterTypePayload TemplateMessageButtonParameterType = "payload"
TemplateMessageButtonParameterTypeText TemplateMessageButtonParameterType = "text"
TemplateMessageButtonParameterTypeAction TemplateMessageButtonParameterType = "action"
TemplateMessageButtonParameterTypeCouponCode TemplateMessageButtonParameterType = "coupon_code"
)
type TemplateMessageCaraouselCard
type TemplateMessageCaraouselCard struct {
CardIndex int `json:"card_index" validate:"required"`
Components []TemplateMessageComponent `json:"components" validate:"required"` // only header, buttons and body
}
type TemplateMessageComponent
TemplateMessageComponent is an interface for all template message components.
type TemplateMessageComponent interface {
GetComponentType() string
}
type TemplateMessageComponentBodyType
TemplateMessageComponentBodyType represents a body component.
type TemplateMessageComponentBodyType struct {
Type TemplateMessageComponentType `json:"type" validate:"required"` // "body"
Parameters []TemplateMessageParameter `json:"parameters" validate:"required"` // Parameters for the body component.
}
func (TemplateMessageComponentBodyType) GetComponentType
func (t TemplateMessageComponentBodyType) GetComponentType() string
GetComponentType returns the component type.
TemplateMessageComponentButtonType represents a button component.
type TemplateMessageComponentButtonType struct {
Type TemplateMessageComponentType `json:"type" validate:"required"` // e.g., "button"
SubType TemplateMessageButtonComponentType `json:"sub_type" validate:"required"` // e.g., "quick_reply", "url", etc.
Index int `json:"index" validate:"required"` // Position index of the button (0 to 9)
Parameters *[]TemplateMessageParameter `json:"parameters,omitempty" validate:"required"` // Parameters for the button component.
}
func (t TemplateMessageComponentButtonType) GetComponentType() string
type TemplateMessageComponentCarouselType
type TemplateMessageComponentCarouselType struct {
Type TemplateMessageComponentType `json:"type" validate:"required"` // "carousel"
Cards []TemplateMessageCaraouselCard `json:"cards" validate:"required"`
}
TemplateMessageComponentHeaderType represents a header component.
type TemplateMessageComponentHeaderType struct {
Type TemplateMessageComponentType `json:"type" validate:"required"` // "header"
Parameters *[]TemplateMessageParameter `json:"parameters,omitempty" validate:"required"` // Parameters for the header component.
}
func (t TemplateMessageComponentHeaderType) GetComponentType() string
GetComponentType returns the component type.
type TemplateMessageComponentLimitedTimeOfferType
type TemplateMessageComponentLimitedTimeOfferType struct {
Type TemplateMessageComponentType `json:"type" validate:"required"`
Parameters *[]TemplateMessageLimitedTimeOfferParameter `json:"parameters,omitempty" validate:"required"`
}
func (TemplateMessageComponentLimitedTimeOfferType) GetComponentType
func (t TemplateMessageComponentLimitedTimeOfferType) GetComponentType() string
type TemplateMessageComponentType
TemplateMessageComponentType represents the type of a template message component.
type TemplateMessageComponentType string
const (
TemplateMessageComponentTypeHeader TemplateMessageComponentType = "header"
TemplateMessageComponentTypeBody TemplateMessageComponentType = "body"
TemplateMessageComponentTypeButton TemplateMessageComponentType = "button"
TemplateMessageComponentTypeLimitedTimeOffer TemplateMessageComponentType = "limited_time_offer"
TemplateMessageComponentTypeCarousel TemplateMessageComponentType = "carousel"
)
type TemplateMessageConfigs
TemplateMessageConfigs represents basic configurations for a template message.
type TemplateMessageConfigs struct {
Name string `json:"name" validate:"required"` // Template name.
Language string `json:"language" validate:"required"` // Language code.
}
type TemplateMessageLanguage
TemplateMessageLanguage represents the language configuration.
type TemplateMessageLanguage struct {
Code string `json:"code" validate:"required"` // e.g., "en_US"
Policy string `json:"policy" validate:"required"` // e.g., "deterministic"
}
type TemplateMessageLimitedTimeOfferParameter
type TemplateMessageLimitedTimeOfferParameter struct {
Type TemplateMessageParameterType `json:"type" validate:"required"` // e.g., "text", "currency", etc.
LimitedTimeOffer struct {
ExpirationTimeMs int64 `json:"expiration_time_ms" validate:"required"` // Expiration time in milliseconds.
} `json:"limited_time_offer" validate:"required"`
}
type TemplateMessageMultiProductButtonActionParameterProductItem struct {
ProductRetailerId string `json:"product_retailer_id" validate:"required"`
}
type TemplateMessageMultiProductButtonActionParameterSection struct {
Title string `json:"title" validate:"required"`
// Upto 30 product items only
ProductItems []TemplateMessageMultiProductButtonActionParameterProductItem `json:"product_items" validate:"required"`
}
type TemplateMessageParameter
TemplateMessageParameter is an interface for all parameter types.
type TemplateMessageParameter interface {
GetParameterType() string
}
type TemplateMessageParameterCurrency
TemplateMessageParameterCurrency represents a currency parameter.
type TemplateMessageParameterCurrency struct {
FallbackValue string `json:"fallback_value" validate:"required"` // Default text if localization fails.
Code string `json:"code" validate:"required"` // ISO 4217 currency code.
Amount1000 int `json:"amount_1000" validate:"required"` // Amount multiplied by 1000.
}
type TemplateMessageParameterDateTime
TemplateMessageParameterDateTime represents a date-time parameter.
type TemplateMessageParameterDateTime struct {
FallbackValue string `json:"fallback_value" validate:"required"` // Default text if localization fails.
}
type TemplateMessageParameterLocation
TemplateMessageParameterLocation represents a location parameter.
type TemplateMessageParameterLocation struct {
Latitude string `json:"latitude" validate:"required"` // Latitude.
Longitude string `json:"longitude" validate:"required"` // Longitude.
Name string `json:"name" validate:"required"` // Location name.
Address string `json:"address" validate:"required"` // Address.
}
TemplateMessageParameterMedia represents a media parameter (for document, image, video).
type TemplateMessageParameterMedia struct {
Link string `json:"link" validate:"required"` // URL link of the media.
}
type TemplateMessageParameterProduct
type TemplateMessageParameterProduct struct {
ProductRetailerId string `json:"product_retailer_id" validate:"required"`
CatalogId string `json:"catalog_id" validate:"required"`
}
type TemplateMessageParameterType
TemplateMessageParameterType represents the type of a parameter.
type TemplateMessageParameterType string
const (
TemplateMessageParameterTypeCurrency TemplateMessageParameterType = "currency"
TemplateMessageParameterTypeDateTime TemplateMessageParameterType = "date_time"
TemplateMessageParameterTypeDocument TemplateMessageParameterType = "document"
TemplateMessageParameterTypeImage TemplateMessageParameterType = "image"
TemplateMessageParameterTypeText TemplateMessageParameterType = "text"
TemplateMessageParameterTypeVideo TemplateMessageParameterType = "video"
TemplateMessageParameterTypeLocation TemplateMessageParameterType = "location"
TemplateMessageParameterTypeLimitedTimeOffer TemplateMessageParameterType = "limited_time_offer"
TemplateMessageParameterTypeProduct TemplateMessageParameterType = "product"
)
type TextMessageApiPayload
TextMessageApiPayload represents the payload for the WhatsApp API.
type TextMessageApiPayload struct {
BaseMessagePayload `json:",inline"`
Text TextMessageApiPayloadText `json:"text" validate:"required"` // The text content of the message.
}
type TextMessageApiPayloadText
TextMessageApiPayloadText represents the text payload for the WhatsApp API.
type TextMessageApiPayloadText struct {
Body string `json:"body" validate:"required"` // The text content of the message.
AllowPreview bool `json:"preview_url,omitempty"` // Whether to allow preview of the message.
}
type TextMessageConfigs
TextMessageConfigs represents the configuration options for a text message.
type TextMessageConfigs struct {
Text string `json:"text" validate:"required"` // The text content of the message.
AllowPreview bool `json:"allowPreview,omitempty"` // Whether to allow preview of the message.
}
type UrlType
type VideoMessage
VideoMessage represents a video message.
type VideoMessage struct {
Id string `json:"id,omitempty"`
Link string `json:"link,omitempty"`
Caption string `json:"caption,omitempty"`
}
func NewVideoMessage
func NewVideoMessage(params VideoMessageConfigs) (*VideoMessage, error)
NewVideoMessage creates a new VideoMessage instance.
func (*VideoMessage) SetCaption
func (video *VideoMessage) SetCaption(params string)
SetCaption sets the caption for the video message.
func (*VideoMessage) ToJson
func (video *VideoMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the video message to JSON.
type VideoMessageApiPayload
VideoMessageApiPayload represents the API payload for a video message.
type VideoMessageApiPayload struct {
BaseMessagePayload
Video VideoMessage `json:"video" validate:"required"`
}
type VideoMessageConfigs
VideoMessageConfigs is an alias for VideoMessage.
type VideoMessageConfigs = VideoMessage
type listMessage
listMessage represents an interactive list message.
type listMessage struct {
Type InteractiveMessageType `json:"type" validate:"required"` // Type of the message.
Action listMessageAction `json:"action" validate:"required"` // Action of the message.
Body ListMessageBody `json:"body,omitempty"` // Body of the message.
}
func NewListMessage
func NewListMessage(params ListMessageParams) (*listMessage, error)
NewListMessage creates a new list message with the given parameters.
func (*listMessage) AddSection
func (m *listMessage) AddSection(section *listSection)
AddSection adds a new section to the list message.
func (*listMessage) SetBodyText
func (m *listMessage) SetBodyText(section *listSection)
SetBodyText sets the body text of the list message.
func (*listMessage) ToJson
func (m *listMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the list message to JSON.
type listMessageAction
listMessageAction represents the action of the list message.
type listMessageAction struct {
ButtonText string `json:"button" validate:"required"` // Text of the button.
Sections []listSection `json:"sections" validate:"required"` // Sections in the list message.
}
type listSection
listSection represents a section in the list message.
type listSection struct {
Title string `json:"title" validate:"required"` // Title of the section.
Rows []listSectionRow `json:"rows" validate:"required"` // Rows in the section.
}
func NewListSection
func NewListSection(title string) (*listSection, error)
NewListSection creates a new list section with the given title.
func (*listSection) AddRow
func (section *listSection) AddRow(row *listSectionRow)
AddRow adds a new row to the list section.
func (*listSection) SetTitle
func (section *listSection) SetTitle(title string)
SetTitle sets the title of the list section.
type listSectionRow
listSectionRow represents a row in the list section.
type listSectionRow struct {
Id string `json:"id" validate:"required"` // ID of the row.
Description string `json:"description" validate:"required"` // Description of the row.
Title string `json:"title" validate:"required"` // Title of the row.
}
func NewListSectionRow
func NewListSectionRow(id, title, description string) (*listSectionRow, error)
NewListSectionRow creates a new list section row with the given ID, title, and description.
func (*listSectionRow) SetDescription
func (row *listSectionRow) SetDescription(description string)
SetDescription sets the description of the list section row.
func (*listSectionRow) SetId
func (row *listSectionRow) SetId(id string)
SetId sets the ID of the list section row.
func (*listSectionRow) SetTitle
func (row *listSectionRow) SetTitle(title string)
SetTitle sets the title of the list section row.
type productMessageAction
type productMessageAction struct {
CatalogId string `json:"catalog_id" validate:"required"`
ProductRetailerId string `json:"product_retailer_id" validate:"required"`
}
quickReplyButtonMessageButton represents a quick reply button.
type quickReplyButtonMessageButton struct {
Type string `json:"type" validate:"required"` // Type of the quick reply button.
Reply quickReplyButtonMessageButtonReply `json:"reply" validate:"required"` // Reply structure of the quick reply button.
}
func NewQuickReplyButton(id, title string) (*quickReplyButtonMessageButton, error)
NewQuickReplyButton creates a new quick reply button with the given ID and title.
quickReplyButtonMessageButtonReply represents the reply structure of a quick reply button.
type quickReplyButtonMessageButtonReply struct {
Title string `json:"title" validate:"required"` // Title of the quick reply button.
Id string `json:"id" validate:"required"` // ID of the quick reply button.
}
type textMessage
textMessage represents a text message.
type textMessage struct {
Text string // The text content of the message.
AllowPreview bool // Whether to allow preview of the message.
}
func NewTextMessage
func NewTextMessage(configs TextMessageConfigs) (*textMessage, error)
NewTextMessage creates a new text message with the given configurations.
func (*textMessage) SetText
func (m *textMessage) SetText(text string)
SetText sets the text content of the message.
func (*textMessage) ToJson
func (m *textMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the text message struct to WhatsApp API compatible JSON.