-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathchannels_gen.go
1272 lines (1115 loc) · 33.4 KB
/
channels_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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
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)
// ChannelsArchiveCall is created by ChannelsService.Archive method call
type ChannelsArchiveCall struct {
service *ChannelsService
channel string
}
// ChannelsCreateCall is created by ChannelsService.Create method call
type ChannelsCreateCall struct {
service *ChannelsService
name string
validate bool
}
// ChannelsHistoryCall is created by ChannelsService.History method call
type ChannelsHistoryCall struct {
service *ChannelsService
channel string
count int // 1 - 1000
inclusive bool
latest string // Range of time (end)
oldest string // Range of time (start)
timestamp string // Used only when retrieving a single message
unreads bool // Include unread_count_display in the output
}
// ChannelsInfoCall is created by ChannelsService.Info method call
type ChannelsInfoCall struct {
service *ChannelsService
channel string
includeLocale bool
}
// ChannelsInviteCall is created by ChannelsService.Invite method call
type ChannelsInviteCall struct {
service *ChannelsService
channel string
user string
}
// ChannelsJoinCall is created by ChannelsService.Join method call
type ChannelsJoinCall struct {
service *ChannelsService
name string
validate bool
}
// ChannelsKickCall is created by ChannelsService.Kick method call
type ChannelsKickCall struct {
service *ChannelsService
channel string
user string
}
// ChannelsLeaveCall is created by ChannelsService.Leave method call
type ChannelsLeaveCall struct {
service *ChannelsService
channel string
}
// ChannelsListCall is created by ChannelsService.List method call
type ChannelsListCall struct {
service *ChannelsService
excludeArchive bool // Exclude archived channels
excludeMembers bool // Exclude the list of members in channels
limit int
}
// ChannelsMarkCall is created by ChannelsService.Mark method call
type ChannelsMarkCall struct {
service *ChannelsService
channel string
timestamp string
}
// ChannelsRenameCall is created by ChannelsService.Rename method call
type ChannelsRenameCall struct {
service *ChannelsService
channel string
name string
validate bool
}
// ChannelsRepliesCall is created by ChannelsService.Replies method call
type ChannelsRepliesCall struct {
service *ChannelsService
channel string
threadTimestamp string
}
// ChannelsSetPurposeCall is created by ChannelsService.SetPurpose method call
type ChannelsSetPurposeCall struct {
service *ChannelsService
channel string
purpose string
}
// ChannelsSetTopicCall is created by ChannelsService.SetTopic method call
type ChannelsSetTopicCall struct {
service *ChannelsService
channel string
topic string
}
// ChannelsUnarchiveCall is created by ChannelsService.Unarchive method call
type ChannelsUnarchiveCall struct {
service *ChannelsService
channel string
}
// Archive creates a ChannelsArchiveCall object in preparation for accessing the channels.archive endpoint
func (s *ChannelsService) Archive(channel string) *ChannelsArchiveCall {
var call ChannelsArchiveCall
call.service = s
call.channel = channel
return &call
}
// ValidateArgs checks that all required fields are set in the ChannelsArchiveCall object
func (c *ChannelsArchiveCall) ValidateArgs() error {
if len(c.channel) <= 0 {
return errors.New(`required field channel not initialized`)
}
return nil
}
// Values returns the ChannelsArchiveCall object as url.Values
func (c *ChannelsArchiveCall) 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("channel", c.channel)
return v, nil
}
// Do executes the call to access channels.archive endpoint
func (c *ChannelsArchiveCall) Do(ctx context.Context) error {
const endpoint = "channels.archive"
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 channels.archive`)
}
if !res.OK {
return errors.New(res.Error.String())
}
return nil
}
// FromValues parses the data in v and populates `c`
func (c *ChannelsArchiveCall) FromValues(v url.Values) error {
var tmp ChannelsArchiveCall
if raw := strings.TrimSpace(v.Get("channel")); len(raw) > 0 {
tmp.channel = raw
}
*c = tmp
return nil
}
// Create creates a ChannelsCreateCall object in preparation for accessing the channels.create endpoint
func (s *ChannelsService) Create(name string) *ChannelsCreateCall {
var call ChannelsCreateCall
call.service = s
call.name = name
return &call
}
// Validate sets the value for optional validate parameter
func (c *ChannelsCreateCall) Validate(validate bool) *ChannelsCreateCall {
c.validate = validate
return c
}
// ValidateArgs checks that all required fields are set in the ChannelsCreateCall object
func (c *ChannelsCreateCall) ValidateArgs() error {
if len(c.name) <= 0 {
return errors.New(`required field name not initialized`)
}
return nil
}
// Values returns the ChannelsCreateCall object as url.Values
func (c *ChannelsCreateCall) 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("name", c.name)
if c.validate {
v.Set("validate", "true")
}
return v, nil
}
// Do executes the call to access channels.create endpoint
func (c *ChannelsCreateCall) Do(ctx context.Context) error {
const endpoint = "channels.create"
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 channels.create`)
}
if !res.OK {
return errors.New(res.Error.String())
}
return nil
}
// FromValues parses the data in v and populates `c`
func (c *ChannelsCreateCall) FromValues(v url.Values) error {
var tmp ChannelsCreateCall
if raw := strings.TrimSpace(v.Get("name")); len(raw) > 0 {
tmp.name = raw
}
if raw := strings.TrimSpace(v.Get("validate")); len(raw) > 0 {
parsed, err := strconv.ParseBool(raw)
if err != nil {
return errors.Wrap(err, `failed to parse boolean value "validate"`)
}
tmp.validate = parsed
}
*c = tmp
return nil
}
// History creates a ChannelsHistoryCall object in preparation for accessing the channels.history endpoint
func (s *ChannelsService) History(channel string) *ChannelsHistoryCall {
var call ChannelsHistoryCall
call.service = s
call.channel = channel
return &call
}
// Count sets the value for optional count parameter
func (c *ChannelsHistoryCall) Count(count int) *ChannelsHistoryCall {
c.count = count
return c
}
// Inclusive sets the value for optional inclusive parameter
func (c *ChannelsHistoryCall) Inclusive(inclusive bool) *ChannelsHistoryCall {
c.inclusive = inclusive
return c
}
// Latest sets the value for optional latest parameter
func (c *ChannelsHistoryCall) Latest(latest string) *ChannelsHistoryCall {
c.latest = latest
return c
}
// Oldest sets the value for optional oldest parameter
func (c *ChannelsHistoryCall) Oldest(oldest string) *ChannelsHistoryCall {
c.oldest = oldest
return c
}
// Timestamp sets the value for optional timestamp parameter
func (c *ChannelsHistoryCall) Timestamp(timestamp string) *ChannelsHistoryCall {
c.timestamp = timestamp
return c
}
// Unreads sets the value for optional unreads parameter
func (c *ChannelsHistoryCall) Unreads(unreads bool) *ChannelsHistoryCall {
c.unreads = unreads
return c
}
// ValidateArgs checks that all required fields are set in the ChannelsHistoryCall object
func (c *ChannelsHistoryCall) ValidateArgs() error {
if len(c.channel) <= 0 {
return errors.New(`required field channel not initialized`)
}
return nil
}
// Values returns the ChannelsHistoryCall object as url.Values
func (c *ChannelsHistoryCall) 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("channel", c.channel)
if c.count > 0 {
v.Set("count", strconv.Itoa(c.count))
}
if c.inclusive {
v.Set("inclusive", "true")
}
if len(c.latest) > 0 {
v.Set("latest", c.latest)
}
if len(c.oldest) > 0 {
v.Set("oldest", c.oldest)
}
if len(c.timestamp) > 0 {
v.Set("ts", c.timestamp)
}
if c.unreads {
v.Set("unreads", "true")
}
return v, nil
}
// Do executes the call to access channels.history endpoint
func (c *ChannelsHistoryCall) Do(ctx context.Context) (*objects.ChannelsHistoryResponse, error) {
const endpoint = "channels.history"
v, err := c.Values()
if err != nil {
return nil, err
}
var res struct {
objects.GenericResponse
*objects.ChannelsHistoryResponse
}
if err := c.service.client.postForm(ctx, endpoint, v, &res); err != nil {
return nil, errors.Wrap(err, `failed to post to channels.history`)
}
if !res.OK {
return nil, errors.New(res.Error.String())
}
return res.ChannelsHistoryResponse, nil
}
// FromValues parses the data in v and populates `c`
func (c *ChannelsHistoryCall) FromValues(v url.Values) error {
var tmp ChannelsHistoryCall
if raw := strings.TrimSpace(v.Get("channel")); len(raw) > 0 {
tmp.channel = raw
}
if raw := strings.TrimSpace(v.Get("count")); len(raw) > 0 {
parsed, err := strconv.ParseInt(raw, 10, 64)
if err != nil {
return errors.Wrap(err, `failed to parse integer value "count"`)
}
tmp.count = int(parsed)
}
if raw := strings.TrimSpace(v.Get("inclusive")); len(raw) > 0 {
parsed, err := strconv.ParseBool(raw)
if err != nil {
return errors.Wrap(err, `failed to parse boolean value "inclusive"`)
}
tmp.inclusive = parsed
}
if raw := strings.TrimSpace(v.Get("latest")); len(raw) > 0 {
tmp.latest = raw
}
if raw := strings.TrimSpace(v.Get("oldest")); len(raw) > 0 {
tmp.oldest = raw
}
if raw := strings.TrimSpace(v.Get("ts")); len(raw) > 0 {
tmp.timestamp = raw
}
if raw := strings.TrimSpace(v.Get("unreads")); len(raw) > 0 {
parsed, err := strconv.ParseBool(raw)
if err != nil {
return errors.Wrap(err, `failed to parse boolean value "unreads"`)
}
tmp.unreads = parsed
}
*c = tmp
return nil
}
// Info creates a ChannelsInfoCall object in preparation for accessing the channels.info endpoint
func (s *ChannelsService) Info(channel string) *ChannelsInfoCall {
var call ChannelsInfoCall
call.service = s
call.channel = channel
return &call
}
// IncludeLocale sets the value for optional includeLocale parameter
func (c *ChannelsInfoCall) IncludeLocale(includeLocale bool) *ChannelsInfoCall {
c.includeLocale = includeLocale
return c
}
// ValidateArgs checks that all required fields are set in the ChannelsInfoCall object
func (c *ChannelsInfoCall) ValidateArgs() error {
if len(c.channel) <= 0 {
return errors.New(`required field channel not initialized`)
}
return nil
}
// Values returns the ChannelsInfoCall object as url.Values
func (c *ChannelsInfoCall) 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("channel", c.channel)
if c.includeLocale {
v.Set("include_locale", "true")
}
return v, nil
}
// Do executes the call to access channels.info endpoint
func (c *ChannelsInfoCall) Do(ctx context.Context) (*objects.Channel, error) {
const endpoint = "channels.info"
v, err := c.Values()
if err != nil {
return nil, err
}
var res struct {
objects.GenericResponse
*objects.Channel `json:"channel"`
}
if err := c.service.client.postForm(ctx, endpoint, v, &res); err != nil {
return nil, errors.Wrap(err, `failed to post to channels.info`)
}
if !res.OK {
return nil, errors.New(res.Error.String())
}
return res.Channel, nil
}
// FromValues parses the data in v and populates `c`
func (c *ChannelsInfoCall) FromValues(v url.Values) error {
var tmp ChannelsInfoCall
if raw := strings.TrimSpace(v.Get("channel")); len(raw) > 0 {
tmp.channel = raw
}
if raw := strings.TrimSpace(v.Get("include_locale")); len(raw) > 0 {
parsed, err := strconv.ParseBool(raw)
if err != nil {
return errors.Wrap(err, `failed to parse boolean value "include_locale"`)
}
tmp.includeLocale = parsed
}
*c = tmp
return nil
}
// Invite creates a ChannelsInviteCall object in preparation for accessing the channels.invite endpoint
func (s *ChannelsService) Invite(channel string, user string) *ChannelsInviteCall {
var call ChannelsInviteCall
call.service = s
call.channel = channel
call.user = user
return &call
}
// ValidateArgs checks that all required fields are set in the ChannelsInviteCall object
func (c *ChannelsInviteCall) ValidateArgs() error {
if len(c.channel) <= 0 {
return errors.New(`required field channel not initialized`)
}
if len(c.user) <= 0 {
return errors.New(`required field user not initialized`)
}
return nil
}
// Values returns the ChannelsInviteCall object as url.Values
func (c *ChannelsInviteCall) 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("channel", c.channel)
v.Set("user", c.user)
return v, nil
}
// Do executes the call to access channels.invite endpoint
func (c *ChannelsInviteCall) Do(ctx context.Context) (*objects.Channel, error) {
const endpoint = "channels.invite"
v, err := c.Values()
if err != nil {
return nil, err
}
var res struct {
objects.GenericResponse
*objects.Channel `json:"channel"`
}
if err := c.service.client.postForm(ctx, endpoint, v, &res); err != nil {
return nil, errors.Wrap(err, `failed to post to channels.invite`)
}
if !res.OK {
return nil, errors.New(res.Error.String())
}
return res.Channel, nil
}
// FromValues parses the data in v and populates `c`
func (c *ChannelsInviteCall) FromValues(v url.Values) error {
var tmp ChannelsInviteCall
if raw := strings.TrimSpace(v.Get("channel")); len(raw) > 0 {
tmp.channel = raw
}
if raw := strings.TrimSpace(v.Get("user")); len(raw) > 0 {
tmp.user = raw
}
*c = tmp
return nil
}
// Join creates a ChannelsJoinCall object in preparation for accessing the channels.join endpoint
func (s *ChannelsService) Join(name string) *ChannelsJoinCall {
var call ChannelsJoinCall
call.service = s
call.name = name
return &call
}
// Validate sets the value for optional validate parameter
func (c *ChannelsJoinCall) Validate(validate bool) *ChannelsJoinCall {
c.validate = validate
return c
}
// ValidateArgs checks that all required fields are set in the ChannelsJoinCall object
func (c *ChannelsJoinCall) ValidateArgs() error {
if len(c.name) <= 0 {
return errors.New(`required field name not initialized`)
}
return nil
}
// Values returns the ChannelsJoinCall object as url.Values
func (c *ChannelsJoinCall) 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("name", c.name)
if c.validate {
v.Set("validate", "true")
}
return v, nil
}
// Do executes the call to access channels.join endpoint
func (c *ChannelsJoinCall) Do(ctx context.Context) (*objects.Channel, error) {
const endpoint = "channels.join"
v, err := c.Values()
if err != nil {
return nil, err
}
var res struct {
objects.GenericResponse
*objects.Channel
}
if err := c.service.client.postForm(ctx, endpoint, v, &res); err != nil {
return nil, errors.Wrap(err, `failed to post to channels.join`)
}
if !res.OK {
return nil, errors.New(res.Error.String())
}
return res.Channel, nil
}
// FromValues parses the data in v and populates `c`
func (c *ChannelsJoinCall) FromValues(v url.Values) error {
var tmp ChannelsJoinCall
if raw := strings.TrimSpace(v.Get("name")); len(raw) > 0 {
tmp.name = raw
}
if raw := strings.TrimSpace(v.Get("validate")); len(raw) > 0 {
parsed, err := strconv.ParseBool(raw)
if err != nil {
return errors.Wrap(err, `failed to parse boolean value "validate"`)
}
tmp.validate = parsed
}
*c = tmp
return nil
}
// Kick creates a ChannelsKickCall object in preparation for accessing the channels.kick endpoint
func (s *ChannelsService) Kick(channel string, user string) *ChannelsKickCall {
var call ChannelsKickCall
call.service = s
call.channel = channel
call.user = user
return &call
}
// ValidateArgs checks that all required fields are set in the ChannelsKickCall object
func (c *ChannelsKickCall) ValidateArgs() error {
if len(c.channel) <= 0 {
return errors.New(`required field channel not initialized`)
}
if len(c.user) <= 0 {
return errors.New(`required field user not initialized`)
}
return nil
}
// Values returns the ChannelsKickCall object as url.Values
func (c *ChannelsKickCall) 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("channel", c.channel)
v.Set("user", c.user)
return v, nil
}
// Do executes the call to access channels.kick endpoint
func (c *ChannelsKickCall) Do(ctx context.Context) error {
const endpoint = "channels.kick"
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 channels.kick`)
}
if !res.OK {
return errors.New(res.Error.String())
}
return nil
}
// FromValues parses the data in v and populates `c`
func (c *ChannelsKickCall) FromValues(v url.Values) error {
var tmp ChannelsKickCall
if raw := strings.TrimSpace(v.Get("channel")); len(raw) > 0 {
tmp.channel = raw
}
if raw := strings.TrimSpace(v.Get("user")); len(raw) > 0 {
tmp.user = raw
}
*c = tmp
return nil
}
// Leave creates a ChannelsLeaveCall object in preparation for accessing the channels.leave endpoint
func (s *ChannelsService) Leave(channel string) *ChannelsLeaveCall {
var call ChannelsLeaveCall
call.service = s
call.channel = channel
return &call
}
// ValidateArgs checks that all required fields are set in the ChannelsLeaveCall object
func (c *ChannelsLeaveCall) ValidateArgs() error {
if len(c.channel) <= 0 {
return errors.New(`required field channel not initialized`)
}
return nil
}
// Values returns the ChannelsLeaveCall object as url.Values
func (c *ChannelsLeaveCall) 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("channel", c.channel)
return v, nil
}
// Do executes the call to access channels.leave endpoint
func (c *ChannelsLeaveCall) Do(ctx context.Context) error {
const endpoint = "channels.leave"
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 channels.leave`)
}
if !res.OK {
return errors.New(res.Error.String())
}
return nil
}
// FromValues parses the data in v and populates `c`
func (c *ChannelsLeaveCall) FromValues(v url.Values) error {
var tmp ChannelsLeaveCall
if raw := strings.TrimSpace(v.Get("channel")); len(raw) > 0 {
tmp.channel = raw
}
*c = tmp
return nil
}
// List creates a ChannelsListCall object in preparation for accessing the channels.list endpoint
func (s *ChannelsService) List() *ChannelsListCall {
var call ChannelsListCall
call.service = s
return &call
}
// ExcludeArchive sets the value for optional excludeArchive parameter
func (c *ChannelsListCall) ExcludeArchive(excludeArchive bool) *ChannelsListCall {
c.excludeArchive = excludeArchive
return c
}
// ExcludeMembers sets the value for optional excludeMembers parameter
func (c *ChannelsListCall) ExcludeMembers(excludeMembers bool) *ChannelsListCall {
c.excludeMembers = excludeMembers
return c
}
// Limit sets the value for optional limit parameter
func (c *ChannelsListCall) Limit(limit int) *ChannelsListCall {
c.limit = limit
return c
}
// ValidateArgs checks that all required fields are set in the ChannelsListCall object
func (c *ChannelsListCall) ValidateArgs() error {
return nil
}
// Values returns the ChannelsListCall object as url.Values
func (c *ChannelsListCall) 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)
if c.excludeArchive {
v.Set("exclude_archive", "true")
}
if c.excludeMembers {
v.Set("exclude_members", "true")
}
if c.limit > 0 {
v.Set("limit", strconv.Itoa(c.limit))
}
return v, nil
}
// Do executes the call to access channels.list endpoint
func (c *ChannelsListCall) Do(ctx context.Context) (objects.ChannelList, error) {
const endpoint = "channels.list"
v, err := c.Values()
if err != nil {
return nil, err
}
var res struct {
objects.GenericResponse
objects.ChannelList `json:"channels"`
}
if err := c.service.client.postForm(ctx, endpoint, v, &res); err != nil {
return nil, errors.Wrap(err, `failed to post to channels.list`)
}
if !res.OK {
return nil, errors.New(res.Error.String())
}
return res.ChannelList, nil
}
// FromValues parses the data in v and populates `c`
func (c *ChannelsListCall) FromValues(v url.Values) error {
var tmp ChannelsListCall
if raw := strings.TrimSpace(v.Get("exclude_archive")); len(raw) > 0 {
parsed, err := strconv.ParseBool(raw)
if err != nil {
return errors.Wrap(err, `failed to parse boolean value "exclude_archive"`)
}
tmp.excludeArchive = parsed
}
if raw := strings.TrimSpace(v.Get("exclude_members")); len(raw) > 0 {
parsed, err := strconv.ParseBool(raw)
if err != nil {
return errors.Wrap(err, `failed to parse boolean value "exclude_members"`)
}
tmp.excludeMembers = parsed
}
if raw := strings.TrimSpace(v.Get("limit")); len(raw) > 0 {
parsed, err := strconv.ParseInt(raw, 10, 64)
if err != nil {
return errors.Wrap(err, `failed to parse integer value "limit"`)
}
tmp.limit = int(parsed)
}
*c = tmp
return nil
}
// Mark creates a ChannelsMarkCall object in preparation for accessing the channels.mark endpoint
func (s *ChannelsService) Mark(channel string) *ChannelsMarkCall {
var call ChannelsMarkCall
call.service = s
call.channel = channel
return &call
}
// Timestamp sets the value for optional timestamp parameter
func (c *ChannelsMarkCall) Timestamp(timestamp string) *ChannelsMarkCall {
c.timestamp = timestamp
return c
}
// ValidateArgs checks that all required fields are set in the ChannelsMarkCall object
func (c *ChannelsMarkCall) ValidateArgs() error {
if len(c.channel) <= 0 {
return errors.New(`required field channel not initialized`)
}
return nil
}
// Values returns the ChannelsMarkCall object as url.Values
func (c *ChannelsMarkCall) 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("channel", c.channel)
if len(c.timestamp) > 0 {
v.Set("ts", c.timestamp)
}
return v, nil
}
// Do executes the call to access channels.mark endpoint
func (c *ChannelsMarkCall) Do(ctx context.Context) error {
const endpoint = "channels.mark"
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 channels.mark`)
}
if !res.OK {
return errors.New(res.Error.String())
}
return nil
}
// FromValues parses the data in v and populates `c`
func (c *ChannelsMarkCall) FromValues(v url.Values) error {
var tmp ChannelsMarkCall
if raw := strings.TrimSpace(v.Get("channel")); len(raw) > 0 {
tmp.channel = raw
}
if raw := strings.TrimSpace(v.Get("ts")); len(raw) > 0 {
tmp.timestamp = raw
}
*c = tmp
return nil
}
// Rename creates a ChannelsRenameCall object in preparation for accessing the channels.rename endpoint
func (s *ChannelsService) Rename(channel string, name string) *ChannelsRenameCall {
var call ChannelsRenameCall
call.service = s
call.channel = channel
call.name = name
return &call
}
// Validate sets the value for optional validate parameter
func (c *ChannelsRenameCall) Validate(validate bool) *ChannelsRenameCall {
c.validate = validate
return c
}
// ValidateArgs checks that all required fields are set in the ChannelsRenameCall object
func (c *ChannelsRenameCall) ValidateArgs() error {
if len(c.channel) <= 0 {
return errors.New(`required field channel not initialized`)
}
if len(c.name) <= 0 {
return errors.New(`required field name not initialized`)
}
return nil
}
// Values returns the ChannelsRenameCall object as url.Values
func (c *ChannelsRenameCall) 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("channel", c.channel)
v.Set("name", c.name)
if c.validate {
v.Set("validate", "true")
}
return v, nil
}
// Do executes the call to access channels.rename endpoint
func (c *ChannelsRenameCall) Do(ctx context.Context) (*objects.Channel, error) {
const endpoint = "channels.rename"
v, err := c.Values()
if err != nil {
return nil, err
}
var res struct {
objects.GenericResponse
*objects.Channel `json:"channel"`
}
if err := c.service.client.postForm(ctx, endpoint, v, &res); err != nil {
return nil, errors.Wrap(err, `failed to post to channels.rename`)
}
if !res.OK {
return nil, errors.New(res.Error.String())
}
return res.Channel, nil
}
// FromValues parses the data in v and populates `c`
func (c *ChannelsRenameCall) FromValues(v url.Values) error {
var tmp ChannelsRenameCall
if raw := strings.TrimSpace(v.Get("channel")); len(raw) > 0 {
tmp.channel = raw
}
if raw := strings.TrimSpace(v.Get("name")); len(raw) > 0 {
tmp.name = raw
}