-
Notifications
You must be signed in to change notification settings - Fork 0
/
media.go
101 lines (88 loc) · 2.24 KB
/
media.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package main
import (
"encoding/json"
"fmt"
)
type Likes struct {
pages string
}
type Name struct {
Surname string
likes []Likes
}
func pringStructs() {
lkes := []Likes{Likes{pages: "names"}}
name := Name{Surname: "Ayomide", likes: lkes}
t, _ := json.Marshal(name)
fmt.Println(string(t))
}
type Buttons struct {
Type string `json:"type"`
URL string `json:"url,omitempty"`
Title string `json:"title"`
Payload string `json:"payload,omitempty"`
}
// type DefaultAction struct {
// Type string `json:"type,omitempty"`
// URL string `json:"url,omitempty"`
// WebviewHeightRatio string `json:"webview_height_ratio,omitempty"`
// }
type Payload struct {
TemplateType string `json:"template_type"`
Els []Elements `json:"elements"`
}
type Elements struct {
Title string `json:"title"`
Subt string `json:"subtitle,omitempty"`
ImageURL string `json:"image_url"`
//DefAction DefaultAction `json:"default_action,omitempty"`
Buttons []Buttons `json:"buttons,omitempty"`
}
type Attachment struct {
Type string `json:"type"`
Payl Payload `json:"payload"`
}
type Recipient struct {
ID string `json:"id"`
}
type Messages struct {
Attach Attachment `json:"attachment"`
}
type AutoGenerated struct {
Rec Recipient `json:"recipient"`
Mes Messages `json:"message"`
}
func ddg(userID string) {
btn := []Buttons{Buttons{Type: "postback", Payload: "goog", Title: "Google"}}
payl := Payload{
TemplateType: "generic",
Els: []Elements{
Elements{
Title: "Google Inc",
Subt: "Google Inc. Best search engine!",
ImageURL: "https://image.shutterstock.com/image-photo/mountain-view-causa-december-29-260nw-630500720.jpg",
Buttons: btn,
},
Elements{
Title: "Amazon Inc",
Subt: "Amazon Inc. Buy whatever you want!",
ImageURL: "https://media.npr.org/assets/img/2018/10/19/img_1330_wide-1e73904f1d0f2b6a4e51e714ef6bf32cd502e6c2.jpg?s=6",
Buttons: []Buttons{Buttons{Type: "postback", Payload: "aws", Title: "Amazon"}},
},
},
}
pnt := AutoGenerated{
Rec: Recipient{
ID: userID,
},
Mes: Messages{
Attach: Attachment{
Type: "template",
Payl: payl,
},
},
}
gth, _ := json.Marshal(pnt)
fmt.Println(string(gth))
callSendAPI(gth)
}