-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathrtm_gen.go
72 lines (61 loc) · 1.65 KB
/
rtm_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
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)
// RTMStartCall is created by RTMService.Start method call
type RTMStartCall struct {
service *RTMService
}
// Start creates a RTMStartCall object in preparation for accessing the rtm.start endpoint
func (s *RTMService) Start() *RTMStartCall {
var call RTMStartCall
call.service = s
return &call
}
// ValidateArgs checks that all required fields are set in the RTMStartCall object
func (c *RTMStartCall) ValidateArgs() error {
return nil
}
// Values returns the RTMStartCall object as url.Values
func (c *RTMStartCall) 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 rtm.start endpoint
func (c *RTMStartCall) Do(ctx context.Context) (*objects.RTMResponse, error) {
const endpoint = "rtm.start"
v, err := c.Values()
if err != nil {
return nil, err
}
var res struct {
objects.GenericResponse
*objects.RTMResponse
}
if err := c.service.client.postForm(ctx, endpoint, v, &res); err != nil {
return nil, errors.Wrap(err, `failed to post to rtm.start`)
}
if !res.OK {
return nil, errors.New(res.Error.String())
}
return res.RTMResponse, nil
}
// FromValues parses the data in v and populates `c`
func (c *RTMStartCall) FromValues(v url.Values) error {
var tmp RTMStartCall
*c = tmp
return nil
}