Documentation
¶
Index ¶
- func NewListMessage(params ListMessageParams) (*listMessage, error)
- func NewListSectionRow(id, title, description string) (*listSectionRow, error)
- func NewQuickReplyButton(id, title string) (*quickReplyButtonMessageButton, error)
- func NewTextMessage(configs TextMessageConfigs) (*textMessage, error)
- type AddressType
- type ApiCompatibleJsonConverterConfigs
- type AudioMessage
- type AudioMessageApiPayload
- type AudioMessageConfigs
- type BaseMessage
- type BaseMessagePayload
- type CallToAction
- type CatalogMessage
- type CatalogMessageAction
- type CatalogMessageActionParameter
- type CatalogMessageApiPayload
- type CatalogMessageBody
- type CatalogMessageFooter
- type CatalogMessageHeader
- type 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)
- 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
- type ContactEmail
- type ContactMessage
- type ContactMessageApiPayload
- type ContactMessageConfigs
- type ContactName
- type ContactOrg
- type ContactPhone
- type ContactUrl
- type Context
- type CtaMessage
- func (message *CtaMessage) SetAction(params CtaMessageActionParams)
- func (message *CtaMessage) SetBody(text string)
- func (message *CtaMessage) SetFooter(text string)
- func (message *CtaMessage) SetHeader(text string)
- func (m *CtaMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
- type CtaMessageAction
- type CtaMessageActionParams
- type CtaMessageApiPayload
- type CtaMessageBody
- type CtaMessageFooter
- type CtaMessageHeader
- type CtaMessageHeaderType
- type CtaMessageParams
- type DocumentMessage
- type DocumentMessageApiPayload
- type DocumentMessageConfigs
- type EmailType
- type FlowAction
- type FlowActionPayload
- type FlowMessage
- func (m *FlowMessage) SetFlowAction(action FlowAction, payload *FlowActionPayload)
- func (m *FlowMessage) SetFlowToken(token string)
- func (m *FlowMessage) SetFooter(text string)
- func (m *FlowMessage) SetHeader(text string)
- func (m *FlowMessage) SetMode(mode FlowMessageMode)
- func (m *FlowMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
- type FlowMessageAction
- type FlowMessageActionParams
- type FlowMessageApiPayload
- type FlowMessageBody
- type FlowMessageFooter
- type FlowMessageHeader
- type FlowMessageHeaderType
- type FlowMessageMode
- type FlowMessageParams
- type ImageMessage
- type ImageMessageApiPayload
- type ImageMessageConfigs
- type InteractiveMessageType
- type ListMessageApiPayload
- type ListMessageBody
- type ListMessageFooter
- type ListMessageHeader
- type ListMessageParams
- type ListSection
- type LocationMessage
- type LocationMessageApiPayload
- type LocationRequestMessage
- type LocationRequestMessageApiPayload
- type LocationRequestMessageBody
- type LocationRequestMessageParams
- type MessageType
- type Order
- type PhoneType
- type Product
- type ProductItem
- type ProductListMessage
- func (message *ProductListMessage) AddSection(section ProductSection)
- func (message *ProductListMessage) SetBody(text string)
- func (message *ProductListMessage) SetCatalogId(catalogId string)
- func (message *ProductListMessage) SetFooter(text string)
- func (message *ProductListMessage) SetHeader(text string)
- func (message *ProductListMessage) SetProductRetailerId(productRetailerId string)
- func (m *ProductListMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
- type ProductListMessageAction
- type ProductListMessageApiPayload
- type ProductListMessageBody
- type ProductListMessageFooter
- type ProductListMessageHeader
- type ProductListMessageHeaderType
- type ProductListMessageParams
- type ProductMessage
- func (m *ProductMessage) SetBody(text string)
- func (m *ProductMessage) SetCatalogId(id string)
- func (m *ProductMessage) SetFooter(text string)
- func (m *ProductMessage) SetHeader(text string)
- func (m *ProductMessage) SetProductRetailerId(id string)
- func (m *ProductMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
- type ProductMessageApiPayload
- type ProductMessageBody
- type ProductMessageFooter
- type ProductMessageHeader
- type ProductMessageParams
- type ProductSection
- type QuickReplyButtonMessage
- type QuickReplyButtonMessageAction
- type QuickReplyButtonMessageApiPayload
- type QuickReplyButtonMessageBody
- type QuickReplyButtonMessageFooter
- type QuickReplyButtonMessageHeader
- type ReactionMessage
- type ReactionMessageApiPayload
- type ReactionMessageParams
- type StickerMessage
- type StickerMessageApiPayload
- type StickerMessageConfigs
- type TemplateMessage
- func (tm *TemplateMessage) AddBody(params TemplateMessageComponentBodyType)
- func (tm *TemplateMessage) AddButton(params TemplateMessageComponentButtonType) error
- func (tm *TemplateMessage) AddHeader(params TemplateMessageComponentHeaderType)
- func (m *TemplateMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
- type TemplateMessageApiPayload
- type TemplateMessageBodyAndHeaderParameter
- type TemplateMessageButtonComponentType
- type TemplateMessageButtonParameter
- type TemplateMessageButtonParameterAction
- type TemplateMessageButtonParameterType
- type TemplateMessageCaraouselCard
- type TemplateMessageComponent
- type TemplateMessageComponentBodyType
- type TemplateMessageComponentButtonType
- type TemplateMessageComponentCarouselType
- type TemplateMessageComponentHeaderType
- type TemplateMessageComponentLimitedTimeOfferType
- type TemplateMessageComponentType
- type TemplateMessageConfigs
- type TemplateMessageLanguage
- type TemplateMessageLimitedTimeOfferParameter
- type TemplateMessageMultiProductButtonActionParameterProductItem
- type TemplateMessageMultiProductButtonActionParameterSection
- type TemplateMessageParameter
- type TemplateMessageParameterCurrency
- type TemplateMessageParameterDateTime
- type TemplateMessageParameterLocation
- type TemplateMessageParameterMedia
- type TemplateMessageParameterProduct
- type TemplateMessageParameterType
- type TextMessageApiPayload
- type TextMessageApiPayloadText
- type TextMessageConfigs
- type UrlType
- type VideoMessage
- type VideoMessageApiPayload
- type VideoMessageConfigs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewListMessage ¶
func NewListMessage(params ListMessageParams) (*listMessage, error)
NewListMessage creates a new list message with the given parameters.
func NewListSectionRow ¶
NewListSectionRow creates a new list section row with the given ID, title, and description.
func NewQuickReplyButton ¶
NewQuickReplyButton creates a new quick reply button with the given ID and title.
func NewTextMessage ¶
func NewTextMessage(configs TextMessageConfigs) (*textMessage, error)
NewTextMessage creates a new text message with the given configurations.
Types ¶
type AddressType ¶
type AddressType string
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 AudioMessage ¶
AudioMessage represents an audio message.
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 ¶
type AudioMessageApiPayload struct {
BaseMessagePayload
Audio AudioMessage `json:"audio" validate:"required"`
}
AudioMessageApiPayload represents the payload for an audio message API request.
type AudioMessageConfigs ¶
type AudioMessageConfigs = AudioMessage
AudioMessageConfigs is an alias for AudioMessage.
type BaseMessage ¶
type BaseMessage interface {
ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
}
BaseMessage is an interface for sending messages.
type BaseMessagePayload ¶
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"`
}
BaseMessagePayload represents the base payload to send messages.
func NewBaseMessagePayload ¶
func NewBaseMessagePayload(to string, messageType MessageType) BaseMessagePayload
NewBaseMessagePayload creates a new instance of BaseMessagePayload.
type CallToAction ¶ added in v0.3.5
type CallToAction struct {
DisplayText string `json:"display_text" validate:"required"`
Url string `json:"url" validate:"required"`
}
func (*CallToAction) SetDisplayText ¶ added in v0.3.5
func (p *CallToAction) SetDisplayText(text string)
func (*CallToAction) SetUrl ¶ added in v0.3.5
func (p *CallToAction) SetUrl(url string)
type CatalogMessage ¶
type CatalogMessage struct {
Type InteractiveMessageType `json:"type" validate:"required"`
Action CatalogMessageAction `json:"action" validate:"required"`
Body CatalogMessageBody `json:"body" validate:"required"`
Header *CatalogMessageHeader `json:"header,omitempty"`
}
ProductMessage represents a product message.
func NewCatalogMessage ¶
func NewCatalogMessage(name, thumbnailProductRetailerId string) (*CatalogMessage, error)
func (*CatalogMessage) SetBody ¶
func (m *CatalogMessage) SetBody(text string)
func (*CatalogMessage) SetFooter ¶
func (m *CatalogMessage) SetFooter(text string)
func (*CatalogMessage) SetHeader ¶
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 ¶
type CatalogMessageApiPayload struct {
BaseMessagePayload
Interactive CatalogMessage `json:"interactive" validate:"required"`
}
ProductMessageApiPayload represents the API payload for a product message.
type CatalogMessageBody ¶
type CatalogMessageBody struct {
Text string `json:"text" validate:"required"`
}
type CatalogMessageFooter ¶
type CatalogMessageFooter struct {
}
type CatalogMessageHeader ¶
type CatalogMessageHeader struct {
Text string `json:"text" validate:"required"`
}
type Contact ¶
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 ¶
func NewContact(name ContactName) *Contact
func (*Contact) AddEmail ¶
func (contact *Contact) AddEmail(params ContactEmail)
func (*Contact) AddPhone ¶
func (contact *Contact) AddPhone(params ContactPhone)
func (*Contact) AddUrl ¶
func (contact *Contact) AddUrl(params ContactUrl)
func (*Contact) SetBirthday ¶
! TODO: add regex check here in the params
func (*Contact) SetFirstName ¶
func (*Contact) SetLastName ¶
func (*Contact) SetMiddleName ¶
func (*Contact) SetOrg ¶
func (contact *Contact) SetOrg(params ContactOrg)
type ContactAddress ¶
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 ¶
type ContactMessage ¶
type ContactMessage struct {
Contacts []Contact `json:"contacts" validate:"required"`
}
func NewContactMessage ¶
func NewContactMessage(configs []Contact) (*ContactMessage, error)
func (*ContactMessage) AddContact ¶
func (contact *ContactMessage) AddContact(params Contact)
func (*ContactMessage) ToJson ¶
func (m *ContactMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
type ContactMessageApiPayload ¶
type ContactMessageApiPayload struct {
BaseMessagePayload
Contacts []Contact `json:"contacts" validate:"required"`
}
type ContactMessageConfigs ¶
type ContactMessageConfigs struct {
Name string `json:"name" validate:"required"`
}
type ContactName ¶
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 ¶
type ContactPhone ¶
type ContactUrl ¶
type Context ¶
type Context struct {
MessageId string `json:"message_id,omitempty"`
}
Context represents the context of the message.
type CtaMessage ¶ added in v0.3.5
type CtaMessage struct {
Action CtaMessageAction `json:"action" validate:"required"`
Body CtaMessageBody `json:"body" validate:"required"`
Header CtaMessageHeader `json:"header,omitempty"`
Type InteractiveMessageType `json:"type" validate:"required"`
}
CtaMessage represents a cta message.
func NewCtaMessage ¶ added in v0.3.5
func NewCtaMessage(params CtaMessageParams) (*CtaMessage, error)
NewCtaMessage creates a new cta message.
func (*CtaMessage) SetAction ¶ added in v0.3.5
func (message *CtaMessage) SetAction(params CtaMessageActionParams)
func (*CtaMessage) SetBody ¶ added in v0.3.5
func (message *CtaMessage) SetBody(text string)
func (*CtaMessage) SetFooter ¶ added in v0.3.5
func (message *CtaMessage) SetFooter(text string)
func (*CtaMessage) SetHeader ¶ added in v0.3.5
func (message *CtaMessage) SetHeader(text string)
func (*CtaMessage) ToJson ¶ added in v0.3.5
func (m *CtaMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the cta message to JSON.
type CtaMessageAction ¶ added in v0.3.5
type CtaMessageAction struct {
Name string `json:"name" validate:"required"`
Parameters CtaMessageActionParams `json:"parameters" validate:"required"`
}
type CtaMessageActionParams ¶ added in v0.3.5
type CtaMessageApiPayload ¶ added in v0.3.5
type CtaMessageApiPayload struct {
BaseMessagePayload
Interactive CtaMessage `json:"interactive" validate:"required"`
}
CtaMessageApiPayload represents the API payload for a cta message.
type CtaMessageBody ¶ added in v0.3.5
type CtaMessageBody struct {
Text string `json:"text" validate:"required"`
}
type CtaMessageFooter ¶ added in v0.3.5
type CtaMessageFooter struct {
}
type CtaMessageHeader ¶ added in v0.3.5
type CtaMessageHeader struct {
Type CtaMessageHeaderType `json:"type" validate:"required"`
Text string `json:"text"`
}
! TODO: support more header types
type CtaMessageHeaderType ¶ added in v0.3.5
type CtaMessageHeaderType string
const (
CtaMessageHeaderTypeText CtaMessageHeaderType = "text"
)
type CtaMessageParams ¶ added in v0.3.5
type CtaMessageParams struct {
BodyText string `validate:"required"`
}
CtaMessageParams represents the parameters for creating a cta message.
type DocumentMessage ¶
type DocumentMessage struct {
Id string `json:"id,omitempty"`
Link *string `json:"link,omitempty"`
Caption *string `json:"caption,omitempty"`
FileName string `json:"filename" validate:"required"`
}
DocumentMessage represents a document message.
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 ¶
type DocumentMessageApiPayload struct {
BaseMessagePayload
Document DocumentMessage `json:"document" validate:"required"`
}
DocumentMessageApiPayload represents the API payload for a document message.
type DocumentMessageConfigs ¶
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"`
}
DocumentMessageConfigs represents the configurations for a document message.
type FlowAction ¶ added in v0.9.30
type FlowAction string
FlowAction represents the action type for a flow
const ( FlowActionNavigate FlowAction = "navigate" // FlowActionDataExchange sends data to WhatsApp Flows Data Endpoint FlowActionDataExchange FlowAction = "data_exchange" )
type FlowActionPayload ¶ added in v0.9.30
type FlowActionPayload struct {
// Screen is the unique ID of the Screen to navigate to
// Default is "FIRST_ENTRY_SCREEN"
Screen string `json:"screen,omitempty"`
// Data is the input data for the screen
Data map[string]interface{} `json:"data,omitempty"`
}
FlowActionPayload contains the payload for navigate action
type FlowMessage ¶ added in v0.9.30
type FlowMessage struct {
Type InteractiveMessageType `json:"type" validate:"required"`
Header *FlowMessageHeader `json:"header,omitempty"`
Body FlowMessageBody `json:"body" validate:"required"`
Action FlowMessageAction `json:"action" validate:"required"`
}
FlowMessage represents an interactive flow message See: https://developers.facebook.com/docs/whatsapp/flows/gettingstarted/sendingaflow
func NewFlowMessage ¶ added in v0.9.30
func NewFlowMessage(params FlowMessageParams) (*FlowMessage, error)
NewFlowMessage creates a new flow message for user-initiated conversations
func (*FlowMessage) SetFlowAction ¶ added in v0.9.30
func (m *FlowMessage) SetFlowAction(action FlowAction, payload *FlowActionPayload)
SetFlowAction sets the flow action and optional payload
func (*FlowMessage) SetFlowToken ¶ added in v0.9.30
func (m *FlowMessage) SetFlowToken(token string)
SetFlowToken sets the flow token for authentication
func (*FlowMessage) SetFooter ¶ added in v0.9.30
func (m *FlowMessage) SetFooter(text string)
SetFooter sets the footer text for the flow message
func (*FlowMessage) SetHeader ¶ added in v0.9.30
func (m *FlowMessage) SetHeader(text string)
SetHeader sets the text header for the flow message
func (*FlowMessage) SetMode ¶ added in v0.9.30
func (m *FlowMessage) SetMode(mode FlowMessageMode)
SetMode sets the flow mode (draft or published)
func (*FlowMessage) ToJson ¶ added in v0.9.30
func (m *FlowMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the flow message to JSON for the WhatsApp Cloud API
type FlowMessageAction ¶ added in v0.9.30
type FlowMessageAction struct {
// Name must be "flow"
Name string `json:"name" validate:"required"`
// Parameters contains the flow action parameters
Parameters FlowMessageActionParams `json:"parameters" validate:"required"`
}
FlowMessageAction represents the action for a flow message
type FlowMessageActionParams ¶ added in v0.9.30
type FlowMessageActionParams struct {
// FlowMessageVersion is required, typically "3"
FlowMessageVersion string `json:"flow_message_version" validate:"required"`
// FlowID is the unique identifier for the flow (either FlowID or FlowName required)
FlowID string `json:"flow_id,omitempty"`
// FlowName is the name of the flow (either FlowID or FlowName required)
FlowName string `json:"flow_name,omitempty"`
// FlowCTA is the call to action button text (required)
FlowCTA string `json:"flow_cta" validate:"required"`
// FlowToken is an optional token to authenticate the flow, default is "unused"
FlowToken string `json:"flow_token,omitempty"`
// FlowAction is either "navigate" or "data_exchange", default is "navigate"
FlowAction FlowAction `json:"flow_action,omitempty"`
// FlowActionPayload contains screen and data for navigate action
FlowActionPayload *FlowActionPayload `json:"flow_action_payload,omitempty"`
// Mode is "draft" or "published", default is "published"
Mode FlowMessageMode `json:"mode,omitempty"`
}
FlowMessageActionParams contains the parameters for a flow action See: https://developers.facebook.com/docs/whatsapp/flows/gettingstarted/sendingaflow
type FlowMessageApiPayload ¶ added in v0.9.30
type FlowMessageApiPayload struct {
BaseMessagePayload
Interactive FlowMessage `json:"interactive" validate:"required"`
}
FlowMessageApiPayload represents the API payload for a flow message
type FlowMessageBody ¶ added in v0.9.30
type FlowMessageBody struct {
Text string `json:"text" validate:"required"`
}
FlowMessageBody represents the body of a flow message
type FlowMessageFooter ¶ added in v0.9.30
type FlowMessageFooter struct {
}
FlowMessageFooter represents the footer of a flow message
type FlowMessageHeader ¶ added in v0.9.30
type FlowMessageHeader struct {
Type FlowMessageHeaderType `json:"type" validate:"required"`
Text string `json:"text,omitempty"`
}
FlowMessageHeader represents the header of a flow message
type FlowMessageHeaderType ¶ added in v0.9.30
type FlowMessageHeaderType string
FlowMessageHeaderType defines the type of header
const (
FlowMessageHeaderTypeText FlowMessageHeaderType = "text"
)
type FlowMessageMode ¶ added in v0.9.30
type FlowMessageMode string
FlowMessageMode represents the mode for sending a flow
const ( // FlowMessageModeDraft sends the current draft version of the flow FlowMessageModeDraft FlowMessageMode = "draft" // FlowMessageModePublished sends the last published version of the flow FlowMessageModePublished FlowMessageMode = "published" )
type FlowMessageParams ¶ added in v0.9.30
type FlowMessageParams struct {
// BodyText is the message body text (required)
BodyText string `validate:"required"`
// FlowID is the unique ID of the flow (either FlowID or FlowName required)
FlowID string
// FlowName is the name of the flow (either FlowID or FlowName required)
FlowName string
// FlowCTA is the call to action button text (required)
FlowCTA string `validate:"required"`
// FlowMessageVersion is the version of flow message protocol, default is "3"
FlowMessageVersion string
}
FlowMessageParams contains parameters for creating a new flow message
type ImageMessage ¶
type ImageMessage struct {
Id string `json:"id,omitempty"`
Link string `json:"link,omitempty"`
Caption string `json:"caption,omitempty"`
}
ImageMessage represents a message with an image.
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 ¶
type ImageMessageApiPayload struct {
BaseMessagePayload
Image ImageMessage `json:"image" validate:"required"`
}
ImageMessageApiPayload represents the API payload for an image message.
type ImageMessageConfigs ¶
type ImageMessageConfigs = ImageMessage
ImageMessageConfigs is an alias for ImageMessage.
type InteractiveMessageType ¶
type InteractiveMessageType string
const ( InteractiveMessageTypeButton InteractiveMessageType = "button" InteractiveMessageTypeProduct InteractiveMessageType = "product" InteractiveMessageTypeProductList InteractiveMessageType = "product_list" InteractiveMessageTypeCta InteractiveMessageType = "cta_url" InteractiveMessageTypeList InteractiveMessageType = "list" InteractiveMessageTypeCatalog InteractiveMessageType = "catalog_message" InteractiveMessageTypeLocationRequest InteractiveMessageType = "location_request_message" InteractiveMessageTypeFlow InteractiveMessageType = "flow" )
type ListMessageApiPayload ¶
type ListMessageApiPayload struct {
BaseMessagePayload
Interactive listMessage `json:"interactive" validate:"required"` // Interactive message.
}
ListMessageApiPayload represents the API payload for the list message.
type ListMessageBody ¶
type ListMessageBody struct {
Text string `json:"text" validate:"required"` // Text of the body.
}
ListMessageBody represents the body of the list message.
type ListMessageFooter ¶ added in v0.3.5
type ListMessageFooter struct {
}
ListMessageFooter represents the footer of the list message.
type ListMessageHeader ¶ added in v0.3.5
type ListMessageParams ¶
type ListMessageParams struct {
ButtonText string `json:"-" validate:"required"` // Text of the button.
BodyText string `json:"-" validate:"required"` // Text of the body.
}
ListMessageParams represents the parameters for creating a list message.
type ListSection ¶
type ListSection struct {
Title string `json:"title" validate:"required"` // Title of the section.
Rows []listSectionRow `json:"rows" validate:"required"` // Rows in the section.
}
ListSection represents a section in the list message.
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 LocationMessage ¶
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)
}
LocationMessage represents a location message with latitude, longitude, address, and name.
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 ¶
type LocationMessageApiPayload struct {
BaseMessagePayload
Location LocationMessage `json:"location" validate:"required"` // Location message
}
LocationMessageApiPayload represents the API payload for a location message.
type LocationRequestMessage ¶ added in v0.3.5
type LocationRequestMessage struct {
Type InteractiveMessageType `json:"type" validate:"required"` // Type of the message.
Action locationMessageAction `json:"action" validate:"required"` // Action of the message.
Body LocationRequestMessageBody `json:"body,omitempty"` // Body of the message.
}
func NewLocationRequestMessage ¶ added in v0.3.5
func NewLocationRequestMessage(params LocationRequestMessageParams) (*LocationRequestMessage, error)
func (*LocationRequestMessage) SetBodyText ¶ added in v0.3.5
func (m *LocationRequestMessage) SetBodyText(bodyText string)
SetBodyText sets the body text of the list message.
func (*LocationRequestMessage) ToJson ¶ added in v0.3.5
func (m *LocationRequestMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the list message to JSON.
type LocationRequestMessageApiPayload ¶ added in v0.3.5
type LocationRequestMessageApiPayload struct {
BaseMessagePayload
Interactive LocationRequestMessage `json:"interactive" validate:"required"` // Interactive message.
}
type LocationRequestMessageBody ¶ added in v0.3.5
type LocationRequestMessageBody struct {
Text string `json:"text" validate:"required"` // Text of the body.
}
type LocationRequestMessageParams ¶ added in v0.3.5
type LocationRequestMessageParams struct {
BodyText string `json:"-" validate:"required"` // Text of the body.
}
type MessageType ¶
type MessageType string
MessageType represents the type of message.
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" )
Constants for different message types.
type Order ¶
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.
}
Order represents an order in the system.
type Product ¶
type Product struct {
RetailerId string `json:"product_retailer_id" validate:"required"`
}
func (*Product) SetRetailerId ¶
type ProductItem ¶
type ProductItem struct {
Currency string `json:"currency"` // Currency is the currency of the product item.
ItemPrice float64 `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 int `json:"quantity"` // Quantity is the quantity of the product item.
}
ProductItem represents a product item in an order.
type ProductListMessage ¶
type ProductListMessage struct {
Action ProductListMessageAction `json:"action" validate:"required"`
Body ProductListMessageBody `json:"body" validate:"required"`
Header *ProductListMessageHeader `json:"header,omitempty"`
Type InteractiveMessageType `json:"type" validate:"required"`
}
ProductListMessage represents a product list message.
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 (*ProductListMessage) SetFooter ¶
func (message *ProductListMessage) SetFooter(text string)
func (*ProductListMessage) SetHeader ¶
func (message *ProductListMessage) SetHeader(text string)
func (*ProductListMessage) SetProductRetailerId ¶
func (message *ProductListMessage) SetProductRetailerId(productRetailerId string)
SetProductRetailerId is deprecated. Product retailer IDs belong to each item. This method is kept for backward compatibility and is now a no-op.
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"`
}
func (*ProductListMessageAction) AddSection ¶
func (a *ProductListMessageAction) AddSection(section ProductSection)
type ProductListMessageApiPayload ¶
type ProductListMessageApiPayload struct {
BaseMessagePayload
Interactive ProductListMessage `json:"interactive" validate:"required"`
}
ProductListMessageApiPayload represents the API payload for a product list message.
type ProductListMessageBody ¶
type ProductListMessageBody struct {
Text string `json:"text" validate:"required"`
}
type ProductListMessageFooter ¶
type ProductListMessageFooter struct {
}
type ProductListMessageHeader ¶
type ProductListMessageHeader struct {
Type ProductListMessageHeaderType `json:"type" validate:"required"`
Text string `json:"text" validate:"required"`
}
! TODO: support more header types
type ProductListMessageHeaderType ¶
type ProductListMessageHeaderType string
const (
ProductListMessageHeaderTypeText ProductListMessageHeaderType = "text"
)
type ProductListMessageParams ¶
type ProductListMessageParams struct {
CatalogId string `validate:"required"`
// Deprecated: action-level product_retailer_id. Use item-level IDs in sections.
ProductRetailerId string
BodyText string `validate:"required"`
Sections []ProductSection
}
ProductListMessageParams represents the parameters for creating a product list message.
type ProductMessage ¶
type ProductMessage struct {
Type InteractiveMessageType `json:"type" validate:"required"`
Body *ProductMessageBody `json:"body" validate:"required"`
Header *ProductMessageHeader `json:"header,omitempty"`
Action productMessageAction `json:"action" validate:"required"`
}
ProductMessage represents a product message.
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 (*ProductMessage) SetFooter ¶
func (m *ProductMessage) SetFooter(text string)
func (*ProductMessage) SetHeader ¶
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 ¶
type ProductMessageApiPayload struct {
BaseMessagePayload
Interactive ProductMessage `json:"interactive" validate:"required"`
}
ProductMessageApiPayload represents the API payload for a product message.
type ProductMessageBody ¶
type ProductMessageBody struct {
Text string `json:"text" validate:"required"`
}
type ProductMessageFooter ¶
type ProductMessageFooter struct {
}
type ProductMessageHeader ¶
type ProductMessageHeader struct {
Text string `json:"text" validate:"required"`
}
type ProductMessageParams ¶
type ProductMessageParams struct {
CatalogId string `validate:"required"`
ProductRetailerId string `validate:"required"`
BodyText string `validate:"required"`
}
ProductMessageParams represents the parameters for creating a product message.
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)
type QuickReplyButtonMessage ¶
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.
Header *QuickReplyButtonMessageHeader `json:"header,omitempty"` // Header of the quick reply button message.
}
QuickReplyButtonMessage represents a quick reply button message.
func NewQuickReplyButtonMessage ¶
func NewQuickReplyButtonMessage(bodyText string) (*QuickReplyButtonMessage, error)
NewQuickReplyButtonMessage creates a new quick reply button message with the given body text.
func (*QuickReplyButtonMessage) AddButton ¶
func (m *QuickReplyButtonMessage) AddButton(id, title string) error
func (*QuickReplyButtonMessage) SetFooter ¶ added in v0.3.5
func (m *QuickReplyButtonMessage) SetFooter(text string)
func (*QuickReplyButtonMessage) SetHeader ¶ added in v0.3.5
func (m *QuickReplyButtonMessage) SetHeader(text string)
func (*QuickReplyButtonMessage) ToJson ¶
func (m *QuickReplyButtonMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
ToJson converts the quick reply button message to JSON.
type QuickReplyButtonMessageAction ¶
type QuickReplyButtonMessageAction struct {
Buttons []quickReplyButtonMessageButton `json:"buttons" validate:"required"` // List of quick reply buttons.
}
QuickReplyButtonMessageAction represents the action of a quick reply button message.
type QuickReplyButtonMessageApiPayload ¶
type QuickReplyButtonMessageApiPayload struct {
BaseMessagePayload
Interactive QuickReplyButtonMessage `json:"interactive" validate:"required"` // Interactive part of the API payload.
}
QuickReplyButtonMessageApiPayload represents the API payload for a quick reply button message.
type QuickReplyButtonMessageBody ¶
type QuickReplyButtonMessageBody struct {
Text string `json:"text" validate:"required"` // Text of the quick reply button message.
}
QuickReplyButtonMessageBody represents the body of a quick reply button message.
type QuickReplyButtonMessageFooter ¶ added in v0.3.5
type QuickReplyButtonMessageFooter struct {
}
QuickReplyButtonMessageFooter represents the footer of a quick reply button message.
type QuickReplyButtonMessageHeader ¶ added in v0.3.5
type ReactionMessage ¶
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.
}
ReactionMessage represents a reaction to a message.
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 ¶
type ReactionMessageApiPayload struct {
BaseMessagePayload
Reaction ReactionMessage `json:"reaction" validate:"required"` // The reaction message.
}
ReactionMessageApiPayload represents the API payload for a reaction message.
type ReactionMessageParams ¶
type ReactionMessageParams = ReactionMessage
ReactionMessageParams is an alias for ReactionMessage.
type StickerMessage ¶
StickerMessage represents a sticker message.
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 ¶
type StickerMessageApiPayload struct {
BaseMessagePayload
Sticker StickerMessage `json:"sticker" validate:"required"`
}
StickerMessageApiPayload represents the API payload for a sticker message.
type StickerMessageConfigs ¶
type StickerMessageConfigs struct {
Id string `json:"id,omitempty"`
Link string `json:"link,omitempty"`
}
StickerMessageConfigs represents the configurations for a sticker message.
type TemplateMessage ¶
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.
}
TemplateMessage represents a template message.
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 (*TemplateMessage) AddButton ¶
func (tm *TemplateMessage) AddButton(params TemplateMessageComponentButtonType) error
AddButton adds a button component to the template message. A maximum of 10 buttons is allowed.
func (*TemplateMessage) AddHeader ¶
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 ¶
type TemplateMessageApiPayload struct {
BaseMessagePayload
Template TemplateMessage `json:"template" validate:"required"`
}
TemplateMessageApiPayload represents the API payload for sending a template message.
type TemplateMessageBodyAndHeaderParameter ¶
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).
}
TemplateMessageBodyAndHeaderParameter represents parameters for body and header components.
func (TemplateMessageBodyAndHeaderParameter) GetParameterType ¶
func (t TemplateMessageBodyAndHeaderParameter) GetParameterType() string
GetParameterType returns the parameter type as a string.
type TemplateMessageButtonComponentType ¶
type TemplateMessageButtonComponentType string
TemplateMessageButtonComponentType represents the subtype of a button component.
const ( TemplateMessageButtonComponentTypeQuickReply TemplateMessageButtonComponentType = "quick_reply" TemplateMessageButtonComponentTypeUrl TemplateMessageButtonComponentType = "url" TemplateMessageButtonComponentTypeCatalog TemplateMessageButtonComponentType = "catalog" TemplateMessageButtonComponentTypeCopyCode TemplateMessageButtonComponentType = "copy_code" TemplateMessageButtonComponentTypeMultiProductMessage TemplateMessageButtonComponentType = "mpm" )
type TemplateMessageButtonParameter ¶
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.
}
TemplateMessageButtonParameter represents a parameter for a button component.
func (TemplateMessageButtonParameter) GetParameterType ¶
func (t TemplateMessageButtonParameter) GetParameterType() string
GetParameterType returns the button parameter type as a string.
type TemplateMessageButtonParameterAction ¶
type TemplateMessageButtonParameterAction struct {
ThumbnailProductRetailerId string `json:"thumbnail_product_retailer_id,omitempty"`
Sections *[]TemplateMessageMultiProductButtonActionParameterSection `json:"sections,omitempty"` // Required for MPM buttons. UPTO 10 sections in a buttons parameter
}
TemplateMessageButtonParameterAction represents the action parameters for catalog buttons. Per WhatsApp API docs, thumbnail_product_retailer_id is optional - if omitted, WhatsApp automatically uses the first product in the catalog as the thumbnail.
type TemplateMessageButtonParameterType ¶
type TemplateMessageButtonParameterType string
TemplateMessageButtonParameterType represents the type for button parameters.
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 ¶
type TemplateMessageComponent interface {
GetComponentType() string
}
TemplateMessageComponent is an interface for all template message components.
type TemplateMessageComponentBodyType ¶
type TemplateMessageComponentBodyType struct {
Type TemplateMessageComponentType `json:"type" validate:"required"` // "body"
Parameters []TemplateMessageParameter `json:"parameters" validate:"required"` // Parameters for the body component.
}
TemplateMessageComponentBodyType represents a body component.
func (TemplateMessageComponentBodyType) GetComponentType ¶
func (t TemplateMessageComponentBodyType) GetComponentType() string
GetComponentType returns the component type.
type TemplateMessageComponentButtonType ¶
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.
}
TemplateMessageComponentButtonType represents a button component.
func (TemplateMessageComponentButtonType) GetComponentType ¶
func (t TemplateMessageComponentButtonType) GetComponentType() string
type TemplateMessageComponentCarouselType ¶
type TemplateMessageComponentCarouselType struct {
Type TemplateMessageComponentType `json:"type" validate:"required"` // "carousel"
Cards []TemplateMessageCaraouselCard `json:"cards" validate:"required"`
}
type TemplateMessageComponentHeaderType ¶
type TemplateMessageComponentHeaderType struct {
Type TemplateMessageComponentType `json:"type" validate:"required"` // "header"
Parameters *[]TemplateMessageParameter `json:"parameters,omitempty" validate:"required"` // Parameters for the header component.
}
TemplateMessageComponentHeaderType represents a header component.
func (TemplateMessageComponentHeaderType) GetComponentType ¶
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 ¶
type TemplateMessageComponentType string
TemplateMessageComponentType represents the type of a template message component.
const ( TemplateMessageComponentTypeHeader TemplateMessageComponentType = "header" TemplateMessageComponentTypeBody TemplateMessageComponentType = "body" TemplateMessageComponentTypeButton TemplateMessageComponentType = "button" TemplateMessageComponentTypeLimitedTimeOffer TemplateMessageComponentType = "limited_time_offer" TemplateMessageComponentTypeCarousel TemplateMessageComponentType = "carousel" )
type TemplateMessageConfigs ¶
type TemplateMessageConfigs struct {
Name string `json:"name" validate:"required"` // Template name.
Language string `json:"language" validate:"required"` // Language code.
}
TemplateMessageConfigs represents basic configurations for a template message.
type TemplateMessageLanguage ¶
type TemplateMessageLanguage struct {
Code string `json:"code" validate:"required"` // e.g., "en_US"
Policy string `json:"policy" validate:"required"` // e.g., "deterministic"
}
TemplateMessageLanguage represents the language configuration.
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 ¶
type TemplateMessageMultiProductButtonActionParameterProductItem struct {
ProductRetailerId string `json:"product_retailer_id" validate:"required"`
}
type TemplateMessageMultiProductButtonActionParameterSection ¶
type TemplateMessageMultiProductButtonActionParameterSection struct {
Title string `json:"title" validate:"required"`
// Upto 30 product items only
ProductItems []TemplateMessageMultiProductButtonActionParameterProductItem `json:"product_items" validate:"required"`
}
type TemplateMessageParameter ¶
type TemplateMessageParameter interface {
GetParameterType() string
}
TemplateMessageParameter is an interface for all parameter types.
type TemplateMessageParameterCurrency ¶
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.
}
TemplateMessageParameterCurrency represents a currency parameter.
type TemplateMessageParameterDateTime ¶
type TemplateMessageParameterDateTime struct {
FallbackValue string `json:"fallback_value" validate:"required"` // Default text if localization fails.
}
TemplateMessageParameterDateTime represents a date-time parameter.
type TemplateMessageParameterLocation ¶
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.
}
TemplateMessageParameterLocation represents a location parameter.
type TemplateMessageParameterMedia ¶
type TemplateMessageParameterMedia struct {
Link string `json:"link" validate:"required"` // URL link of the media.
}
TemplateMessageParameterMedia represents a media parameter (for document, image, video).
type TemplateMessageParameterType ¶
type TemplateMessageParameterType string
TemplateMessageParameterType represents the type of a parameter.
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 ¶
type TextMessageApiPayload struct {
BaseMessagePayload `json:",inline"`
Text TextMessageApiPayloadText `json:"text" validate:"required"` // The text content of the message.
}
TextMessageApiPayload represents the payload for the WhatsApp API.
type TextMessageApiPayloadText ¶
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.
}
TextMessageApiPayloadText represents the text payload for the WhatsApp API.
type TextMessageConfigs ¶
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.
}
TextMessageConfigs represents the configuration options for a text message.
type VideoMessage ¶
type VideoMessage struct {
Id string `json:"id,omitempty"`
Link string `json:"link,omitempty"`
Caption string `json:"caption,omitempty"`
}
VideoMessage represents a video message.
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 ¶
type VideoMessageApiPayload struct {
BaseMessagePayload
Video VideoMessage `json:"video" validate:"required"`
}
VideoMessageApiPayload represents the API payload for a video message.
type VideoMessageConfigs ¶
type VideoMessageConfigs = VideoMessage
VideoMessageConfigs is an alias for VideoMessage.
Source Files
¶
- audio_message.go
- base_message.go
- catalog_message.go
- contact_message.go
- cta_message.go
- document_message.go
- flow_message.go
- image_message.go
- interactive_message.go
- list_message.go
- location_message.go
- location_request_message.go
- order.go
- product_list_message.go
- product_message.go
- quick_reply_button_message.go
- reaction_message.go
- sticker_message.go
- template_message.go
- text_message.go
- video_message.go