-
Notifications
You must be signed in to change notification settings - Fork 0
/
response.go
78 lines (64 loc) · 2.16 KB
/
response.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
package alice
type ResponseCardType string
const (
BigImage ResponseCardType = "BigImage"
ItemsList ResponseCardType = "ItemsList"
)
// Response represents main response object.
// See https://tech.yandex.ru/dialogs/alice/doc/protocol-docpage/#response
type Response struct {
Response ResponsePayload `json:"response"`
Session ResponseSession `json:"session"`
Version string `json:"version"`
}
// ResponsePayload contains response payload.
type ResponsePayload struct {
Text string `json:"text"`
Tts string `json:"tts,omitempty"`
Card *ResponseCard `json:"card,omitempty"`
Buttons []ResponseButton `json:"buttons,omitempty"`
EndSession bool `json:"end_session"`
}
// ResponseCard contains response card.
type ResponseCard struct {
Type ResponseCardType `json:"type"`
// For BigImage type.
*ResponseCardItem `json:",omitempty"`
// For ItemsList type.
*ResponseCardItemsList `json:",omitempty"`
}
type ResponseCardItem struct {
ImageID string `json:"image_id,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Button *ResponseCardButton `json:"button,omitempty"`
}
type ResponseCardItemsList struct {
Header *ResponseCardHeader `json:"header,omitempty"`
Items []ResponseCardItem `json:"items,omitempty"`
Footer *ResponseCardFooter `json:"footer,omitempty"`
}
type ResponseCardHeader struct {
Text string `json:"text"`
}
type ResponseCardFooter struct {
Text string `json:"text"`
Button *ResponseCardButton `json:"button,omitempty"`
}
type ResponseCardButton struct {
Text string `json:"text"`
URL string `json:"url,omitempty"`
Payload interface{} `json:"payload,omitempty"`
}
type ResponseButton struct {
Title string `json:"title"`
Payload interface{} `json:"payload,omitempty"`
URL string `json:"url,omitempty"`
Hide bool `json:"hide,omitempty"`
}
// ResponseSession contains response session.
type ResponseSession struct {
SessionID string `json:"session_id"`
MessageID int `json:"message_id"`
UserID string `json:"user_id"`
}