components

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: AGPL-3.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 NewListSection

func NewListSection(title string) (*listSection, error)

NewListSection creates a new list section with the given title.

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 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 DocumentMessage

type DocumentMessage struct {
}

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 {
}

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"
	InteractiveMessageTypeList        InteractiveMessageType = "list"
)

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 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 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 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:"retailerId" 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         string `json:"item_price"`          // ItemPrice is the price of the product item.
	ProductRetailerID string `json:"product_retailer_id"` // ProductRetailerID is the ID of the retailer associated with the product item.
	Quantity          string `json:"quantity"`            // Quantity is the quantity of the product item.
}

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

ToJson converts the product list message to JSON.

type ProductListMessageAction

type ProductListMessageAction struct {
	Sections          []ProductSection `json:"sections" validate:"required"`
	CatalogId         string           `json:"catalogId" validate:"required"`
	ProductRetailerId string           `json:"productRetailerId" 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 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"`
	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) SetBodyText

func (m *ProductMessage) SetBodyText(text string)

func (*ProductMessage) SetCatalogId

func (m *ProductMessage) SetCatalogId(id string)

func (*ProductMessage) SetHeader

func (m *ProductMessage) SetHeader()

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 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:"products" 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.
}

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

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"` // Name of the template message.
	Language   TemplateMessageLanguage    `json:"language" validate:"required"`
	Components []TemplateMessageComponent `json:"components" validate:"required"` // Components of the template message.
}

TemplateMessage represents a template message.

func NewTemplateMessage

func NewTemplateMessage(params *TemplateMessageConfigs) (*TemplateMessage, error)

NewTemplateMessage creates a new instance of TemplateMessage.

func (*TemplateMessage) AddBody

AddBody adds a body to the template message. Template Messages in whatsapp can only have one body component, so this function will override the last body added if any.

func (*TemplateMessage) AddButton

func (*TemplateMessage) AddHeader

AddHeader adds a header to the template message. Template Messages in whatsapp can only have one header, so this function will override the last header added if any.

func (*TemplateMessage) ToJson

ToJson converts the template message to JSON.

type TemplateMessageApiPayload

type TemplateMessageApiPayload struct {
	BaseMessagePayload
	Template TemplateMessage `json:"template" validate:"required"`
}

TemplateMessageApiPayload represents the API payload for a template message.

type TemplateMessageBodyAndHeaderParameter

type TemplateMessageBodyAndHeaderParameter struct {
	Type     TemplateMessageParameterType      `json:"type" validate:"required"` // Type of the template message parameter.
	Currency *TemplateMessageParameterCurrency `json:"currency,omitempty"`       // Currency of the template message parameter.
	DateTime *TemplateMessageParameterDateTime `json:"date_time,omitempty"`      // Date time of the template message parameter.
	Document *TemplateMessageParameterMedia    `json:"document,omitempty"`       // Document of the template message parameter.
	Image    *TemplateMessageParameterMedia    `json:"image,omitempty"`          // Image of the template message parameter.
	Text     *string                           `json:"text,omitempty"`           // Text of the template message parameter.
	Video    *TemplateMessageParameterMedia    `json:"video,omitempty"`          // Video of the template message parameter.
	Location *TemplateMessageParameterLocation `json:"location,omitempty"`       // Location of the template message parameter.
}

func (TemplateMessageBodyAndHeaderParameter) GetParameterType

func (t TemplateMessageBodyAndHeaderParameter) GetParameterType() string

type TemplateMessageButtonComponentType

type TemplateMessageButtonComponentType string
const (
	TemplateMessageButtonComponentTypeQuickReply TemplateMessageButtonComponentType = "quick_reply"
	TemplateMessageButtonComponentTypeUrl        TemplateMessageButtonComponentType = "url"
	TemplateMessageButtonComponentTypeCatalog    TemplateMessageButtonComponentType = "catalog"
)

type TemplateMessageButtonParameter

type TemplateMessageButtonParameter struct {
	Type    TemplateMessageButtonParameterType `json:"type" validate:"required"` // Type of the template message parameter.
	Payload string                             `json:"payload,omitempty"`        // Payload of the template message parameter, required for type of button sub_type -> quick_reply
	Text    string                             `json:"text,omitempty"`           // Text of the template message parameter, required for type of button sub_type -> URL.
}

func (TemplateMessageButtonParameter) GetParameterType

func (t TemplateMessageButtonParameter) GetParameterType() string

type TemplateMessageButtonParameterType

type TemplateMessageButtonParameterType string
const (
	TemplateMessageButtonParameterTypePayload TemplateMessageButtonParameterType = "payload"
	TemplateMessageButtonParameterTypeText    TemplateMessageButtonParameterType = "text"
)

type TemplateMessageComponent

type TemplateMessageComponent interface {
	GetComponentType() string
}

type TemplateMessageComponentBodyType

type TemplateMessageComponentBodyType struct {
	Type       TemplateMessageComponentType `json:"type" validate:"required"`       // Type of the template message component.
	Parameters []TemplateMessageParameter   `json:"parameters" validate:"required"` // Parameters of the template message component.
}

func (TemplateMessageComponentBodyType) GetComponentType

func (t TemplateMessageComponentBodyType) GetComponentType() string

type TemplateMessageComponentButtonType

type TemplateMessageComponentButtonType struct {
	Type       TemplateMessageComponentType       `json:"type" validate:"required"`       // Type of the template message component.
	SubType    TemplateMessageButtonComponentType `json:"sub_type" validate:"required"`   // Subtype of the template message component.
	Index      int                                `json:"index" validate:"required"`      // Index of the template message component.
	Parameters []TemplateMessageParameter         `json:"parameters" validate:"required"` // Parameters of the template message component.
}

func (TemplateMessageComponentButtonType) GetComponentType

func (t TemplateMessageComponentButtonType) GetComponentType() string

type TemplateMessageComponentHeaderType

type TemplateMessageComponentHeaderType struct {
	Type       TemplateMessageComponentType `json:"type" validate:"required"`       // Type of the template message component.
	Parameters []TemplateMessageParameter   `json:"parameters" validate:"required"` // Parameters of the template message component.
}

func (TemplateMessageComponentHeaderType) GetComponentType

func (t TemplateMessageComponentHeaderType) GetComponentType() string

type TemplateMessageComponentType

type TemplateMessageComponentType string
const (
	TemplateMessageComponentTypeHeader TemplateMessageComponentType = "header"
	TemplateMessageComponentTypeBody   TemplateMessageComponentType = "body"
	TemplateMessageComponentTypeButton TemplateMessageComponentType = "button"
)

type TemplateMessageConfigs

type TemplateMessageConfigs struct {
	Name     string `json:"name" validate:"required"`     // Name of the template message.
	Language string `json:"language" validate:"required"` // Language of the template message.
}

TemplateMessageConfigs represents the configurations for a template message.

type TemplateMessageLanguage

type TemplateMessageLanguage struct {
	Code   string `json:"code" validate:"required"`
	Policy string `json:"policy" validate:"required"`
}

type TemplateMessageParameter

type TemplateMessageParameter interface {
	GetParameterType() string
}

type TemplateMessageParameterCurrency

type TemplateMessageParameterCurrency struct {
	FallbackValue string `json:"fallback_value" validate:"required"` // Fallback value of the currency parameter.
	Code          string `json:"code" validate:"required"`           // Code of the currency parameter.
	Amount1000    int    `json:"amount_1000" validate:"required"`    // Amount of the currency parameter.
}

type TemplateMessageParameterDateTime

type TemplateMessageParameterDateTime struct {
	FallbackValue string `json:"fallback_value" validate:"required"` // Fallback value of the date time parameter.
}

type TemplateMessageParameterLocation added in v0.0.10

type TemplateMessageParameterLocation struct {
	Latitude  string `json:"latitude" validate:"required"`  // Latitude of the location parameter.
	Longitude string `json:"longitude" validate:"required"` // Longitude of the location parameter.
	Name      string `json:"name" validate:"required"`      // Name of the location parameter.
	Address   string `json:"address" validate:"required"`   // Address of the location parameter.
}

type TemplateMessageParameterMedia added in v0.0.10

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

type TemplateMessageParameterType

type TemplateMessageParameterType string
const (
	TemplateMessageParameterTypeCurrency TemplateMessageParameterType = "currency"
	TemplateMessageParameterTypeDateTime TemplateMessageParameterType = "date_time"
	TemplateMessageParameterTypeDocument TemplateMessageParameterType = "document"
	TemplateMessageParameterTypeImage    TemplateMessageParameterType = "image"
	TemplateMessageParameterTypeText     TemplateMessageParameterType = "text"
	TemplateMessageParameterTypeVideo    TemplateMessageParameterType = "video"
	TemplateMessageParameterTypeLocation TemplateMessageParameterType = "location"
)

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