From efd9d44236aaff310b45af652c4691aca7a4b100 Mon Sep 17 00:00:00 2001 From: Ahmed Aboelyazeed Date: Fri, 22 Feb 2019 18:16:14 +0200 Subject: [PATCH 1/2] add attachment.fallback json fields --- receiving.go | 6 ++++-- response.go | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/receiving.go b/receiving.go index 4bcac1f..316cbd8 100644 --- a/receiving.go +++ b/receiving.go @@ -92,6 +92,8 @@ type Recipient struct { // Attachment is a file which used in a message. type Attachment struct { + Title string `json:"title,omitempty"` + URL string `json:"url,omitempty"` // Type is what type the message is. (image, video, audio or location) Type string `json:"type"` // Payload is the information for the file which was sent in the attachment. @@ -111,7 +113,7 @@ type QuickReply struct { // Payload is the information on where an attachment is. type Payload struct { // URL is where the attachment resides on the internet. - URL string `json:"url,omitempty"` + URL string `json:"url,omitempty"` // Coordinates is Lat/Long pair of location pin Coordinates *Coordinates `json:"coordinates,omitempty"` } @@ -119,7 +121,7 @@ type Payload struct { // Coordinates is a pair of latitude and longitude type Coordinates struct { // Lat is latitude - Lat float64 `json:"lat"` + Lat float64 `json:"lat"` // Long is longitude Long float64 `json:"long"` } diff --git a/response.go b/response.go index 20e243c..d1012a8 100644 --- a/response.go +++ b/response.go @@ -351,7 +351,9 @@ type StructuredMessageData struct { // StructuredMessageAttachment is the attachment of a structured message. type StructuredMessageAttachment struct { // Type must be template - Type AttachmentType `json:"type"` + Title string `json:"title,omitempty"` + URL string `json:"url,omitempty"` + Type AttachmentType `json:"type"` // Payload is the information for the file which was sent in the attachment. Payload StructuredMessagePayload `json:"payload"` } From 14ff2aecb8f0d29b7a9505f5e92b0bc99fffbc6a Mon Sep 17 00:00:00 2001 From: Ahmed Aboelyazeed Date: Sun, 14 Apr 2019 12:28:09 +0200 Subject: [PATCH 2/2] add list template --- response.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/response.go b/response.go index d1012a8..4ee192d 100644 --- a/response.go +++ b/response.go @@ -285,6 +285,32 @@ func (r *Response) GenericTemplate(elements *[]StructuredMessageElement, messagi return r.DispatchMessage(&m) } +// ListTemplate sends a list of elements +func (r *Response) ListTemplate(elements *[]StructuredMessageElement, messagingType MessagingType, tags ...string) error { + var tag string + if len(tags) > 0 { + tag = tags[0] + } + + m := SendStructuredMessage{ + MessagingType: messagingType, + Recipient: r.to, + Message: StructuredMessageData{ + Attachment: StructuredMessageAttachment{ + Type: "template", + Payload: StructuredMessagePayload{ + TopElementStyle: "compact", + TemplateType: "list", + Buttons: nil, + Elements: elements, + }, + }, + }, + Tag: tag, + } + return r.DispatchMessage(&m) +} + // SenderAction sends a info about sender action func (r *Response) SenderAction(action string) error { m := SendSenderAction{