-
Notifications
You must be signed in to change notification settings - Fork 7
/
list.go
267 lines (226 loc) · 5.47 KB
/
list.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
package yext
import (
"encoding/json"
"reflect"
)
type ListType string
const (
BIO ListType = "BIOS"
MENU ListType = "MENU"
PRODUCT ListType = "PRODUCTS"
EVENT ListType = "EVENTS"
)
// Generic base of a list
type List struct {
Id *string `json:"id"`
Name *string `json:"name,omitempty"` // max length 100
Title *string `json:"title,omitempty"` // max length 100
Type *string `json:"type,omitempty"` // one of MENU, BIOS, PRODUCTS, EVENTS
Size *int `json:"size,omitempty"` // read only
Publish *bool `json:"publish"`
Language *string `json:"language,omitempty"`
Currency *string `json:"currency,omitempty"` // ISO Code for currency
Sections []*ListSection `json:"sections,omitempty"`
}
func (e List) GetId() string {
if e.Id != nil {
return *e.Id
}
return ""
}
func (e List) GetName() string {
if e.Name != nil {
return *e.Name
}
return ""
}
func (e List) GetTitle() string {
if e.Title != nil {
return *e.Title
}
return ""
}
func (e List) GetType() string {
if e.Type != nil {
return *e.Type
}
return ""
}
func (e List) GetSize() int {
if e.Size != nil {
return *e.Size
}
return -1
}
func (e List) GetPublish() bool {
if e.Publish != nil {
return *e.Publish
}
return false
}
func (e List) GetLanguage() string {
if e.Language != nil {
return *e.Language
}
return ""
}
func (e List) GetCurrency() string {
if e.Currency != nil {
return *e.Currency
}
return ""
}
type ListSection struct {
Id *string `json:"id"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
}
func (e ListSection) GetId() string {
if e.Id != nil {
return *e.Id
}
return ""
}
func (e ListSection) GetName() string {
if e.Name != nil {
return *e.Name
}
return ""
}
func (e ListSection) GetDescription() string {
if e.Description != nil {
return *e.Description
}
return ""
}
type ListItem struct {
Id *string `json:"id"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
}
func (e ListItem) GetId() string {
if e.Id != nil {
return *e.Id
}
return ""
}
func (e ListItem) GetName() string {
if e.Name != nil {
return *e.Name
}
return ""
}
func (e ListItem) GetDescription() string {
if e.Description != nil {
return *e.Description
}
return ""
}
type ListPhoto struct {
Url string `json:"url"`
Height int `json:"height,omitempty"`
Width int `json:"width,omitempty"`
AlternateText string `json:"alternateText,omitempty"`
}
type Cost struct {
Type string `json:"type,omitempty"`
Price string `json:"price,omitempty"`
Unit string `json:"unit,omitempty"`
RangeTo string `json:"rangeTo,omitempty"`
Other string `json:"other,omitempty"`
Options []*CostOptions `json:"options,omitempty"`
}
type CostOptions struct {
Name string `json:"name,omitempty"`
Price string `json:"price,omitempty"`
Calorie int `json:"calorie,omitempty"`
}
type Calories struct {
Type string `json:"type,omitempty"`
Calorie int `json:"calorie,omitempty"`
RangeTo int `json:"rangeTo,omitempty"`
}
type EventList struct {
List
Sections []*EventListSection `json:"sections,omitempty"`
}
func (e EventList) String() string {
l, _ := json.Marshal(e)
return string(l)
}
type EventListSection struct {
ListSection
Items []*Event `json:"items,omitempty"` // max 100 items
}
type Event struct {
ListItem
Type string `json:"type,omitempty"`
Starts string `json:"starts,omitempty"`
Ends string `json:"ends,omitempty"`
Photos []*ListPhoto `json:"photos,omitempty"`
Url string `json:"url,omitempty"`
}
type ProductList struct {
List
Sections []*ProductListSection `json:"sections,omitempty"`
}
func (p ProductList) String() string {
l, _ := json.Marshal(p)
return string(l)
}
type ProductListSection struct {
ListSection
Items []*Product `json:"items,omitempty"` // max 100 items
}
type Product struct {
ListItem
Type string `json:"idcode,omitempty"`
Cost *Cost `json:"cost,omitempty"`
Photos []*ListPhoto `json:"photos,omitempty"`
Video string `json:"video,omitempty"`
Url string `json:"url,omitempty"`
}
type MenuList struct {
List
Sections []*MenuListSection `json:"sections,omitempty"`
}
func (m MenuList) String() string {
l, _ := json.Marshal(m)
return string(l)
}
type MenuListSection struct {
ListSection
Items []*Menu `json:"items,omitempty"` // max 100 items
}
type Menu struct {
ListItem
Cost *Cost `json:"cost,omitempty"`
Photo *ListPhoto `json:"photo,omitempty"`
Calories *Calories `json:"calories,omitempty"`
}
type BioList struct {
List
Sections []*BioListSection `json:"sections,omitempty"`
}
func (b BioList) String() string {
l, _ := json.Marshal(b)
return string(l)
}
type BioListSection struct {
ListSection
Items []*Bio `json:"items,omitempty"` // max 100 items
}
type Bio struct {
ListItem
Title string `json:"title,omitempty"`
Photo *ListPhoto `json:"photo,omitempty"`
PhoneNumber string `json:"phone,omitempty"`
EmailAddress string `json:"email,omitempty"`
Education []string `json:"education"`
Certifications []string `json:"certifications"`
Services []string `json:"services,omitempty"`
Url string `json:"url,omitempty"`
}
func BioItemCompare(itemA Bio, itemB Bio) bool {
return reflect.DeepEqual(itemA, itemB)
}