Documentation
¶
Index ¶
Constants ¶
const FacebookSupportUrl = "https://developers.facebook.com/docs/whatsapp"
references for documentation url, points to the facebook documentation page
const (
// global field for authorization header
HeaderAuthorization = "Authorization"
)
Variables ¶
var ( // MediaTypeMapping provides available extension to mime // type mapping which can be uploaded to whatsapp MediaTypeMapping = map[string]MediaType{ ".jpeg": MediaTypeImageJpeg, ".png": MediaTypeImagePng, ".webp": MediaTypeImageWebp, ".acc": MediaTypeAudioAcc, ".mp3": MediaTypeAudioMpeg, ".amr": MediaTypeAudioAmr, ".oga": MediaTypeAudioOgg, ".opus": MediaTypeAudioOpus, ".mp4": MediaTypeVideoMp4, ".3gp": MediaTypeVideo3gpp, ".doc": MediaTypeDocumentDoc, ".docx": MediaTypeDocumentDocx, ".pdf": MediaTypeDocumentPdf, ".ppt": MediaTypeDocumentPpt, ".pptx": MediaTypeDocumentPptx, ".xls": MediaTypeDocumentXls, ".xlsx": MediaTypeDocumentXlsx, ".zip": MediaTypeDocumentZip, ".rar": MediaTypeDocumentRar, } )
var ( MessageTypesMapping = map[MessageType]bool{ MessageTypeText: true, MessageTypeImage: true, MessageTypeAudio: true, MessageTypeVideo: true, MessageTypeDocument: true, MessageTypeTemplateText: true, MessageTypeTemplateMedia: true, MessageTypeContact: true, MessageTypeLocation: true, MessageTypeSticker: true, } )
MessageTypesMapping provides a mapping to message types which will be use to validate the user specified operation
Functions ¶
This section is empty.
Types ¶
type ContactResponse ¶
type ContactResponse struct { Contacts []struct { Input string `json:"input"` Status string `json:"status"` WaID string `json:"wa_id"` } `json:"contacts"` Meta Meta `json:"meta"` }
func (*ContactResponse) GetStatus ¶
func (c *ContactResponse) GetStatus() (string, error)
type Media ¶
Media object for storing the information about file, which will be uploaded to whatsapp
func NewFileReader ¶
NewFileReader returns a new object of media type it will also convert the file path to absolute
func (*Media) GetMimeType ¶
GetMimeType will return the file mime type which is of type MediaType converted to string
type MediaMessage ¶
type MediaResponse ¶
type MediaResponse struct { Media []struct { ID string `json:"id"` } `json:"media"` Meta Meta `json:"meta"` }
func (*MediaResponse) GetId ¶
func (m *MediaResponse) GetId() (string, error)
type MediaType ¶
type MediaType string
const ( MediaTypeImageJpeg MediaType = "image/jpeg" MediaTypeImagePng MediaType = "image/png" MediaTypeImageWebp MediaType = "image/webp" MediaTypeAudioAcc MediaType = "audio/aac" MediaTypeAudioAmr MediaType = "audio/amr" MediaTypeAudioMpeg MediaType = "audio/mpeg" MediaTypeAudioOgg MediaType = "audio/ogg" MediaTypeAudioOpus MediaType = "audio/opus" MediaTypeVideoMp4 MediaType = "video/mp4" MediaTypeVideo3gpp MediaType = "video/3gpp" MediaTypeDocumentDoc MediaType = "application/msword" MediaTypeDocumentDocx MediaType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document" MediaTypeDocumentPdf MediaType = "application/pdf" MediaTypeDocumentPpt MediaType = "application/vnd.ms-powerpoint" MediaTypeDocumentPptx MediaType = "application/vnd.openxmlformats-officedocument.presentationml.presentation" MediaTypeDocumentXls MediaType = "application/vnd.ms-excel" MediaTypeDocumentXlsx MediaType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" MediaTypeDocumentZip MediaType = "application/zip" MediaTypeDocumentRar MediaType = "application/vnd.rar" )
All media types extensions which are supported by facebook whatsapp business, please follow the link https://developers.facebook.com/docs/whatsapp/api/media/ for reference on supported media types
type MessageResponse ¶
type MessageResponse struct { Messages []struct { ID string `json:"id"` } `json:"messages"` Meta Meta }
func (*MessageResponse) GetId ¶
func (m *MessageResponse) GetId() (string, error)
type MessageType ¶
type MessageType string
const ( MessageTypeText MessageType = "text" MessageTypeImage MessageType = "image" MessageTypeAudio MessageType = "audio" MessageTypeVideo MessageType = "video" MessageTypeDocument MessageType = "document" MessageTypeTemplateText MessageType = "hsm" MessageTypeTemplateMedia MessageType = "template" MessageTypeContact MessageType = "contacts" MessageTypeLocation MessageType = "location" MessageTypeSticker MessageType = "sticker" )
All the available message type supported by Whatsapp
type WAMessage ¶
type WAMessage struct { To int `json:"to" validate:"required"` Type string `json:"type" validate:"required"` RecipientType string `json:"recipient_type"` PreviewURL bool `json:"preview_url,omitempty"` Caption string `json:"caption,omitempty"` Text Text `json:"text,omitempty"` Image MediaMessage `json:"image,omitempty"` Audio MediaMessage `json:"audio,omitempty"` Video MediaMessage `json:"video,omitempty"` Document MediaMessage `json:"document,omitempty"` }
WAMessage defines all the message formats and it's values which will further be process by intermediate functions to send the request to whatsapp
type WhatsappError ¶
type WhatsappError struct { Meta Meta `json:"meta"` Errors []struct { Code int `json:"code"` Title string `json:"title"` Details string `json:"details"` } `json:"errors"` }
func (*WhatsappError) Error ¶
func (w *WhatsappError) Error() string