-
Notifications
You must be signed in to change notification settings - Fork 19
/
reminders_gen.go
358 lines (312 loc) · 9.24 KB
/
reminders_gen.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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
package slack
// Auto-generated by internal/cmd/genmethods/genmethods.go. DO NOT EDIT!
import (
"context"
"net/url"
"strconv"
"strings"
"github.com/lestrrat-go/slack/objects"
"github.com/pkg/errors"
)
var _ = strconv.Itoa
var _ = strings.Index
var _ = objects.EpochTime(0)
// RemindersAddCall is created by RemindersService.Add method call
type RemindersAddCall struct {
service *RemindersService
text string
time int
user string
}
// RemindersCompleteCall is created by RemindersService.Complete method call
type RemindersCompleteCall struct {
service *RemindersService
reminder string
}
// RemindersDeleteCall is created by RemindersService.Delete method call
type RemindersDeleteCall struct {
service *RemindersService
reminder string
}
// RemindersInfoCall is created by RemindersService.Info method call
type RemindersInfoCall struct {
service *RemindersService
reminder string
}
// RemindersListCall is created by RemindersService.List method call
type RemindersListCall struct {
service *RemindersService
}
// Add creates a RemindersAddCall object in preparation for accessing the reminders.add endpoint
func (s *RemindersService) Add(text string, time int) *RemindersAddCall {
var call RemindersAddCall
call.service = s
call.text = text
call.time = time
return &call
}
// User sets the value for optional user parameter
func (c *RemindersAddCall) User(user string) *RemindersAddCall {
c.user = user
return c
}
// ValidateArgs checks that all required fields are set in the RemindersAddCall object
func (c *RemindersAddCall) ValidateArgs() error {
if len(c.text) <= 0 {
return errors.New(`required field text not initialized`)
}
if c.time == 0 {
return errors.New(`required field time not initialized`)
}
return nil
}
// Values returns the RemindersAddCall object as url.Values
func (c *RemindersAddCall) Values() (url.Values, error) {
if err := c.ValidateArgs(); err != nil {
return nil, errors.Wrap(err, `failed validation`)
}
v := url.Values{}
v.Set(`token`, c.service.token)
v.Set("text", c.text)
v.Set("time", strconv.Itoa(c.time))
if len(c.user) > 0 {
v.Set("user", c.user)
}
return v, nil
}
// Do executes the call to access reminders.add endpoint
func (c *RemindersAddCall) Do(ctx context.Context) (*objects.Reminder, error) {
const endpoint = "reminders.add"
v, err := c.Values()
if err != nil {
return nil, err
}
var res struct {
objects.GenericResponse
*objects.Reminder
}
if err := c.service.client.postForm(ctx, endpoint, v, &res); err != nil {
return nil, errors.Wrap(err, `failed to post to reminders.add`)
}
if !res.OK {
return nil, errors.New(res.Error.String())
}
return res.Reminder, nil
}
// FromValues parses the data in v and populates `c`
func (c *RemindersAddCall) FromValues(v url.Values) error {
var tmp RemindersAddCall
if raw := strings.TrimSpace(v.Get("text")); len(raw) > 0 {
tmp.text = raw
}
if raw := strings.TrimSpace(v.Get("time")); len(raw) > 0 {
parsed, err := strconv.ParseInt(raw, 10, 64)
if err != nil {
return errors.Wrap(err, `failed to parse integer value "time"`)
}
tmp.time = int(parsed)
}
if raw := strings.TrimSpace(v.Get("user")); len(raw) > 0 {
tmp.user = raw
}
*c = tmp
return nil
}
// Complete creates a RemindersCompleteCall object in preparation for accessing the reminders.complete endpoint
func (s *RemindersService) Complete(reminder string) *RemindersCompleteCall {
var call RemindersCompleteCall
call.service = s
call.reminder = reminder
return &call
}
// ValidateArgs checks that all required fields are set in the RemindersCompleteCall object
func (c *RemindersCompleteCall) ValidateArgs() error {
if len(c.reminder) <= 0 {
return errors.New(`required field reminder not initialized`)
}
return nil
}
// Values returns the RemindersCompleteCall object as url.Values
func (c *RemindersCompleteCall) Values() (url.Values, error) {
if err := c.ValidateArgs(); err != nil {
return nil, errors.Wrap(err, `failed validation`)
}
v := url.Values{}
v.Set(`token`, c.service.token)
v.Set("reminder", c.reminder)
return v, nil
}
// Do executes the call to access reminders.complete endpoint
func (c *RemindersCompleteCall) Do(ctx context.Context) error {
const endpoint = "reminders.complete"
v, err := c.Values()
if err != nil {
return err
}
var res struct {
objects.GenericResponse
}
if err := c.service.client.postForm(ctx, endpoint, v, &res); err != nil {
return errors.Wrap(err, `failed to post to reminders.complete`)
}
if !res.OK {
return errors.New(res.Error.String())
}
return nil
}
// FromValues parses the data in v and populates `c`
func (c *RemindersCompleteCall) FromValues(v url.Values) error {
var tmp RemindersCompleteCall
if raw := strings.TrimSpace(v.Get("reminder")); len(raw) > 0 {
tmp.reminder = raw
}
*c = tmp
return nil
}
// Delete creates a RemindersDeleteCall object in preparation for accessing the reminders.delete endpoint
func (s *RemindersService) Delete(reminder string) *RemindersDeleteCall {
var call RemindersDeleteCall
call.service = s
call.reminder = reminder
return &call
}
// ValidateArgs checks that all required fields are set in the RemindersDeleteCall object
func (c *RemindersDeleteCall) ValidateArgs() error {
if len(c.reminder) <= 0 {
return errors.New(`required field reminder not initialized`)
}
return nil
}
// Values returns the RemindersDeleteCall object as url.Values
func (c *RemindersDeleteCall) Values() (url.Values, error) {
if err := c.ValidateArgs(); err != nil {
return nil, errors.Wrap(err, `failed validation`)
}
v := url.Values{}
v.Set(`token`, c.service.token)
v.Set("reminder", c.reminder)
return v, nil
}
// Do executes the call to access reminders.delete endpoint
func (c *RemindersDeleteCall) Do(ctx context.Context) error {
const endpoint = "reminders.delete"
v, err := c.Values()
if err != nil {
return err
}
var res struct {
objects.GenericResponse
}
if err := c.service.client.postForm(ctx, endpoint, v, &res); err != nil {
return errors.Wrap(err, `failed to post to reminders.delete`)
}
if !res.OK {
return errors.New(res.Error.String())
}
return nil
}
// FromValues parses the data in v and populates `c`
func (c *RemindersDeleteCall) FromValues(v url.Values) error {
var tmp RemindersDeleteCall
if raw := strings.TrimSpace(v.Get("reminder")); len(raw) > 0 {
tmp.reminder = raw
}
*c = tmp
return nil
}
// Info creates a RemindersInfoCall object in preparation for accessing the reminders.info endpoint
func (s *RemindersService) Info(reminder string) *RemindersInfoCall {
var call RemindersInfoCall
call.service = s
call.reminder = reminder
return &call
}
// ValidateArgs checks that all required fields are set in the RemindersInfoCall object
func (c *RemindersInfoCall) ValidateArgs() error {
if len(c.reminder) <= 0 {
return errors.New(`required field reminder not initialized`)
}
return nil
}
// Values returns the RemindersInfoCall object as url.Values
func (c *RemindersInfoCall) Values() (url.Values, error) {
if err := c.ValidateArgs(); err != nil {
return nil, errors.Wrap(err, `failed validation`)
}
v := url.Values{}
v.Set(`token`, c.service.token)
v.Set("reminder", c.reminder)
return v, nil
}
// Do executes the call to access reminders.info endpoint
func (c *RemindersInfoCall) Do(ctx context.Context) (*objects.Reminder, error) {
const endpoint = "reminders.info"
v, err := c.Values()
if err != nil {
return nil, err
}
var res struct {
objects.GenericResponse
*objects.Reminder
}
if err := c.service.client.postForm(ctx, endpoint, v, &res); err != nil {
return nil, errors.Wrap(err, `failed to post to reminders.info`)
}
if !res.OK {
return nil, errors.New(res.Error.String())
}
return res.Reminder, nil
}
// FromValues parses the data in v and populates `c`
func (c *RemindersInfoCall) FromValues(v url.Values) error {
var tmp RemindersInfoCall
if raw := strings.TrimSpace(v.Get("reminder")); len(raw) > 0 {
tmp.reminder = raw
}
*c = tmp
return nil
}
// List creates a RemindersListCall object in preparation for accessing the reminders.list endpoint
func (s *RemindersService) List() *RemindersListCall {
var call RemindersListCall
call.service = s
return &call
}
// ValidateArgs checks that all required fields are set in the RemindersListCall object
func (c *RemindersListCall) ValidateArgs() error {
return nil
}
// Values returns the RemindersListCall object as url.Values
func (c *RemindersListCall) Values() (url.Values, error) {
if err := c.ValidateArgs(); err != nil {
return nil, errors.Wrap(err, `failed validation`)
}
v := url.Values{}
v.Set(`token`, c.service.token)
return v, nil
}
// Do executes the call to access reminders.list endpoint
func (c *RemindersListCall) Do(ctx context.Context) (objects.ReminderList, error) {
const endpoint = "reminders.list"
v, err := c.Values()
if err != nil {
return nil, err
}
var res struct {
objects.GenericResponse
objects.ReminderList `json:"reminders"`
}
if err := c.service.client.postForm(ctx, endpoint, v, &res); err != nil {
return nil, errors.Wrap(err, `failed to post to reminders.list`)
}
if !res.OK {
return nil, errors.New(res.Error.String())
}
return res.ReminderList, nil
}
// FromValues parses the data in v and populates `c`
func (c *RemindersListCall) FromValues(v url.Values) error {
var tmp RemindersListCall
*c = tmp
return nil
}