Skip to content

Commit ee38187

Browse files
committed
document channel_api.go
1 parent 6bc6f52 commit ee38187

File tree

1 file changed

+61
-4
lines changed

1 file changed

+61
-4
lines changed

api/channel_api.go

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func NewEmbed() *Embed {
7777
}
7878
}
7979

80+
// SetTitle - Set the Embed title
8081
func (e *Embed) SetTitle(title string) *Embed {
8182
if len(title) > titleLimit {
8283
title = title[:titleLimit-4] + " ..."
@@ -86,10 +87,13 @@ func (e *Embed) SetTitle(title string) *Embed {
8687
return e
8788
}
8889

90+
// GetTitle - Get the Embed title
91+
// Deprecated: Access the struct field directly
8992
func (e *Embed) GetTitle() string {
9093
return e.Title
9194
}
9295

96+
// SetDescription - Set the Embed description
9397
func (e *Embed) SetDescription(description string) *Embed {
9498
if len(description) > descriptionLimit {
9599
description = description[:descriptionLimit-4] + " ..."
@@ -99,10 +103,13 @@ func (e *Embed) SetDescription(description string) *Embed {
99103
return e
100104
}
101105

106+
// GetDescription - Get the Embed description
107+
// Deprecated: Access the struct field directly
102108
func (e *Embed) GetDescription() string {
103109
return e.Description
104110
}
105111

112+
// SetURL - Set the Embed URL
106113
func (e *Embed) SetURL(u string) *Embed {
107114
// We only check for an error to validate if it's a properly formed URL
108115
if _, err := url.Parse(u); err != nil {
@@ -113,76 +120,98 @@ func (e *Embed) SetURL(u string) *Embed {
113120
return e
114121
}
115122

123+
// GetURL - Get the Embed URL
124+
// Deprecated: Access the struct field directly
116125
func (e *Embed) GetURL() string {
117126
return e.URL
118127
}
119128

129+
// SetTimestamp - Set the Embed timestamp
120130
func (e *Embed) SetTimestamp(ts time.Time) *Embed {
121131
e.Timestamp = ts.UTC().Format(time.RFC3339)
122132

123133
return e
124134
}
125135

136+
// GetTimestamp - Get the Embed timestamp
137+
// Deprecated: Access the struct field directly
126138
func (e *Embed) GetTimestamp() (time.Time, error) {
127139
return time.Parse(time.RFC3339, e.Timestamp)
128140
}
129141

142+
// SetColor - Set the Embed color
130143
func (e *Embed) SetColor(c int64) *Embed {
131144
e.Color = c
132145

133146
return e
134147
}
135148

149+
// GetColor - Get the Embed color
150+
// Deprecated: Access the struct field directly
136151
func (e *Embed) GetColor() int64 {
137152
return e.Color
138153
}
139154

155+
// SetFooter - Set the Footer
140156
func (e *Embed) SetFooter(text string, iconURL string) *Embed {
141157
e.Footer = newFooter().SetText(text).SetIconURL(iconURL)
142158

143159
return e
144160
}
145161

162+
// GetFooter - Get the Embed footer
163+
// Deprecated: Access the struct field directly
146164
func (e *Embed) GetFooter() *Footer {
147165
return e.Footer
148166
}
149167

168+
// SetImage - Set the Image
150169
func (e *Embed) SetImage(imageURL string) *Embed {
151170
e.Image = newImage().SetURL(imageURL)
152171

153172
return e
154173
}
155174

175+
// GetImage - Get the Embed image
176+
// Deprecated: Access the struct field directly
156177
func (e *Embed) GetImage() *Image {
157178
return e.Image
158179
}
159180

181+
// SetThumbnail - Set the Thumbnail
160182
func (e *Embed) SetThumbnail(thumbnailURL string) *Embed {
161183
e.Thumbnail = newThumbnail().SetURL(thumbnailURL)
162184

163185
return e
164186
}
165187

188+
// GetThumbnail - Get the Embed thumbnail
189+
// Deprecated: Access the struct field directly
166190
func (e *Embed) GetThumbnail() string {
167191
return e.Thumbnail.URL
168192
}
169193

194+
// SetAuthor - Set the Author
170195
func (e *Embed) SetAuthor(name, url string, iconURL *string) *Embed {
171196
e.Author = newAuthor().SetName(name).SetURL(url).SetIconURL(iconURL)
172197

173198
return e
174199
}
175200

201+
// GetAuthor - Get the Embed author
202+
// Deprecated: Access the struct field directly
176203
func (e *Embed) GetAuthor() *Author {
177204
return e.Author
178205
}
179206

207+
// AddField - Add a singular Field
180208
func (e *Embed) AddField(name, value string, inline bool) *Embed {
181-
e.Fields = append(e.Fields, newField().SetName(name).SetValue(value).SetInline(inline))
209+
e.Fields = append(e.Fields, NewField().SetName(name).SetValue(value).SetInline(inline))
182210

183211
return e
184212
}
185213

214+
// AddFields - Add multiple fields; must create the Field objects first
186215
func (e *Embed) AddFields(fields ...*Field) *Embed {
187216
if len(fields) == 0 {
188217
return e
@@ -193,6 +222,8 @@ func (e *Embed) AddFields(fields ...*Field) *Embed {
193222
return e
194223
}
195224

225+
// GetFields - Get the Embed fields
226+
// Deprecated: Access the struct field directly
196227
func (e *Embed) GetFields() []*Field {
197228
return e.Fields
198229
}
@@ -203,6 +234,7 @@ func newFooter() *Footer {
203234
return &Footer{}
204235
}
205236

237+
// SetText - set the Footer text
206238
func (f *Footer) SetText(text string) *Footer {
207239
if len(text) > footerTextLimit {
208240
text = text[:footerTextLimit-4] + " ..."
@@ -212,10 +244,13 @@ func (f *Footer) SetText(text string) *Footer {
212244
return f
213245
}
214246

247+
// GetText - Get the Footer text
248+
// Deprecated: Access the struct field directly
215249
func (f *Footer) GetText() string {
216250
return f.Text
217251
}
218252

253+
// SetIconURL - set the Footer IconURL
219254
func (f *Footer) SetIconURL(iconURL string) *Footer {
220255
if _, err := url.Parse(iconURL); err != nil {
221256
return f
@@ -225,6 +260,8 @@ func (f *Footer) SetIconURL(iconURL string) *Footer {
225260
return f
226261
}
227262

263+
// GetIconURL - Get the Footer icon URL
264+
// Deprecated: Access the struct field directly
228265
func (f *Footer) GetIconURL() string {
229266
return f.IconURL
230267
}
@@ -235,6 +272,7 @@ func newImage() *Image {
235272
return &Image{}
236273
}
237274

275+
// SetURL - set the Image URL
238276
func (i *Image) SetURL(u string) *Image {
239277
if _, err := url.Parse(u); err != nil {
240278
return i
@@ -244,6 +282,8 @@ func (i *Image) SetURL(u string) *Image {
244282
return i
245283
}
246284

285+
// GetURL - Get the Image URL
286+
// Deprecated: Access the struct field directly
247287
func (i *Image) GetURL() string {
248288
return i.URL
249289
}
@@ -254,6 +294,7 @@ func newThumbnail() *Thumbnail {
254294
return &Thumbnail{}
255295
}
256296

297+
// SetURL - set the Thumbnail URL
257298
func (t *Thumbnail) SetURL(u string) *Thumbnail {
258299
if _, err := url.Parse(u); err != nil {
259300
return t
@@ -263,6 +304,8 @@ func (t *Thumbnail) SetURL(u string) *Thumbnail {
263304
return t
264305
}
265306

307+
// GetURL - Get the Thumbnail URL
308+
// Deprecated: Access the struct field directly
266309
func (t *Thumbnail) GetURL() string {
267310
return t.URL
268311
}
@@ -273,6 +316,7 @@ func newAuthor() *Author {
273316
return &Author{}
274317
}
275318

319+
// SetName - set the Author Name
276320
func (a *Author) SetName(name string) *Author {
277321
if len(name) > authorNameLimit {
278322
name = name[:authorNameLimit-4] + " ..."
@@ -282,10 +326,13 @@ func (a *Author) SetName(name string) *Author {
282326
return a
283327
}
284328

329+
// GetName - Get the Author name
330+
// Deprecated: Access the struct field directly
285331
func (a *Author) GetName() string {
286332
return a.Name
287333
}
288334

335+
// SetURL - set the Author URL
289336
func (a *Author) SetURL(u string) *Author {
290337
if _, err := url.Parse(u); err != nil {
291338
return a
@@ -295,10 +342,13 @@ func (a *Author) SetURL(u string) *Author {
295342
return a
296343
}
297344

345+
// GetURL - Get the Author URL
346+
// Deprecated: Access the struct field directly
298347
func (a *Author) GetURL() string {
299348
return a.URL
300349
}
301350

351+
// SetIconURL - set the Author IconURL
302352
func (a *Author) SetIconURL(u *string) *Author {
303353
if _, err := url.Parse(*u); err != nil {
304354
return a
@@ -308,12 +358,12 @@ func (a *Author) SetIconURL(u *string) *Author {
308358
return a
309359
}
310360

311-
/* EMBED FIELD */
312-
313-
func newField() *Field {
361+
// NewField - Create a new base Field to chain against
362+
func NewField() *Field {
314363
return &Field{}
315364
}
316365

366+
// SetName - set the Field Name
317367
func (f *Field) SetName(name string) *Field {
318368
if len(name) > fieldNameLimit {
319369
name = name[:fieldNameLimit-4] + " ..."
@@ -323,10 +373,13 @@ func (f *Field) SetName(name string) *Field {
323373
return f
324374
}
325375

376+
// GetName - Get the Field name
377+
// Deprecated: Access the struct field directly
326378
func (f *Field) GetName() string {
327379
return f.Name
328380
}
329381

382+
// SetValue - set the Field Value
330383
func (f *Field) SetValue(value string) *Field {
331384
if len(value) > fieldValueLimit {
332385
value = value[:fieldValueLimit-4] + " ..."
@@ -336,16 +389,20 @@ func (f *Field) SetValue(value string) *Field {
336389
return f
337390
}
338391

392+
// GetValue - Get the Field value
393+
// Deprecated: Access the struct field directly
339394
func (f *Field) GetValue() string {
340395
return f.Value
341396
}
342397

398+
// SetInline - set the Field Inline
343399
func (f *Field) SetInline(inline bool) *Field {
344400
f.Inline = inline
345401

346402
return f
347403
}
348404

405+
// IsInline - Helper function for testing is inline
349406
func (f *Field) IsInline() bool {
350407
return f.Inline
351408
}

0 commit comments

Comments
 (0)