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