Update nlopes/slack vendor

This commit is contained in:
Wim
2018-08-10 00:38:19 +02:00
parent 51062863a5
commit 68aeb93afa
57 changed files with 2654 additions and 2047 deletions

View File

@@ -45,25 +45,24 @@ func (api *Client) AddStar(channel string, item ItemRef) error {
func (api *Client) AddStarContext(ctx context.Context, channel string, item ItemRef) error {
values := url.Values{
"channel": {channel},
"token": {api.config.token},
"token": {api.token},
}
if item.Timestamp != "" {
values.Set("timestamp", string(item.Timestamp))
values.Set("timestamp", item.Timestamp)
}
if item.File != "" {
values.Set("file", string(item.File))
values.Set("file", item.File)
}
if item.Comment != "" {
values.Set("file_comment", string(item.Comment))
values.Set("file_comment", item.Comment)
}
response := &SlackResponse{}
if err := post(ctx, "stars.add", values, response, api.debug); err != nil {
if err := postSlackMethod(ctx, api.httpclient, "stars.add", values, response, api.debug); err != nil {
return err
}
if !response.Ok {
return errors.New(response.Error)
}
return nil
return response.Err()
}
// RemoveStar removes a starred item from a channel
@@ -75,25 +74,24 @@ func (api *Client) RemoveStar(channel string, item ItemRef) error {
func (api *Client) RemoveStarContext(ctx context.Context, channel string, item ItemRef) error {
values := url.Values{
"channel": {channel},
"token": {api.config.token},
"token": {api.token},
}
if item.Timestamp != "" {
values.Set("timestamp", string(item.Timestamp))
values.Set("timestamp", item.Timestamp)
}
if item.File != "" {
values.Set("file", string(item.File))
values.Set("file", item.File)
}
if item.Comment != "" {
values.Set("file_comment", string(item.Comment))
values.Set("file_comment", item.Comment)
}
response := &SlackResponse{}
if err := post(ctx, "stars.remove", values, response, api.debug); err != nil {
if err := postSlackMethod(ctx, api.httpclient, "stars.remove", values, response, api.debug); err != nil {
return err
}
if !response.Ok {
return errors.New(response.Error)
}
return nil
return response.Err()
}
// ListStars returns information about the stars a user added
@@ -104,7 +102,7 @@ func (api *Client) ListStars(params StarsParameters) ([]Item, *Paging, error) {
// ListStarsContext returns information about the stars a user added with a custom context
func (api *Client) ListStarsContext(ctx context.Context, params StarsParameters) ([]Item, *Paging, error) {
values := url.Values{
"token": {api.config.token},
"token": {api.token},
}
if params.User != DEFAULT_STARS_USER {
values.Add("user", params.User)
@@ -115,8 +113,9 @@ func (api *Client) ListStarsContext(ctx context.Context, params StarsParameters)
if params.Page != DEFAULT_STARS_PAGE {
values.Add("page", strconv.Itoa(params.Page))
}
response := &listResponseFull{}
err := post(ctx, "stars.list", values, response, api.debug)
err := postSlackMethod(ctx, api.httpclient, "stars.list", values, response, api.debug)
if err != nil {
return nil, nil, err
}