2016-04-13 09:14:23 +03:00
|
|
|
package messenger
|
|
|
|
|
2016-04-14 03:07:23 +03:00
|
|
|
// Receive is the format in which webhook events are sent.
|
2016-04-13 09:14:23 +03:00
|
|
|
type Receive struct {
|
2016-04-14 03:07:23 +03:00
|
|
|
// Object should always be `page`. (I don't quite understand why)
|
|
|
|
Object string `json:"object"`
|
|
|
|
// Entry is all of the different messenger types which were
|
|
|
|
// sent in this event.
|
|
|
|
Entry []Entry `json:"entry"`
|
2016-04-13 09:14:23 +03:00
|
|
|
}
|
|
|
|
|
2016-04-14 03:07:23 +03:00
|
|
|
// Entry is a batch of events which were sent in this webhook trigger.
|
2016-04-13 09:14:23 +03:00
|
|
|
type Entry struct {
|
2016-04-14 03:07:23 +03:00
|
|
|
// ID is the ID of the batch.
|
2016-05-20 02:18:44 +03:00
|
|
|
ID int64 `json:"id,string"`
|
2016-04-14 03:07:23 +03:00
|
|
|
// Time is when the batch was sent.
|
|
|
|
Time int64 `json:"time"`
|
|
|
|
// Messaging is the events that were sent in this Entry
|
2016-04-13 09:14:23 +03:00
|
|
|
Messaging []MessageInfo `json:"messaging"`
|
|
|
|
}
|
|
|
|
|
2016-04-14 03:07:23 +03:00
|
|
|
// MessageInfo is an event that is fired by the webhook.
|
2016-04-13 09:14:23 +03:00
|
|
|
type MessageInfo struct {
|
2016-04-14 03:07:23 +03:00
|
|
|
// Sender is who the event was sent from.
|
|
|
|
Sender Sender `json:"sender"`
|
|
|
|
// Recipient is who the event was sent to.
|
2016-04-13 12:36:38 +03:00
|
|
|
Recipient Recipient `json:"recipient"`
|
2016-04-14 03:07:23 +03:00
|
|
|
// Timestamp is the true time the event was triggered.
|
|
|
|
Timestamp int64 `json:"timestamp"`
|
|
|
|
// Message is the contents of a message if it is a MessageAction.
|
|
|
|
// Nil if it is not a MessageAction.
|
|
|
|
Message *Message `json:"message"`
|
|
|
|
// Delivery is the contents of a message if it is a DeliveryAction.
|
|
|
|
// Nil if it is not a DeliveryAction.
|
|
|
|
Delivery *Delivery `json:"delivery"`
|
2016-05-04 11:09:34 +03:00
|
|
|
|
2016-05-03 16:42:25 +03:00
|
|
|
PostBack *PostBack `json:"postback"`
|
2016-04-13 09:14:23 +03:00
|
|
|
}
|
|
|
|
|
2016-04-14 03:07:23 +03:00
|
|
|
// Sender is who the message was sent from.
|
2016-04-13 09:14:23 +03:00
|
|
|
type Sender struct {
|
2016-05-20 02:18:44 +03:00
|
|
|
ID int64 `json:"id,string"`
|
2016-04-13 09:14:23 +03:00
|
|
|
}
|
|
|
|
|
2016-04-14 03:07:23 +03:00
|
|
|
// Recipient is who the message was sent to.
|
2016-04-13 09:14:23 +03:00
|
|
|
type Recipient struct {
|
2016-05-20 02:18:44 +03:00
|
|
|
ID int64 `json:"id,string"`
|
2016-04-13 09:14:23 +03:00
|
|
|
}
|
2016-04-13 12:46:52 +03:00
|
|
|
|
2016-04-14 03:07:23 +03:00
|
|
|
// Attachment is a file which used in a message.
|
2016-04-13 12:46:52 +03:00
|
|
|
type Attachment struct {
|
2016-04-14 03:07:23 +03:00
|
|
|
// Type is what type the message is. (image, video or audio)
|
|
|
|
Type string `json:"type"`
|
|
|
|
// Payload is the information for the file which was sent in the attachment.
|
2016-04-13 12:46:52 +03:00
|
|
|
Payload Payload `json:"payload"`
|
|
|
|
}
|
|
|
|
|
2016-04-14 03:07:23 +03:00
|
|
|
// Payload is the information on where an attachment is.
|
2016-04-13 12:46:52 +03:00
|
|
|
type Payload struct {
|
2016-04-14 03:07:23 +03:00
|
|
|
// URL is where the attachment resides on the internet.
|
2016-04-16 11:01:32 +03:00
|
|
|
URL string `json:"url,omitempty"`
|
2016-04-13 12:46:52 +03:00
|
|
|
}
|