This repository has been archived by the owner on Dec 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtipe.go
81 lines (68 loc) · 1.78 KB
/
tipe.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
package tipe
type CreatedBy struct {
Email string `json:"email"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
}
// Fields
type BooleanField struct {
Data map[string]interface{} `json:"data"`
ID string `json:"id"`
List bool `json:"list"`
Name string `json:"name"`
Type string `json:"type"`
Value bool `json:"value"`
}
type ButtonField struct {
Data map[string]interface{} `json:"data"`
ID string `json:"id"`
List bool `json:"list"`
Name string `json:"name"`
Type string `json:"type"`
Value string `json:"value"`
}
type HTMLField struct {
Data map[string]interface{} `json:"data"`
ID string `json:"id"`
List bool `json:"list"`
Name string `json:"name"`
Type string `json:"type"`
Value interface{} `json:"value"`
}
func (f HTMLField) String() string {
value, ok := f.Value.(string)
if !ok {
return ""
}
return value
}
func (f HTMLField) StringSlice() []string {
if f.List {
values, ok := f.Value.([]interface{})
if !ok {
return nil
}
strs := []string{}
for _, v := range values {
str, ok := v.(string)
if !ok {
return nil
}
strs = append(strs, str)
}
return strs
}
return []string{}
}
type TextField struct {
Data map[string]interface{} `json:"data"`
ID string `json:"id"`
List bool `json:"list"`
Name string `json:"name"`
Type string `json:"type"`
Value string `json:"value"`
}
type Template struct {
ID string `json:"id"`
Name string `json:"name"`
}