components

package
v0.7.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2026 License: Apache-2.0 Imports: 3 Imported by: 3 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

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

func NewListSectionRow(id, title, description string) (*listSectionRow, error)

NewListSectionRow creates a new list section row with the given ID, title, and description.

func NewQuickReplyButton

func NewQuickReplyButton(id, title string) (*quickReplyButtonMessageButton, error)

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

type ApiCompatibleJsonConverterConfigs struct {
	ReplyToMessageId  string
	SendToPhoneNumber string
}

ApiCompatibleJsonConverterConfigs represents the configuration for converting to JSON.

type AudioMessage

type AudioMessage struct {
	Id   string `json:"id,omitempty"`
	Link string `json:"link,omitempty"`
}

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.6.0

type CallToAction struct {
	DisplayText string `json:"display_text" validate:"required"`
	Url         string `json:"url" validate:"required"`
}

func (*CallToAction) SetDisplayText added in v0.6.0

func (p *CallToAction) SetDisplayText(text string)

func (*CallToAction) SetUrl added in v0.6.0

func (p *CallToAction) SetUrl(url string)

type CatalogMessage added in v0.2.0

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"`
}

ProductMessage represents a product message.

func NewCatalogMessage added in v0.2.0

func NewCatalogMessage(name, thumbnailProductRetailerId string) (*CatalogMessage, error)

func (*CatalogMessage) SetBody added in v0.2.0

func (m *CatalogMessage) SetBody(text string)

func (*CatalogMessage) SetFooter added in v0.2.0

func (m *CatalogMessage) SetFooter(text string)

func (*CatalogMessage) SetHeader added in v0.2.0

func (m *CatalogMessage) SetHeader(text string)

func (*CatalogMessage) ToJson added in v0.2.0

ToJson converts the product message to JSON with the given configurations.

type CatalogMessageAction added in v0.2.0

type CatalogMessageAction struct {
	Name       string                        `json:"name" validate:"required"`
	Parameters CatalogMessageActionParameter `json:"parameters,omitempty"`
}

type CatalogMessageActionParameter added in v0.2.1

type CatalogMessageActionParameter struct {
	ThumbnailProductRetailerId string `json:"thumbnail_product_retailer_id" validate:"required"`
}

type CatalogMessageApiPayload added in v0.2.0

type CatalogMessageApiPayload struct {
	BaseMessagePayload
	Interactive CatalogMessage `json:"interactive" validate:"required"`
}

ProductMessageApiPayload represents the API payload for a product message.

type CatalogMessageBody added in v0.2.0

type CatalogMessageBody struct {
	Text string `json:"text" validate:"required"`
}

type CatalogMessageFooter added in v0.2.0

type CatalogMessageFooter struct {
	Text string `json:"text" validate:"required"`
}

type CatalogMessageHeader added in v0.2.0

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

func (contact *Contact) SetBirthday(params string)

! TODO: add regex check here in the params

func (*Contact) SetFirstName

func (contact *Contact) SetFirstName(firstName string)

func (*Contact) SetLastName

func (contact *Contact) SetLastName(lastName string)

func (*Contact) SetMiddleName

func (contact *Contact) SetMiddleName(middleName string)

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 ContactEmail struct {
	Email string    `json:"email,omitempty"`
	Type  EmailType `json:"type,omitempty"`
}

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

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 ContactOrg struct {
	Company    string `json:"company,omitempty"`
	Title      string `json:"title,omitempty"`
	Department string `json:"department,omitempty"`
}

type ContactPhone

type ContactPhone struct {
	Phone string    `json:"phone,omitempty"`
	WaId  string    `json:"wa_id,omitempty"`
	Type  PhoneType `json:"type" validate:"required"`
}

type ContactUrl

type ContactUrl struct {
	Url  string  `json:"url" validate:"required"`
	Type UrlType `json:"type" validate:"required"`
}

type Context

type Context struct {
	MessageId string `json:"message_id,omitempty"`
}

Context represents the context of the message.

type CtaMessage added in v0.6.0

type CtaMessage struct {
	Action CtaMessageAction       `json:"action" validate:"required"`
	Body   CtaMessageBody         `json:"body" validate:"required"`
	Footer *CtaMessageFooter      `json:"footer,omitempty"`
	Header CtaMessageHeader       `json:"header,omitempty"`
	Type   InteractiveMessageType `json:"type" validate:"required"`
}

CtaMessage represents a cta message.

func NewCtaMessage added in v0.6.0

func NewCtaMessage(params CtaMessageParams) (*CtaMessage, error)

NewCtaMessage creates a new cta message.

func (*CtaMessage) SetAction added in v0.6.0

func (message *CtaMessage) SetAction(params CtaMessageActionParams)

func (*CtaMessage) SetBody added in v0.6.0

func (message *CtaMessage) SetBody(text string)

func (*CtaMessage) SetFooter added in v0.6.0

func (message *CtaMessage) SetFooter(text string)

func (*CtaMessage) SetHeader added in v0.6.0

func (message *CtaMessage) SetHeader(text string)

func (*CtaMessage) ToJson added in v0.6.0

func (m *CtaMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)

ToJson converts the cta message to JSON.

type CtaMessageAction added in v0.6.0

type CtaMessageAction struct {
	Name       string                 `json:"name" validate:"required"`
	Parameters CtaMessageActionParams `json:"parameters" validate:"required"`
}

type CtaMessageActionParams added in v0.6.0

type CtaMessageActionParams struct {
	DisplayText string `json:"display_text" validate:"required"`
	Url         string `json:"url" validate:"required"`
}

type CtaMessageApiPayload added in v0.6.0

type CtaMessageApiPayload struct {
	BaseMessagePayload
	Interactive CtaMessage `json:"interactive" validate:"required"`
}

CtaMessageApiPayload represents the API payload for a cta message.

type CtaMessageBody added in v0.6.0

type CtaMessageBody struct {
	Text string `json:"text" validate:"required"`
}

type CtaMessageFooter added in v0.6.0

type CtaMessageFooter struct {
	Text string `json:"text"`
}

type CtaMessageHeader added in v0.6.0

type CtaMessageHeader struct {
	Type CtaMessageHeaderType `json:"type" validate:"required"`
	Text string               `json:"text"`
}

! TODO: support more header types

type CtaMessageHeaderType added in v0.6.0

type CtaMessageHeaderType string
const (
	CtaMessageHeaderTypeText CtaMessageHeaderType = "text"
)

type CtaMessageParams added in v0.6.0

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

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,omitempty"`
	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 EmailType

type EmailType string
const (
	HomeEmail EmailType = "HOME"
	WorkEmail EmailType = "WORK"
)

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"
)

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.6

type ListMessageFooter struct {
	Text string `json:"text" validate:"required"` // Text of the footer.
}

ListMessageFooter represents the footer of the list message.

type ListMessageHeader added in v0.3.6

type ListMessageHeader struct {
	Type string `json:"type" validate:"required"` // Type of the header.
	Text string `json:"text" validate:"required"` // Text of the header.
}

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 added in v0.3.1

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 added in v0.3.1

func (section *ListSection) AddRow(row *listSectionRow)

AddRow adds a new row to the list section.

func (*ListSection) SetTitle added in v0.3.1

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.4.0

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.4.0

func NewLocationRequestMessage(params LocationRequestMessageParams) (*LocationRequestMessage, error)

func (*LocationRequestMessage) SetBodyText added in v0.4.0

func (m *LocationRequestMessage) SetBodyText(bodyText string)

SetBodyText sets the body text of the list message.

func (*LocationRequestMessage) ToJson added in v0.4.0

ToJson converts the list message to JSON.

type LocationRequestMessageApiPayload added in v0.4.0

type LocationRequestMessageApiPayload struct {
	BaseMessagePayload
	Interactive LocationRequestMessage `json:"interactive" validate:"required"` // Interactive message.
}

type LocationRequestMessageBody added in v0.4.0

type LocationRequestMessageBody struct {
	Text string `json:"text" validate:"required"` // Text of the body.
}

type LocationRequestMessageParams added in v0.4.0

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 PhoneType

type PhoneType string
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

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"`
	Footer *ProductListMessageFooter `json:"footer,omitempty"`
	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 added in v0.2.0

func (message *ProductListMessage) SetBody(text string)

func (*ProductListMessage) SetCatalogId added in v0.2.0

func (message *ProductListMessage) SetCatalogId(catalogId string)

func (*ProductListMessage) SetFooter added in v0.2.0

func (message *ProductListMessage) SetFooter(text string)

func (*ProductListMessage) SetHeader added in v0.2.0

func (message *ProductListMessage) SetHeader(text string)

func (*ProductListMessage) SetProductRetailerId added in v0.2.0

func (message *ProductListMessage) SetProductRetailerId(productRetailerId string)

func (*ProductListMessage) ToJson

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

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 added in v0.2.0

type ProductListMessageFooter struct {
	Text string `json:"text" validate:"required"`
}

type ProductListMessageHeader added in v0.2.0

type ProductListMessageHeader struct {
	Type ProductListMessageHeaderType `json:"type" validate:"required"`
	Text string                       `json:"text" validate:"required"`
}

! TODO: support more header types

type ProductListMessageHeaderType added in v0.2.1

type ProductListMessageHeaderType string
const (
	ProductListMessageHeaderTypeText ProductListMessageHeaderType = "text"
)

type ProductListMessageParams

type ProductListMessageParams struct {
	CatalogId         string `validate:"required"`
	ProductRetailerId string `validate:"required"`
	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"`
	Footer *ProductMessageFooter  `json:"footer,omitempty"`
	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 added in v0.2.0

func (m *ProductMessage) SetBody(text string)

func (*ProductMessage) SetCatalogId

func (m *ProductMessage) SetCatalogId(id string)

func (*ProductMessage) SetFooter added in v0.2.0

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

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 added in v0.2.0

type ProductMessageFooter struct {
	Text string `json:"text" validate:"required"`
}

type ProductMessageHeader added in v0.2.0

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.
	Footer *QuickReplyButtonMessageFooter `json:"footer,omitempty"`           // Footer 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.6

func (m *QuickReplyButtonMessage) SetFooter(text string)

func (*QuickReplyButtonMessage) SetHeader added in v0.3.6

func (m *QuickReplyButtonMessage) SetHeader(text string)

func (*QuickReplyButtonMessage) ToJson

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.6

type QuickReplyButtonMessageFooter struct {
	Text string `json:"text" validate:"required"` // Text of the quick reply button message footer.
}

QuickReplyButtonMessageFooter represents the footer of a quick reply button message.

type QuickReplyButtonMessageHeader added in v0.3.6

type QuickReplyButtonMessageHeader struct {
	Type string `json:"type" validate:"required"` // Type of the quick reply button message header.
	Text string `json:"text" validate:"required"` // Text of the quick reply button message header.
}

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

type StickerMessage struct {
	Id         string `json:"id,omitempty"`
	Link       string `json:"link,omitempty"`
	IsAnimated bool   `json:"animated,omitempty"`
}

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"`
	IsAnimated bool   `json:"animated,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

AddBody adds (or overrides) a body component in the template message. Only one body component is allowed.

func (*TemplateMessage) AddButton

AddButton adds a button component to the template message. A maximum of 10 buttons is allowed.

func (*TemplateMessage) AddCarousel added in v0.7.6

AddCarousel adds (or overrides) a carousel component in the template message. Only one carousel is allowed, and a carousel can contain up to 10 cards.

func (*TemplateMessage) AddHeader

AddHeader adds (or overrides) a header component in the template message. Only one header is allowed.

func (*TemplateMessage) ToJson

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 added in v0.2.0

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
}

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 TemplateMessageCarouselCard added in v0.7.6

type TemplateMessageCarouselCard 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 added in v0.2.0

type TemplateMessageComponentCarouselType struct {
	Type  TemplateMessageComponentType  `json:"type" validate:"required"` // "carousel"
	Cards []TemplateMessageCarouselCard `json:"cards" validate:"required"`
}

func (TemplateMessageComponentCarouselType) GetComponentType added in v0.7.6

func (t TemplateMessageComponentCarouselType) GetComponentType() string

GetComponentType returns the component type.

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 added in v0.2.0

type TemplateMessageComponentLimitedTimeOfferType struct {
	Type       TemplateMessageComponentType                `json:"type" validate:"required"`
	Parameters *[]TemplateMessageLimitedTimeOfferParameter `json:"parameters,omitempty" validate:"required"`
}

func (TemplateMessageComponentLimitedTimeOfferType) GetComponentType added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

type TemplateMessageMultiProductButtonActionParameterProductItem struct {
	ProductRetailerId string `json:"product_retailer_id" validate:"required"`
}

type TemplateMessageMultiProductButtonActionParameterSection added in v0.2.0

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 added in v0.0.10

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 added in v0.0.10

type TemplateMessageParameterMedia struct {
	Link string `json:"link" validate:"required"` // URL link of the media.
}

TemplateMessageParameterMedia represents a media parameter (for document, image, video).

type TemplateMessageParameterProduct added in v0.2.0

type TemplateMessageParameterProduct struct {
	ProductRetailerId string `json:"product_retailer_id" validate:"required"`
	CatalogId         string `json:"catalog_id" validate:"required"`
}

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 UrlType

type UrlType string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL