Fix styling
This commit is contained in:
parent
09dbfd4b26
commit
036b286d6b
34
response.go
34
response.go
@ -97,13 +97,14 @@ func (r *Response) Image(im image.Image) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ButtonTemplate sends a message with the main contents being button elements
|
||||||
func (r *Response) ButtonTemplate(text string, buttons *[]StructuredMessageButton) error {
|
func (r *Response) ButtonTemplate(text string, buttons *[]StructuredMessageButton) error {
|
||||||
m := SendStructuredMessage {
|
m := SendStructuredMessage{
|
||||||
Recipient: r.to,
|
Recipient: r.to,
|
||||||
Message: StructuredMessageData {
|
Message: StructuredMessageData{
|
||||||
Attachment: StructuredMessageAttachment {
|
Attachment: StructuredMessageAttachment{
|
||||||
Type: "template",
|
Type: "template",
|
||||||
Payload: StructuredMessagePayload {
|
Payload: StructuredMessagePayload{
|
||||||
TemplateType: "button",
|
TemplateType: "button",
|
||||||
Text: text,
|
Text: text,
|
||||||
Buttons: buttons,
|
Buttons: buttons,
|
||||||
@ -134,13 +135,14 @@ func (r *Response) ButtonTemplate(text string, buttons *[]StructuredMessageButto
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GenericTemplate is a message which allows for structural elements to be sent
|
||||||
func (r *Response) GenericTemplate(text string, elements *[]StructuredMessageElement) error {
|
func (r *Response) GenericTemplate(text string, elements *[]StructuredMessageElement) error {
|
||||||
m := SendStructuredMessage {
|
m := SendStructuredMessage{
|
||||||
Recipient: r.to,
|
Recipient: r.to,
|
||||||
Message: StructuredMessageData {
|
Message: StructuredMessageData{
|
||||||
Attachment: StructuredMessageAttachment {
|
Attachment: StructuredMessageAttachment{
|
||||||
Type: "template",
|
Type: "template",
|
||||||
Payload: StructuredMessagePayload {
|
Payload: StructuredMessagePayload{
|
||||||
TemplateType: "generic",
|
TemplateType: "generic",
|
||||||
Buttons: nil,
|
Buttons: nil,
|
||||||
Elements: elements,
|
Elements: elements,
|
||||||
@ -181,32 +183,35 @@ type MessageData struct {
|
|||||||
Text string `json:"text,omitempty"`
|
Text string `json:"text,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendStructuredMessage is a structured message template
|
// SendStructuredMessage is a structured message template.
|
||||||
type SendStructuredMessage struct {
|
type SendStructuredMessage struct {
|
||||||
Recipient Recipient `json:"recipient"`
|
Recipient Recipient `json:"recipient"`
|
||||||
Message StructuredMessageData `json:"message"`
|
Message StructuredMessageData `json:"message"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StructuredMessageData is an attachment sent with a structured message.
|
||||||
type StructuredMessageData struct {
|
type StructuredMessageData struct {
|
||||||
Attachment StructuredMessageAttachment `json:"attachment"`
|
Attachment StructuredMessageAttachment `json:"attachment"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StructuredMessageAttachment is the attachment of a structured message.
|
||||||
type StructuredMessageAttachment struct {
|
type StructuredMessageAttachment struct {
|
||||||
// Template allways
|
// Type must be template
|
||||||
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.
|
||||||
Payload StructuredMessagePayload `json:"payload"`
|
Payload StructuredMessagePayload `json:"payload"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StructuredMessagePayload is the actual payload of an attachment
|
||||||
type StructuredMessagePayload struct {
|
type StructuredMessagePayload struct {
|
||||||
// button, generic, receipt
|
// TemplateType must be button, generic or receipt
|
||||||
TemplateType string `json:"template_type"`
|
TemplateType string `json:"template_type"`
|
||||||
Text string `json:"text,omitempty"`
|
Text string `json:"text,omitempty"`
|
||||||
Elements *[]StructuredMessageElement `json:"elements,omitempty"`
|
Elements *[]StructuredMessageElement `json:"elements,omitempty"`
|
||||||
Buttons *[]StructuredMessageButton `json:"buttons,omitempty"`
|
Buttons *[]StructuredMessageButton `json:"buttons,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// StructuredMessageElement - Generic Template
|
// StructuredMessageElement is a response containing structural elements
|
||||||
type StructuredMessageElement struct {
|
type StructuredMessageElement struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
ImageURL string `json:"image_url"`
|
ImageURL string `json:"image_url"`
|
||||||
@ -214,12 +219,9 @@ type StructuredMessageElement struct {
|
|||||||
Buttons []StructuredMessageButton `json:"buttons"`
|
Buttons []StructuredMessageButton `json:"buttons"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// StructuredMessageButton - Button Template
|
// StructuredMessageButton is a response containing buttons
|
||||||
type StructuredMessageButton struct {
|
type StructuredMessageButton struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user