Documentation
¶
Index ¶
- Variables
- type AccountEventPayload
- type Contact
- type Context
- type GCSMediaServer
- type InboundButtonReply
- type InboundButtonText
- type InboundListReply
- type InboundLocation
- type InboundMedia
- type InboundMessage
- type InboundMessagePayload
- type InboundText
- type ListItem
- type ListItemOption
- type ListMessage
- type MediaServer
- type MediaServerMedia
- type MessageEventPayload
- type OutboundMessage
- func (om *OutboundMessage) Audio(url string) (url.Values, error)
- func (om *OutboundMessage) AudioMS(media MediaServerMedia) (url.Values, error)
- func (om *OutboundMessage) Image(originalURL string, previewURL string) (url.Values, error)
- func (om *OutboundMessage) ImageMS(original MediaServerMedia, preview MediaServerMedia) (url.Values, error)
- func (om *OutboundMessage) ListMessage(lm ListMessage) (url.Values, error)
- func (om *OutboundMessage) QuickReplyDocument(qrd QuickReplyDocument) (url.Values, error)
- func (om *OutboundMessage) QuickReplyImage(qri QuickReplyImage) (url.Values, error)
- func (om *OutboundMessage) QuickReplyText(text QuickReplyText) (url.Values, error)
- func (om *OutboundMessage) Text(text string) (url.Values, error)
- func (om *OutboundMessage) Validate() error
- func (om *OutboundMessage) Video(url string, caption string) (url.Values, error)
- func (om *OutboundMessage) VideoMS(media MediaServerMedia, caption string) (url.Values, error)
- type QuickReplyDocument
- type QuickReplyImage
- type QuickReplyOption
- type QuickReplyText
- type QuickReplyVideo
- type Sender
- type SystemEventPayload
- type UserEventPayload
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultTimeout = 120 * time.Second
DefaultTimeout is the default timeout for the media server
Functions ¶
This section is empty.
Types ¶
type AccountEventPayload ¶
type Contact ¶
type Contact struct {
Addresses []struct {
City string `json:"city"`
Country string `json:"country"`
CountryCode string `json:"countryCode"`
State string `json:"state"`
Street string `json:"street"`
Type string `json:"type"`
Zip string `json:"zip"`
} `json:"addresses"`
Emails []struct {
Email string `json:"email"`
Type string `json:"type"`
} `json:"emails"`
Ims []interface{} `json:"ims"`
Name struct {
FirstName string `json:"first_name"`
FormattedName string `json:"formatted_name"`
LastName string `json:"last_name"`
} `json:"name"`
Org struct {
Company string `json:"company"`
} `json:"org"`
Phones []struct {
Phone string `json:"phone"`
Type string `json:"type"`
} `json:"phones"`
URLs []struct {
URL string `json:"url"`
Type string `json:"type"`
} `json:"urls"`
}
type GCSMediaServer ¶
func (*GCSMediaServer) GetFile ¶
func (ms *GCSMediaServer) GetFile(requri string) (io.ReadCloser, error)
func (*GCSMediaServer) PutFileWithExt ¶
type InboundButtonReply ¶
type InboundButtonText ¶
type InboundButtonText string
type InboundListReply ¶
type InboundLocation ¶
type InboundMedia ¶
type InboundMedia struct {
Caption string `json:"caption"`
Name string `json:"name"`
URL string `json:"url"`
ContentType string `json:"contentType"`
URLExpiry time.Time `json:"urlExpiry"`
Type string `json:"-"`
}
func (*InboundMedia) UnmarshalJSON ¶
func (media *InboundMedia) UnmarshalJSON(data []byte) error
type InboundMessage ¶
type InboundMessage struct {
App string `json:"app"`
Timestamp time.Time `json:"timestamp"`
Type string `json:"type"`
Payload interface{} `json:"payload"`
}
func (*InboundMessage) UnmarshalJSON ¶
func (m *InboundMessage) UnmarshalJSON(data []byte) error
type InboundMessagePayload ¶
type InboundMessagePayload struct {
ID string `json:"id"`
Source string `json:"source"`
Type string `json:"type"`
Payload interface{} `json:"payload"`
}
func (*InboundMessagePayload) UnmarshalJSON ¶
func (msg *InboundMessagePayload) UnmarshalJSON(data []byte) error
type InboundText ¶
type InboundText string
type ListItem ¶
type ListItem struct {
Title string `json:"title"`
Options []ListItemOption `json:"options"`
}
type ListItemOption ¶
type ListItemOption struct {
Title string `json:"title"`
Description string `json:"description"`
PostbackText string `json:"postbackText"`
}
func (ListItemOption) MarshalJSON ¶
func (li ListItemOption) MarshalJSON() ([]byte, error)
func (*ListItemOption) Validate ¶ added in v0.2.1
func (li *ListItemOption) Validate() error
type ListMessage ¶
type ListMessage struct {
Title string `json:"title"`
Body string `json:"body"`
MsgID string `json:"msgid,omitempty"`
GlobalButton string `json:"-"`
Items []ListItem `json:"items"`
}
func (ListMessage) MarshalJSON ¶
func (lm ListMessage) MarshalJSON() ([]byte, error)
func (*ListMessage) Validate ¶ added in v0.2.1
func (lm *ListMessage) Validate() error
type MediaServer ¶
type MediaServer interface {
//GetFile returns a file from the media server and its content type
GetFile(requri string) (io.ReadCloser, string, error)
//PutFile uploads a file to the media server and returns the path to the file
PutFile(r io.Reader, contentType string) (string, error)
//PutFileWithExt uploads a file to the media server and returns the path to the file
PutFileWithExt(r io.Reader, ext string) (string, error)
}
type MediaServerMedia ¶
type MediaServerMedia struct {
Server MediaServer
Reader io.ReadCloser
ContentType string
}
func (*MediaServerMedia) PutFile ¶
func (media *MediaServerMedia) PutFile() (string, error)
type MessageEventPayload ¶ added in v0.2.1
type MessageEventPayload struct {
ID string `json:"id"`
GSID string `json:"gsId"`
Type string `json:"type"`
Destination string `json:"destination"`
Payload json.RawMessage `json:"payload"`
}
func (*MessageEventPayload) GetError ¶ added in v0.2.1
func (msgEvent *MessageEventPayload) GetError() error
type OutboundMessage ¶
type OutboundMessage struct {
Channel string
Destination string
Source string
SourceName string
DisablePreview bool
DoNotValidate bool
}
OutboundMessage is the basic structure for creating reply messages. Call this structure with the appropriate method to create a reply message. Limited validation is performed on the structure
Example ¶
om := &OutboundMessage{
Channel: "whatsapp",
Destination: "+1234567890",
Source: "+15555555555",
SourceName: "Our Company",
}
values, err := om.Text("Hello World")
if err != nil {
panic(err)
}
//Send the message
_, err = http.PostForm("https://gupshupurl", values)
func (*OutboundMessage) Audio ¶
func (om *OutboundMessage) Audio(url string) (url.Values, error)
Audio creates an audio message
func (*OutboundMessage) AudioMS ¶
func (om *OutboundMessage) AudioMS(media MediaServerMedia) (url.Values, error)
func (*OutboundMessage) ImageMS ¶
func (om *OutboundMessage) ImageMS(original MediaServerMedia, preview MediaServerMedia) (url.Values, error)
func (*OutboundMessage) ListMessage ¶
func (om *OutboundMessage) ListMessage(lm ListMessage) (url.Values, error)
Creates an interactive list message
func (*OutboundMessage) QuickReplyDocument ¶
func (om *OutboundMessage) QuickReplyDocument(qrd QuickReplyDocument) (url.Values, error)
func (*OutboundMessage) QuickReplyImage ¶
func (om *OutboundMessage) QuickReplyImage(qri QuickReplyImage) (url.Values, error)
func (*OutboundMessage) QuickReplyText ¶
func (om *OutboundMessage) QuickReplyText(text QuickReplyText) (url.Values, error)
func (*OutboundMessage) Text ¶
func (om *OutboundMessage) Text(text string) (url.Values, error)
Text creates a text message
func (*OutboundMessage) Validate ¶
func (om *OutboundMessage) Validate() error
func (*OutboundMessage) VideoMS ¶
func (om *OutboundMessage) VideoMS(media MediaServerMedia, caption string) (url.Values, error)
type QuickReplyDocument ¶
type QuickReplyDocument struct {
MsgID string `json:"msgid"`
URL string `json:"url"`
Text string `json:"text"`
Caption string `json:"caption"`
Filename string `json:"filename"`
Options []QuickReplyOption
}
func (*QuickReplyDocument) MarshalJSON ¶
func (qrd *QuickReplyDocument) MarshalJSON() ([]byte, error)
type QuickReplyImage ¶
type QuickReplyImage struct {
MsgID string
URL string
Text string
Caption string
Options []QuickReplyOption
}
func (*QuickReplyImage) MarshalJSON ¶
func (qri *QuickReplyImage) MarshalJSON() ([]byte, error)
type QuickReplyOption ¶
type QuickReplyOption string
func (*QuickReplyOption) MarshalJSON ¶
func (qro *QuickReplyOption) MarshalJSON() ([]byte, error)
type QuickReplyText ¶
type QuickReplyText struct {
MsgID string `json:"msgid"`
Header string `json:"header"`
Text string `json:"text"`
Caption string `json:"caption"`
Options []QuickReplyOption
}
func (*QuickReplyText) MarshalJSON ¶
func (qrt *QuickReplyText) MarshalJSON() ([]byte, error)
type QuickReplyVideo ¶
type QuickReplyVideo struct {
MsgID string `json:"msgid"`
URL string `json:"url"`
Text string `json:"text"`
Caption string `json:"caption"`
Options []QuickReplyOption
}
func (*QuickReplyVideo) MarshalJSON ¶
func (qrv *QuickReplyVideo) MarshalJSON() ([]byte, error)
type SystemEventPayload ¶
type UserEventPayload ¶
Click to show internal directories.
Click to hide internal directories.