From 92cd8b953b7f41b2894d1d918802b1f02172039b Mon Sep 17 00:00:00 2001 From: Pranas Kiziela Date: Tue, 13 Nov 2018 14:38:34 +0200 Subject: [PATCH 1/3] Add image_aspect_ratio property to attachments --- response.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/response.go b/response.go index 897f186..caba15c 100644 --- a/response.go +++ b/response.go @@ -18,6 +18,7 @@ import ( type AttachmentType string type MessagingType string type TopElementStyle string +type ImageAspectRatio string const ( // SendMessageURL is API endpoint for sending messages. @@ -45,6 +46,11 @@ const ( CompactTopElementStyle TopElementStyle = "compact" // TopElementStyle is large. LargeTopElementStyle TopElementStyle = "large" + + // ImageAspectRatio is horizontal (1.91:1). Default. + HorizontalImageAspectRatio ImageAspectRatio = "horizontal" + // ImageAspectRatio is square. + SquareImageAspectRatio ImageAspectRatio = "square" ) // QueryResponse is the response sent back by Facebook when setting up things @@ -348,12 +354,13 @@ type StructuredMessageAttachment struct { // StructuredMessagePayload is the actual payload of an attachment type StructuredMessagePayload struct { // TemplateType must be button, generic or receipt - TemplateType string `json:"template_type,omitempty"` - TopElementStyle TopElementStyle `json:"top_element_style,omitempty"` - Text string `json:"text,omitempty"` - Elements *[]StructuredMessageElement `json:"elements,omitempty"` - Buttons *[]StructuredMessageButton `json:"buttons,omitempty"` - Url string `json:"url,omitempty"` + TemplateType string `json:"template_type,omitempty"` + TopElementStyle TopElementStyle `json:"top_element_style,omitempty"` + Text string `json:"text,omitempty"` + ImageAspectRatio ImageAspectRatio `json:"image_aspect_ratio,omitempty"` + Elements *[]StructuredMessageElement `json:"elements,omitempty"` + Buttons *[]StructuredMessageButton `json:"buttons,omitempty"` + Url string `json:"url,omitempty"` } // StructuredMessageElement is a response containing structural elements From 5f412351045e5f18eb3af92ed239568afb7ce4cb Mon Sep 17 00:00:00 2001 From: Pranas Kiziela Date: Tue, 13 Nov 2018 15:00:30 +0200 Subject: [PATCH 2/3] Add sharable property to attachments --- response.go | 1 + 1 file changed, 1 insertion(+) diff --git a/response.go b/response.go index caba15c..ecd6f0f 100644 --- a/response.go +++ b/response.go @@ -358,6 +358,7 @@ type StructuredMessagePayload struct { TopElementStyle TopElementStyle `json:"top_element_style,omitempty"` Text string `json:"text,omitempty"` ImageAspectRatio ImageAspectRatio `json:"image_aspect_ratio,omitempty"` + Sharable bool `json:"sharable,omitempty"` Elements *[]StructuredMessageElement `json:"elements,omitempty"` Buttons *[]StructuredMessageButton `json:"buttons,omitempty"` Url string `json:"url,omitempty"` From a9882ddddbc8f77e7a9144ad44c92d5dea4640ee Mon Sep 17 00:00:00 2001 From: Pranas Kiziela Date: Tue, 13 Nov 2018 15:41:30 +0200 Subject: [PATCH 3/3] Add default_action property to attachments --- response.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/response.go b/response.go index ecd6f0f..4411761 100644 --- a/response.go +++ b/response.go @@ -366,11 +366,22 @@ type StructuredMessagePayload struct { // StructuredMessageElement is a response containing structural elements type StructuredMessageElement struct { - Title string `json:"title"` - ImageURL string `json:"image_url"` - ItemURL string `json:"item_url"` - Subtitle string `json:"subtitle"` - Buttons []StructuredMessageButton `json:"buttons"` + Title string `json:"title"` + ImageURL string `json:"image_url"` + ItemURL string `json:"item_url"` + Subtitle string `json:"subtitle"` + DefaultAction *DefaultAction `json:"default_action,omitempty"` + Buttons []StructuredMessageButton `json:"buttons"` +} + +// DefaultAction is a response containing default action properties +type DefaultAction struct { + Type string `json:"type"` + 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"` } // StructuredMessageButton is a response containing buttons