1
0
mirror of synced 2024-11-25 22:36:03 +03:00

Add Response documentation

This commit is contained in:
Harrison 2016-04-14 10:23:45 +10:00
parent 99c1be7fa1
commit b206661b37

View File

@ -7,14 +7,17 @@ import (
) )
const ( const (
// SendMessageURL is API endpoint for sending messages.
SendMessageURL = "https://graph.facebook.com/v2.6/me/messages" SendMessageURL = "https://graph.facebook.com/v2.6/me/messages"
) )
// Response is used for responding to events with messages.
type Response struct { type Response struct {
token string token string
to Recipient to Recipient
} }
// Text sends a textual message.
func (r *Response) Text(message string) error { func (r *Response) Text(message string) error {
m := SendMessage{ m := SendMessage{
Recipient: r.to, Recipient: r.to,
@ -44,11 +47,13 @@ func (r *Response) Text(message string) error {
return err return err
} }
// SendMessage is the information sent in an API request to Facebook.
type SendMessage struct { type SendMessage struct {
Recipient Recipient `json:"recipient"` Recipient Recipient `json:"recipient"`
Message MessageData `json:"message"` Message MessageData `json:"message"`
} }
// MessageData is a text message to be sent.
type MessageData struct { type MessageData struct {
Text string `json:"text,omitempty"` Text string `json:"text,omitempty"`
} }