Documentation
¶
Index ¶
- Constants
- type Address
- type Addresses
- type Audio
- type AuthTemplateRequest
- type BaseClient
- func (c *BaseClient) RequestLocation(ctx context.Context, request *Request[string]) (*Response, error)
- func (c *BaseClient) SendAudio(ctx context.Context, request *Request[Audio]) (*Response, error)
- func (c *BaseClient) SendContacts(ctx context.Context, request *Request[Contacts]) (*Response, error)
- func (c *BaseClient) SendDocument(ctx context.Context, request *Request[Document]) (*Response, error)
- func (c *BaseClient) SendImage(ctx context.Context, request *Request[Image]) (*Response, error)
- func (c *BaseClient) SendInteractiveMessage(ctx context.Context, request *Request[Interactive]) (*Response, error)
- func (c *BaseClient) SendLocation(ctx context.Context, request *Request[Location]) (*Response, error)
- func (c *BaseClient) SendMessage(ctx context.Context, message *Message) (*Response, error)
- func (c *BaseClient) SendReaction(ctx context.Context, request *Request[Reaction]) (*Response, error)
- func (c *BaseClient) SendSticker(ctx context.Context, request *Request[Sticker]) (*Response, error)
- func (c *BaseClient) SendTemplate(ctx context.Context, request *Request[Template]) (*Response, error)
- func (c *BaseClient) SendText(ctx context.Context, request *Request[Text]) (*Response, error)
- func (c *BaseClient) SendVideo(ctx context.Context, request *Request[Video]) (*Response, error)
- func (c *BaseClient) SetConfigReader(fetcher config.Reader)
- func (c *BaseClient) UpdateStatus(ctx context.Context, request *StatusUpdateRequest) (*StatusUpdateResponse, error)
- type BaseRequest
- type BaseRequestOption
- func WithBaseRequestDecodeOptions(options whttp.DecodeOptions) BaseRequestOption
- func WithBaseRequestEndpoints(endpoint ...string) BaseRequestOption
- func WithBaseRequestMetadata(metadata map[string]any) BaseRequestOption
- func WithBaseRequestMethod(method string) BaseRequestOption
- func WithBaseRequestType(reqType whttp.RequestType) BaseRequestOption
- type BaseSender
- type ButtonParams
- type Client
- type Contact
- type ContactOption
- func WithContactAddresses(addresses ...*Address) ContactOption
- func WithContactBirthdays(birthday time.Time) ContactOption
- func WithContactEmails(emails ...*Email) ContactOption
- func WithContactName(name *Name) ContactOption
- func WithContactOrganization(organization *Org) ContactOption
- func WithContactPhones(phones ...*Phone) ContactOption
- func WithContactURLs(urls ...*URL) ContactOption
- type Contacts
- type Context
- type CouponCodeTemplateRequest
- type Document
- type Email
- type Emails
- type FlowActionPayload
- type ID
- type Image
- type Interactive
- type InteractiveAction
- type InteractiveActionParameters
- type InteractiveBody
- type InteractiveButton
- type InteractiveButtonTemplate
- type InteractiveCTARequest
- type InteractiveFlowRequest
- type InteractiveFooter
- type InteractiveHeader
- type InteractiveMessage
- type InteractiveOption
- type InteractiveReplyButton
- type InteractiveReplyButtonsRequest
- type InteractiveSection
- type InteractiveSectionRow
- type LimitedTimeOffer
- type LimitedTimeOfferTemplateRequest
- type Location
- type Media
- type MediaCard
- type MediaCardBody
- type MediaCardHeader
- type MediaCardTemplateRequest
- type MediaInfo
- type Message
- type Name
- type Option
- func WithAudio(image *Audio) Option
- func WithContacts(contacts *Contacts) Option
- func WithDocument(doc *Document) Option
- func WithImage(image *Image) Option
- func WithInteractiveCTAURLButton(request *InteractiveCTARequest) Option
- func WithInteractiveFlow(req *InteractiveFlowRequest) Option
- func WithInteractiveMessage(request *Interactive) Option
- func WithInteractiveReplyButtons(params *InteractiveReplyButtonsRequest) Option
- func WithLocationMessage(location *Location) Option
- func WithMessageAsReplyTo(messageID string) Option
- func WithReaction(reaction *Reaction) Option
- func WithRequestLocationMessage(text *string) Option
- func WithSticker(image *Sticker) Option
- func WithTemplateMessage(tmpl *Template) Option
- func WithTextMessage(text *Text) Option
- func WithVideo(image *Video) Option
- type Org
- type Phone
- type Phones
- type Product
- type Reaction
- type Request
- type Response
- type ResponseContact
- type Sender
- type SenderFunc
- type SenderMiddleware
- type Service
- type StatusUpdateRequest
- type StatusUpdateResponse
- type StatusUpdater
- type Sticker
- type Template
- func NewAuthTemplate(request *AuthTemplateRequest) *Template
- func NewCouponCodeTemplate(req *CouponCodeTemplateRequest) *Template
- func NewInteractiveTemplate(name string, language *TemplateLanguage, headers []*TemplateParameter, ...) *Template
- func NewLimitedTimeOfferTemplate(req *LimitedTimeOfferTemplateRequest) *Template
- func NewMediaCardTemplate(req *MediaCardTemplateRequest) *Template
- type TemplateButton
- type TemplateComponent
- func NewCopyCodeButton(params *ButtonParams) *TemplateComponent
- func NewLimitedTimeOfferTemplateDocumentHeader(document *Document) *TemplateComponent
- func NewLimitedTimeOfferTemplateImageHeader(image *Image) *TemplateComponent
- func NewTemplateComponentLimitedTimeOffer(expiresAt int64) *TemplateComponent
- func NewURLButton(params *ButtonParams) *TemplateComponent
- type TemplateCurrency
- type TemplateDateTime
- type TemplateFlowButton
- type TemplateLanguage
- type TemplateParameter
- type Text
- type TypingIndicator
- type URL
- type UpdateStatusFunc
- type Urls
- type Video
Constants ¶
View Source
const ( StatusSent status = "sent" StatusDelivered status = "delivered" StatusRead status = "read" StatusFailed status = "failed" StatusDeleted status = "deleted" StatusWarning status = "warning" )
View Source
const ( Endpoint = "/messages" MessagingProduct = "whatsapp" RecipientTypeIndividual = "individual" TypeText = "text" TypeVideo = "video" TypeAudio = "audio" TypeSticker = "sticker" TypeDocument = "document" TypeImage = "image" TypeLocation = "location" TypeReaction = "reaction" TypeContacts = "contacts" TypeInteractive = "interactive" TypeTemplate = "template" )
View Source
const ( TypeInteractiveLocationRequest = "location_request_message" TypeInteractiveCTAURL = "cta_url" TypeInteractiveButton = "button" TypeInteractiveFlow = "flow" InteractionActionSendLocation = "send_location" InteractiveActionCTAURL = "cta_url" InteractiveActionButtonReply = "reply" InteractiveActionFlow = "flow" )
View Source
const ( TemplateComponentTypeCarousel = "carousel" TemplateComponentTypeHeader = "header" TemplateComponentTypeButton = "button" TemplateComponentTypeButtons = "buttons" TemplateComponentTypeBody = "body" TemplateParameterTypeText = "text" TemplateParameterTypeCurrency = "currency" TemplateParameterTypeDateTime = "date_time" TemplateParameterTypePayload = "payload" TemplateParameterTypeImage = "image" TemplateParameterTypeVideo = "video" TemplateParameterTypeDocument = "document" TemplateParameterTypeLocation = "location" TemplateComponentTypeLimitedTimeOffer = "limited_time_offer" TemplateButtonSubTypeCopyCode = "copy_code" TemplateButtonSubTypeURL = "url" )
View Source
const (
TemplateComponentButtonSubTypeURL = "url"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthTemplateRequest ¶
type BaseClient ¶
type BaseClient struct {
// contains filtered or unexported fields
}
func NewBaseClient ¶
func (*BaseClient) RequestLocation ¶
func (*BaseClient) SendContacts ¶
func (*BaseClient) SendDocument ¶
func (*BaseClient) SendInteractiveMessage ¶
func (*BaseClient) SendLocation ¶
func (*BaseClient) SendMessage ¶
func (*BaseClient) SendReaction ¶
func (*BaseClient) SendSticker ¶
func (*BaseClient) SendTemplate ¶
func (*BaseClient) SetConfigReader ¶
func (*BaseClient) UpdateStatus ¶
func (c *BaseClient) UpdateStatus(ctx context.Context, request *StatusUpdateRequest) (*StatusUpdateResponse, error)
type BaseRequest ¶
type BaseRequest struct {
Method string
Endpoints []string
Type whttp.RequestType
Message *Message
DecodeOptions whttp.DecodeOptions
Metadata types.Metadata
}
func NewBaseRequest ¶
func NewBaseRequest(message *Message, options ...BaseRequestOption) *BaseRequest
type BaseRequestOption ¶
type BaseRequestOption func(request *BaseRequest)
func WithBaseRequestDecodeOptions ¶
func WithBaseRequestDecodeOptions(options whttp.DecodeOptions) BaseRequestOption
func WithBaseRequestEndpoints ¶
func WithBaseRequestEndpoints(endpoint ...string) BaseRequestOption
func WithBaseRequestMetadata ¶
func WithBaseRequestMethod ¶
func WithBaseRequestMethod(method string) BaseRequestOption
func WithBaseRequestType ¶
func WithBaseRequestType(reqType whttp.RequestType) BaseRequestOption
type BaseSender ¶
type ButtonParams ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) SendMessage ¶
func (*Client) UpdateStatus ¶
func (c *Client) UpdateStatus(ctx context.Context, request *StatusUpdateRequest) (*StatusUpdateResponse, error)
type Contact ¶
type Contact struct {
Addresses Addresses `json:"addresses,omitempty"`
Birthday string `json:"birthday"`
Emails Emails `json:"emails,omitempty"`
Name *Name `json:"name"`
Org *Org `json:"org"`
Phones Phones `json:"phones,omitempty"`
Urls Urls `json:"urls,omitempty"`
}
func NewContact ¶
func NewContact(options ...ContactOption) *Contact
type ContactOption ¶
type ContactOption func(*Contact)
func WithContactAddresses ¶
func WithContactAddresses(addresses ...*Address) ContactOption
func WithContactBirthdays ¶
func WithContactBirthdays(birthday time.Time) ContactOption
func WithContactEmails ¶
func WithContactEmails(emails ...*Email) ContactOption
func WithContactName ¶
func WithContactName(name *Name) ContactOption
func WithContactOrganization ¶
func WithContactOrganization(organization *Org) ContactOption
func WithContactPhones ¶
func WithContactPhones(phones ...*Phone) ContactOption
func WithContactURLs ¶
func WithContactURLs(urls ...*URL) ContactOption
type CouponCodeTemplateRequest ¶
type CouponCodeTemplateRequest struct {
Name string // Template name
Language *TemplateLanguage // Language code and policy
Body []*TemplateParameter // Parameters for the body text
CouponCode string // Coupon code to be copied
ButtonIndex int // Index of the button in the template
}
type FlowActionPayload ¶
type Interactive ¶
type Interactive struct {
Type string `json:"type,omitempty"`
Action *InteractiveAction `json:"action,omitempty"`
Body *InteractiveBody `json:"body,omitempty"`
Header *InteractiveHeader `json:"header,omitempty"`
}
func NewInteractiveCTAURLButton ¶
func NewInteractiveCTAURLButton(request *InteractiveCTARequest) *Interactive
func NewInteractiveMessageContent ¶
func NewInteractiveMessageContent(interactiveType string, options ...InteractiveOption) *Interactive
type InteractiveAction ¶
type InteractiveAction struct {
Button string `json:"button,omitempty"`
Buttons []*InteractiveButton `json:"buttons,omitempty"`
CatalogID string `json:"catalog_id,omitempty"`
ProductRetailerID string `json:"product_retailer_id,omitempty"`
Sections []*InteractiveSection `json:"sections,omitempty"`
Name string `json:"name,omitempty"`
Parameters *InteractiveActionParameters `json:"parameters,omitempty"`
}
type InteractiveActionParameters ¶
type InteractiveActionParameters struct {
DisplayText string `json:"display_text,omitempty"`
URL string `json:"url,omitempty"`
FlowMessageVersion string `json:"flow_message_version"`
FlowToken string `json:"flow_token"`
FlowID string `json:"flow_id"`
FlowCTA string `json:"flow_cta"`
FlowAction string `json:"flow_action"`
FlowActionPayload *FlowActionPayload `json:"flow_action_payload"`
}
type InteractiveBody ¶
type InteractiveBody struct {
Text string `json:"text,omitempty"`
}
InteractiveBody contains information about an interactive body.
type InteractiveButton ¶
type InteractiveButton struct {
Type string `json:"type,omitempty"`
Title string `json:"title,omitempty"`
ID string `json:"id,omitempty"`
Reply *InteractiveReplyButton `json:"reply,omitempty"`
}
type InteractiveButtonTemplate ¶
type InteractiveButtonTemplate struct {
SubType string
Index int
Button *TemplateButton
}
type InteractiveCTARequest ¶
type InteractiveCTARequest struct {
DisplayText string
URL string
Body string
Header *InteractiveHeader
}
type InteractiveFlowRequest ¶
type InteractiveFlowRequest struct {
Body string `json:"body"`
Header *InteractiveHeader `json:"header"`
FlowMessageVersion string `json:"flow_message_version"`
FlowToken string `json:"flow_token"`
FlowID string `json:"flow_id"`
FlowCTA string `json:"flow_cta"`
FlowAction string `json:"flow_action"`
FlowScreen string `json:"flow_screen"`
FlowData map[string]any `json:"flow_data"`
}
type InteractiveFooter ¶
type InteractiveFooter struct {
}
InteractiveFooter contains information about an interactive footer.
type InteractiveHeader ¶
type InteractiveHeader struct {
Document *Document `json:"document,omitempty"`
Image *Image `json:"image,omitempty"`
Video *Video `json:"video,omitempty"`
Text string `json:"text,omitempty"`
Type string `json:"type,omitempty"`
}
func InteractiveHeaderImage ¶
func InteractiveHeaderImage(image *Image) *InteractiveHeader
func InteractiveHeaderText ¶
func InteractiveHeaderText(text string) *InteractiveHeader
func InteractiveHeaderVideo ¶
func InteractiveHeaderVideo(video *Video) *InteractiveHeader
type InteractiveMessage ¶
type InteractiveMessage string
type InteractiveOption ¶
type InteractiveOption func(*Interactive)
func WithInteractiveAction ¶
func WithInteractiveAction(action *InteractiveAction) InteractiveOption
func WithInteractiveBody ¶
func WithInteractiveBody(body string) InteractiveOption
func WithInteractiveFooter ¶
func WithInteractiveFooter(footer string) InteractiveOption
func WithInteractiveHeader ¶
func WithInteractiveHeader(header *InteractiveHeader) InteractiveOption
type InteractiveReplyButton ¶
type InteractiveReplyButtonsRequest ¶
type InteractiveReplyButtonsRequest struct {
Buttons []*InteractiveReplyButton
Body string
Header *InteractiveHeader
}
type InteractiveSection ¶
type InteractiveSection struct {
Title string `json:"title,omitempty"`
ProductItems []*Product `json:"product_items,omitempty"`
Rows []*InteractiveSectionRow `json:"rows,omitempty"`
}
type InteractiveSectionRow ¶
type InteractiveSectionRow struct {
ID string `json:"id,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
}
InteractiveSectionRow contains information about a row in an interactive section.
type LimitedTimeOffer ¶
type LimitedTimeOffer struct {
ExpirationTimeMs int64 `json:"expiration_time_ms"`
}
type LimitedTimeOfferTemplateRequest ¶
type LimitedTimeOfferTemplateRequest struct {
Name string
Language *TemplateLanguage
HeaderComponent *TemplateComponent
Body []*TemplateParameter
ExpirationTime int64
CouponCode *string
URLVariable string
}
type MediaCard ¶
type MediaCard struct {
Header *MediaCardHeader `json:"header"`
Body *MediaCardBody `json:"body"`
Buttons []*TemplateButton `json:"buttons,omitempty"`
}
type MediaCardBody ¶
type MediaCardBody struct {
Text string `json:"text"`
}
type MediaCardHeader ¶
type MediaCardTemplateRequest ¶
type MediaCardTemplateRequest struct {
Name string
Language *TemplateLanguage
BodyText string
Cards []*MediaCard
Category string
}
type MediaInfo ¶
type MediaInfo struct {
ID string `json:"id,omitempty"`
Caption string `json:"caption,omitempty"`
MimeType string `json:"mime_type,omitempty"`
Sha256 string `json:"sha256,omitempty"`
Filename string `json:"filename,omitempty"`
Animated bool `json:"animated,omitempty"` // used with stickers true if animated
}
type Message ¶
type Message struct {
Product string `json:"messaging_product"`
To string `json:"to"`
RecipientType string `json:"recipient_type"`
Type string `json:"type"`
PreviewURL bool `json:"preview_url,omitempty"`
Context *Context `json:"context,omitempty"`
Text *Text `json:"text,omitempty"`
Location *Location `json:"location,omitempty"`
Reaction *Reaction `json:"reaction,omitempty"`
Contacts Contacts `json:"contacts,omitempty"`
Interactive *Interactive `json:"interactive,omitempty"`
Document *Document `json:"document,omitempty"`
Sticker *Sticker `json:"sticker,omitempty"`
Video *Video `json:"video,omitempty"`
Image *Image `json:"image,omitempty"`
Audio *Audio `json:"audio,omitempty"`
Status *string `json:"status,omitempty"` // used to update message status
MessageID *string `json:"message_id,omitempty"` // used to update message status
Template *Template `json:"template,omitempty"`
TypingIndicator *TypingIndicator `json:"typing_indicator,omitempty"`
}
type Option ¶
type Option func(message *Message)
func WithContacts ¶
func WithDocument ¶
func WithInteractiveCTAURLButton ¶
func WithInteractiveCTAURLButton(request *InteractiveCTARequest) Option
func WithInteractiveFlow ¶
func WithInteractiveFlow(req *InteractiveFlowRequest) Option
func WithInteractiveMessage ¶
func WithInteractiveMessage(request *Interactive) Option
func WithInteractiveReplyButtons ¶
func WithInteractiveReplyButtons(params *InteractiveReplyButtonsRequest) Option
func WithLocationMessage ¶
func WithMessageAsReplyTo ¶
func WithReaction ¶
func WithSticker ¶
func WithTemplateMessage ¶
func WithTextMessage ¶
type ResponseContact ¶
type SenderFunc ¶
type SenderMiddleware ¶
type SenderMiddleware func(senderFunc SenderFunc) SenderFunc
type Service ¶
type Service interface {
SendText(ctx context.Context, request *Request[Text]) (*Response, error)
SendLocation(ctx context.Context, request *Request[Location]) (*Response, error)
SendVideo(ctx context.Context, request *Request[Video]) (*Response, error)
SendReaction(ctx context.Context, request *Request[Reaction]) (*Response, error)
SendTemplate(ctx context.Context, request *Request[Template]) (*Response, error)
SendImage(ctx context.Context, request *Request[Image]) (*Response, error)
SendAudio(ctx context.Context, request *Request[Audio]) (*Response, error)
SendDocument(ctx context.Context, request *Request[Document]) (*Response, error)
SendSticker(ctx context.Context, request *Request[Sticker]) (*Response, error)
SendContacts(ctx context.Context, request *Request[Contacts]) (*Response, error)
RequestLocation(ctx context.Context, request *Request[string]) (*Response, error)
SendInteractiveMessage(ctx context.Context, request *Request[Interactive]) (*Response, error)
}
type StatusUpdateRequest ¶
type StatusUpdateResponse ¶
type StatusUpdateResponse struct {
Success bool `json:"success"`
}
type StatusUpdater ¶
type StatusUpdater interface {
UpdateStatus(ctx context.Context,
request *StatusUpdateRequest) (*StatusUpdateResponse, error)
}
type Template ¶
type Template struct {
Name string `json:"name,omitempty"`
Language *TemplateLanguage `json:"language,omitempty"`
Category string `json:"category,omitempty"`
Components []*TemplateComponent `json:"components,omitempty"`
}
func NewAuthTemplate ¶
func NewAuthTemplate(request *AuthTemplateRequest) *Template
func NewCouponCodeTemplate ¶
func NewCouponCodeTemplate(req *CouponCodeTemplateRequest) *Template
func NewInteractiveTemplate ¶
func NewInteractiveTemplate(name string, language *TemplateLanguage, headers []*TemplateParameter, bodies []*TemplateParameter, buttons []*InteractiveButtonTemplate, ) *Template
func NewLimitedTimeOfferTemplate ¶
func NewLimitedTimeOfferTemplate(req *LimitedTimeOfferTemplateRequest) *Template
func NewMediaCardTemplate ¶
func NewMediaCardTemplate(req *MediaCardTemplateRequest) *Template
type TemplateButton ¶
type TemplateComponent ¶
type TemplateComponent struct {
Type string `json:"type"`
SubType string `json:"sub_type,omitempty"`
Index int `json:"index"`
Parameters []*TemplateParameter `json:"parameters"`
Buttons []*TemplateButton `json:"buttons,omitempty"`
Text string `json:"text,omitempty"`
Cards []*MediaCard `json:"cards,omitempty"`
}
func NewCopyCodeButton ¶
func NewCopyCodeButton(params *ButtonParams) *TemplateComponent
func NewLimitedTimeOfferTemplateDocumentHeader ¶
func NewLimitedTimeOfferTemplateDocumentHeader(document *Document) *TemplateComponent
func NewLimitedTimeOfferTemplateImageHeader ¶
func NewLimitedTimeOfferTemplateImageHeader(image *Image) *TemplateComponent
func NewTemplateComponentLimitedTimeOffer ¶
func NewTemplateComponentLimitedTimeOffer(expiresAt int64) *TemplateComponent
func NewURLButton ¶
func NewURLButton(params *ButtonParams) *TemplateComponent
type TemplateCurrency ¶
type TemplateDateTime ¶
type TemplateFlowButton ¶
type TemplateLanguage ¶
type TemplateParameter ¶
type TemplateParameter struct {
Type string `json:"type"`
Text string `json:"text"`
Name string `json:"parameter_name,omitempty"`
Payload string `json:"payload,omitempty"`
Currency *TemplateCurrency `json:"currency"`
DateTime *TemplateDateTime `json:"date_time"`
LimitedTimeOffer *LimitedTimeOffer `json:"limited_time_offer,omitempty"`
Image *Image `json:"image"`
Document *Document `json:"document"`
Video *Video `json:"video"`
Location *Location `json:"location"`
}
type TypingIndicator ¶
type TypingIndicator struct {
Type string `json:"type"`
}
type UpdateStatusFunc ¶
type UpdateStatusFunc func(ctx context.Context, request *StatusUpdateRequest) (*StatusUpdateResponse, error)
func (UpdateStatusFunc) UpdateStatus ¶
func (fn UpdateStatusFunc) UpdateStatus(ctx context.Context, request *StatusUpdateRequest, ) (*StatusUpdateResponse, error)
Click to show internal directories.
Click to hide internal directories.