whatsapp

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const FacebookGraphAPI = "https://graph.facebook.com/v15.0/"

Variables

View Source
var (
	BearerToken = "Bearer " + os.Getenv("BEARER_ACCESS_TOKEN")
)

Functions

func SendMessage

func SendMessage(message []byte, phoneNumberID string) error

func UploadSticker

func UploadSticker(path string, phoneNumberID string) (string, error)

UploadSticker returns the ID

Types

type Change

type Change struct {
	Value ChangeValue `json:"value"`
	Field string      `json:"field"`
}

type ChangeValue

type ChangeValue struct {
	MessagingProduct string    `json:"messaging_product"`
	Metadata         Metadata  `json:"metadata"`
	Contacts         []Contact `json:"contacts"`
	Messages         []Message `json:"messages"`
}

type Contact

type Contact struct {
	Profile struct {
		Name string `json:"name"`
	} `json:"profile"`
	WhatsappID string `json:"wa_id"`
}

type Context

type Context struct {
	MessageID string `json:"message_id"`
}

type Entry

type Entry struct {
	ID      string   `json:"id"`
	Changes []Change `json:"changes"`
}

type Media

type Media struct {
	MimeType string `json:"mime_type"`
	SHA256   string `json:"sha256"`
	ID       string `json:"id"`
}

type MediaURLResponse

type MediaURLResponse struct {
	URL      string `json:"url"`
	FileSize int    `json:"file_size"`
}

type Message

type Message struct {
	From      string `json:"from"`
	ID        string `json:"id"`
	Timestamp string `json:"timestamp"`
	Type      string `json:"type"`
	Text      struct {
		Body string `json:"body"`
	} `json:"text"`
	Sticker struct {
		Media
		Animated string `json:"animated"`
	} `json:"sticker"`
	Image Media `json:"image"`
	Video Media `json:"video"`
}

func (Message) ContentLength

func (incoming Message) ContentLength() (*MediaURLResponse, error)

func (Message) DownloadMedia

func (incoming Message) DownloadMedia(path string, url string) error

func (Message) IsGroup

func (incoming Message) IsGroup() bool

IsGroup : Right now twilio doesn't allow adding whatsapp business to a group but we keep this here for now

func (Message) IsImage

func (incoming Message) IsImage() bool

func (Message) IsMedia

func (incoming Message) IsMedia() bool

func (Message) IsSticker

func (incoming Message) IsSticker() bool

func (Message) IsVideo

func (incoming Message) IsVideo() bool

func (Message) MediaID

func (incoming Message) MediaID() string

func (Message) MediaType

func (incoming Message) MediaType() string

func (Message) Time

func (m Message) Time() string

type MessagingProduct

type MessagingProduct string

func (MessagingProduct) MarshalJSON

func (e MessagingProduct) MarshalJSON() ([]byte, error)

implement the Unmarshaler interface on MessagingProduct

type Metadata

type Metadata struct {
	DisplayPhoneNumber string `json:"display_phone_number"`
	PhoneNumberID      string `json:"phone_number_id"`
}

type Response

type Response struct {
	Type             string           `json:"type"`
	Context          Context          `json:"context"`
	To               string           `json:"to"`
	MessagingProduct MessagingProduct `json:"messaging_product"`
}

type Sticker

type Sticker struct {
	ID string `json:"id"`
}

type StickerResponse

type StickerResponse struct {
	Response
	Sticker `json:"sticker"`
}

type Text

type Text struct {
	Body string `json:"body"`
}

type TextResponse

type TextResponse struct {
	Response
	Text Text `json:"text"`
}

type UploadMediaRequest

type UploadMediaRequest struct {
	Path             string `json:"file"`
	Type             string `json:"type"`
	MessagingProduct string `json:"messaging_product"`
}

type UploadMediaResponse

type UploadMediaResponse struct {
	ID string `json:"id"`
}

type WhatsappIncomingMessage

type WhatsappIncomingMessage struct {
	Object string  `json:"object"`
	Entry  []Entry `json:"entry"`
}

func UnmarshalIncomingMessage

func UnmarshalIncomingMessage(req *http.Request) (*WhatsappIncomingMessage, error)

Jump to

Keyboard shortcuts

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