Merge pull request #60 from ahmdaeyz/master
Adding missing json fields and list template method
This commit is contained in:
commit
19ba0ed851
@ -92,6 +92,8 @@ type Recipient struct {
|
|||||||
|
|
||||||
// Attachment is a file which used in a message.
|
// Attachment is a file which used in a message.
|
||||||
type Attachment struct {
|
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 is what type the message is. (image, video, audio or location)
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
// Payload is the information for the file which was sent in the attachment.
|
// Payload is the information for the file which was sent in the attachment.
|
||||||
|
28
response.go
28
response.go
@ -289,6 +289,32 @@ func (r *Response) GenericTemplate(elements *[]StructuredMessageElement, messagi
|
|||||||
return r.DispatchMessage(&m)
|
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
|
// SenderAction sends a info about sender action
|
||||||
func (r *Response) SenderAction(action string) error {
|
func (r *Response) SenderAction(action string) error {
|
||||||
m := SendSenderAction{
|
m := SendSenderAction{
|
||||||
@ -386,6 +412,8 @@ type StructuredMessageData struct {
|
|||||||
// StructuredMessageAttachment is the attachment of a structured message.
|
// StructuredMessageAttachment is the attachment of a structured message.
|
||||||
type StructuredMessageAttachment struct {
|
type StructuredMessageAttachment struct {
|
||||||
// Type must be template
|
// Type must be template
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
URL string `json:"url,omitempty"`
|
||||||
Type AttachmentType `json:"type"`
|
Type AttachmentType `json:"type"`
|
||||||
// Payload is the information for the file which was sent in the attachment.
|
// Payload is the information for the file which was sent in the attachment.
|
||||||
Payload StructuredMessagePayload `json:"payload"`
|
Payload StructuredMessagePayload `json:"payload"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user