forked from hilaily/larkcard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjects.go
94 lines (79 loc) · 1.84 KB
/
objects.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
package larkcard
// Reference:
// https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/uYTOxUjL2kTM14iN5ETN
// https://open.feishu.cn/document/ukTMukTMukTM/uUzNwUjL1cDM14SN3ATN
func NewObjTextPlain(text string) *OText {
return NewObjText(text, TextPlain)
}
func NewObjTextMD(text string) *OText {
return NewObjText(text, TextLarkMD)
}
func NewObjText(content string, tag TextTag) *OText {
return &OText{
Tag: tag,
Content: content,
}
}
func NewObjField(isShort bool, text string) *OField {
return &OField{
IsShort: isShort,
Text: NewObjTextPlain(text),
}
}
func NewObjURL(url, androidURL, iOSURL, pcURL string) *OURL {
return &OURL{
URL: url,
AndroidURL: androidURL,
IOSURL: iOSURL,
PCURL: pcURL,
}
}
func NewObjOption(text string, val string) *OOption {
return &OOption{
Text: NewObjTextPlain(text),
Value: val,
}
}
func NewObjConfirm(title, text string) *OConfirm {
return &OConfirm{
Title: NewObjTextPlain(title),
Text: NewObjTextPlain(text),
}
}
type OText struct {
Tag TextTag `json:"tag"`
Content string `json:"content"`
Lines int `json:"lines,omitempty"`
}
func (t *OText) SetLines(l int) *OText {
t.Lines = l
return t
}
type OField struct {
IsShort bool `json:"is_short"`
Text *OText `json:"text"`
}
type OURL struct {
URL string `json:"url"`
AndroidURL string `json:"android_url"`
IOSURL string `json:"ios_url"`
PCURL string `json:"pc_url"`
}
type OOption struct {
Text *OText `json:"text,omitempty"`
Value string `json:"value"`
URL string `json:"url"`
MultiURL *OURL `json:"multi_url,omitempty"`
}
func (o *OOption) SetURL(url string) *OOption {
o.URL = url
return o
}
func (o *OOption) SetMultiURL(url *OURL) *OOption {
o.MultiURL = url
return o
}
type OConfirm struct {
Title *OText `json:"title"`
Text *OText `json:"text"`
}