2016-04-13 09:14:23 +03:00
|
|
|
package messenger
|
|
|
|
|
2016-12-08 23:52:21 +03:00
|
|
|
import "time"
|
|
|
|
|
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-08-18 02:41:25 +03:00
|
|
|
|
|
|
|
Read *Read `json:"read"`
|
2016-12-08 23:52:21 +03:00
|
|
|
|
|
|
|
OptIn *OptIn `json:"optin"`
|
2017-02-17 05:29:12 +03:00
|
|
|
|
|
|
|
ReferralMessage *ReferralMessage `json:"referral"`
|
2018-03-10 12:12:35 +03:00
|
|
|
|
|
|
|
AccountLinking *AccountLinking `json:"account_linking"`
|
2016-12-08 23:52:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type OptIn struct {
|
|
|
|
// Sender is the sender of the message
|
|
|
|
Sender Sender `json:"-"`
|
|
|
|
// Recipient is who the message was sent to.
|
|
|
|
Recipient Recipient `json:"-"`
|
|
|
|
// Time is when the message was sent.
|
|
|
|
Time time.Time `json:"-"`
|
|
|
|
// Ref is the reference as given
|
|
|
|
Ref string `json:"ref"`
|
2016-04-13 09:14:23 +03:00
|
|
|
}
|
|
|
|
|
2021-02-17 15:15:29 +03:00
|
|
|
// ReferralMessage represents referral endpoint.
|
2017-02-17 05:29:12 +03:00
|
|
|
type ReferralMessage struct {
|
|
|
|
*Referral
|
|
|
|
|
|
|
|
// Sender is the sender of the message
|
|
|
|
Sender Sender `json:"-"`
|
|
|
|
// Recipient is who the message was sent to.
|
|
|
|
Recipient Recipient `json:"-"`
|
|
|
|
// Time is when the message was sent.
|
|
|
|
Time time.Time `json:"-"`
|
|
|
|
}
|
|
|
|
|
2021-02-17 15:15:29 +03:00
|
|
|
// Referral represents referral info.
|
2017-02-17 05:29:12 +03:00
|
|
|
type Referral struct {
|
|
|
|
// Data originally passed in the ref param
|
|
|
|
Ref string `json:"ref"`
|
|
|
|
// Source type
|
|
|
|
Source string `json:"source"`
|
|
|
|
// The identifier dor the referral
|
|
|
|
Type string `json:"type"`
|
2022-01-13 14:50:17 +03:00
|
|
|
// ID of the ad
|
|
|
|
AdID string `json:"ad_id,omitempty"`
|
|
|
|
// The data containing information about the CTM ad, the user initiated the thread from.
|
|
|
|
AdsContextData AdsContextData `json:"ads_context_data,omitempty"`
|
2022-12-19 16:59:30 +03:00
|
|
|
// URI of the site from which the message was sent to the Facebook chat plugin.
|
|
|
|
RefererURI string `json:"referer_uri,omitempty"`
|
2022-01-13 14:50:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// AdsContextData represents data containing information about the CTM ad, the user initiated the thread from.
|
|
|
|
type AdsContextData struct {
|
|
|
|
// Title of the Ad
|
|
|
|
AdTitle string `json:"ad_title"`
|
|
|
|
// Url of the image from the Ad the user is interested
|
|
|
|
PhotoURL string `json:"photo_url,omitempty"`
|
|
|
|
// Thumbnail url of the video from the ad
|
|
|
|
VideoURL string `json:"video_url,omitempty"`
|
|
|
|
// ID of the post
|
|
|
|
PostID string `json:"post_id"`
|
|
|
|
// Product ID from the Ad the user is interested
|
|
|
|
ProductID string `json:"product_id,omitempty"`
|
2017-02-17 05:29:12 +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 {
|
2021-08-24 10:13:05 +03:00
|
|
|
ID int64 `json:"id,string,omitempty"`
|
|
|
|
PostID string `json:"post_id,omitempty"`
|
|
|
|
CommentID string `json:"comment_id,omitempty"`
|
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 {
|
2019-02-22 19:16:14 +03:00
|
|
|
Title string `json:"title,omitempty"`
|
|
|
|
URL string `json:"url,omitempty"`
|
2018-11-09 18:40:45 +03:00
|
|
|
// Type is what type the message is. (image, video, audio or location)
|
2016-04-14 03:07:23 +03:00
|
|
|
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-07-08 16:49:35 +03:00
|
|
|
// QuickReply is a file which used in a message.
|
|
|
|
type QuickReply struct {
|
|
|
|
// ContentType is the type of reply
|
2016-09-08 10:55:48 +03:00
|
|
|
ContentType string `json:"content_type,omitempty"`
|
2016-07-08 16:49:35 +03:00
|
|
|
// Title is the reply title
|
2016-09-08 10:55:48 +03:00
|
|
|
Title string `json:"title,omitempty"`
|
2016-07-08 16:49:35 +03:00
|
|
|
// Payload is the reply information
|
|
|
|
Payload string `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 {
|
2021-02-17 15:15:29 +03:00
|
|
|
URL string `json:"url,omitempty"`
|
2021-02-09 11:14:42 +03:00
|
|
|
Title string `json:"title,omitempty"`
|
2018-11-09 18:40:45 +03:00
|
|
|
// Coordinates is Lat/Long pair of location pin
|
2021-11-02 15:11:36 +03:00
|
|
|
Coordinates *Coordinates `json:"coordinates,omitempty"`
|
|
|
|
TemplateType string `json:"template_type,omitempty"`
|
|
|
|
Buttons []Button `json:"buttons,omitempty"`
|
2021-10-22 16:20:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type Button struct {
|
2021-11-02 15:11:36 +03:00
|
|
|
Type string `json:"type,omitempty"`
|
|
|
|
Title string `json:"title,omitempty"`
|
|
|
|
Payload string `json:"payload,omitempty"`
|
|
|
|
URL string `json:"url,omitempty"`
|
|
|
|
WebviewHeightRatio string `json:"webview_height_ratio,omitempty"`
|
|
|
|
MessengerExtensions bool `json:"messenger_extensions,omitempty"`
|
|
|
|
FallbackURL string `json:"fallback_url,omitempty"`
|
|
|
|
WebviewShareButton string `json:"webview_share_button,omitempty"`
|
2018-11-09 18:40:45 +03:00
|
|
|
}
|
|
|
|
|
2021-02-17 15:15:29 +03:00
|
|
|
// Coordinates is a pair of latitude and longitude.
|
2018-11-09 18:40:45 +03:00
|
|
|
type Coordinates struct {
|
|
|
|
// Lat is latitude
|
2019-02-22 19:16:14 +03:00
|
|
|
Lat float64 `json:"lat"`
|
2018-11-09 18:40:45 +03:00
|
|
|
// Long is longitude
|
|
|
|
Long float64 `json:"long"`
|
2016-04-13 12:46:52 +03:00
|
|
|
}
|