summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nlopes/slack/groups.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/nlopes/slack/groups.go')
-rw-r--r--vendor/github.com/nlopes/slack/groups.go43
1 files changed, 20 insertions, 23 deletions
diff --git a/vendor/github.com/nlopes/slack/groups.go b/vendor/github.com/nlopes/slack/groups.go
index 67e78e99..a248f6fd 100644
--- a/vendor/github.com/nlopes/slack/groups.go
+++ b/vendor/github.com/nlopes/slack/groups.go
@@ -2,7 +2,6 @@ package slack
import (
"context"
- "errors"
"net/url"
"strconv"
)
@@ -28,16 +27,14 @@ type groupResponseFull struct {
SlackResponse
}
-func groupRequest(ctx context.Context, client HTTPRequester, path string, values url.Values, debug bool) (*groupResponseFull, error) {
+func groupRequest(ctx context.Context, client httpClient, path string, values url.Values, d debug) (*groupResponseFull, error) {
response := &groupResponseFull{}
- err := postForm(ctx, client, SLACK_API+path, values, response, debug)
+ err := postForm(ctx, client, APIURL+path, values, response, d)
if err != nil {
return nil, err
}
- if !response.Ok {
- return nil, errors.New(response.Error)
- }
- return response, nil
+
+ return response, response.Err()
}
// ArchiveGroup archives a private group
@@ -52,7 +49,7 @@ func (api *Client) ArchiveGroupContext(ctx context.Context, group string) error
"channel": {group},
}
- _, err := groupRequest(ctx, api.httpclient, "groups.archive", values, api.debug)
+ _, err := groupRequest(ctx, api.httpclient, "groups.archive", values, api)
return err
}
@@ -68,7 +65,7 @@ func (api *Client) UnarchiveGroupContext(ctx context.Context, group string) erro
"channel": {group},
}
- _, err := groupRequest(ctx, api.httpclient, "groups.unarchive", values, api.debug)
+ _, err := groupRequest(ctx, api.httpclient, "groups.unarchive", values, api)
return err
}
@@ -84,7 +81,7 @@ func (api *Client) CreateGroupContext(ctx context.Context, group string) (*Group
"name": {group},
}
- response, err := groupRequest(ctx, api.httpclient, "groups.create", values, api.debug)
+ response, err := groupRequest(ctx, api.httpclient, "groups.create", values, api)
if err != nil {
return nil, err
}
@@ -109,7 +106,7 @@ func (api *Client) CreateChildGroupContext(ctx context.Context, group string) (*
"channel": {group},
}
- response, err := groupRequest(ctx, api.httpclient, "groups.createChild", values, api.debug)
+ response, err := groupRequest(ctx, api.httpclient, "groups.createChild", values, api)
if err != nil {
return nil, err
}
@@ -128,7 +125,7 @@ func (api *Client) CloseGroupContext(ctx context.Context, group string) (bool, b
"channel": {group},
}
- response, err := imRequest(ctx, api.httpclient, "groups.close", values, api.debug)
+ response, err := imRequest(ctx, api.httpclient, "groups.close", values, api)
if err != nil {
return false, false, err
}
@@ -170,7 +167,7 @@ func (api *Client) GetGroupHistoryContext(ctx context.Context, group string, par
}
}
- response, err := groupRequest(ctx, api.httpclient, "groups.history", values, api.debug)
+ response, err := groupRequest(ctx, api.httpclient, "groups.history", values, api)
if err != nil {
return nil, err
}
@@ -190,7 +187,7 @@ func (api *Client) InviteUserToGroupContext(ctx context.Context, group, user str
"user": {user},
}
- response, err := groupRequest(ctx, api.httpclient, "groups.invite", values, api.debug)
+ response, err := groupRequest(ctx, api.httpclient, "groups.invite", values, api)
if err != nil {
return nil, false, err
}
@@ -209,7 +206,7 @@ func (api *Client) LeaveGroupContext(ctx context.Context, group string) (err err
"channel": {group},
}
- _, err = groupRequest(ctx, api.httpclient, "groups.leave", values, api.debug)
+ _, err = groupRequest(ctx, api.httpclient, "groups.leave", values, api)
return err
}
@@ -226,7 +223,7 @@ func (api *Client) KickUserFromGroupContext(ctx context.Context, group, user str
"user": {user},
}
- _, err = groupRequest(ctx, api.httpclient, "groups.kick", values, api.debug)
+ _, err = groupRequest(ctx, api.httpclient, "groups.kick", values, api)
return err
}
@@ -244,7 +241,7 @@ func (api *Client) GetGroupsContext(ctx context.Context, excludeArchived bool) (
values.Add("exclude_archived", "1")
}
- response, err := groupRequest(ctx, api.httpclient, "groups.list", values, api.debug)
+ response, err := groupRequest(ctx, api.httpclient, "groups.list", values, api)
if err != nil {
return nil, err
}
@@ -263,7 +260,7 @@ func (api *Client) GetGroupInfoContext(ctx context.Context, group string) (*Grou
"channel": {group},
}
- response, err := groupRequest(ctx, api.httpclient, "groups.info", values, api.debug)
+ response, err := groupRequest(ctx, api.httpclient, "groups.info", values, api)
if err != nil {
return nil, err
}
@@ -288,7 +285,7 @@ func (api *Client) SetGroupReadMarkContext(ctx context.Context, group, ts string
"ts": {ts},
}
- _, err = groupRequest(ctx, api.httpclient, "groups.mark", values, api.debug)
+ _, err = groupRequest(ctx, api.httpclient, "groups.mark", values, api)
return err
}
@@ -304,7 +301,7 @@ func (api *Client) OpenGroupContext(ctx context.Context, group string) (bool, bo
"channel": {group},
}
- response, err := groupRequest(ctx, api.httpclient, "groups.open", values, api.debug)
+ response, err := groupRequest(ctx, api.httpclient, "groups.open", values, api)
if err != nil {
return false, false, err
}
@@ -328,7 +325,7 @@ func (api *Client) RenameGroupContext(ctx context.Context, group, name string) (
// XXX: the created entry in this call returns a string instead of a number
// so I may have to do some workaround to solve it.
- response, err := groupRequest(ctx, api.httpclient, "groups.rename", values, api.debug)
+ response, err := groupRequest(ctx, api.httpclient, "groups.rename", values, api)
if err != nil {
return nil, err
}
@@ -348,7 +345,7 @@ func (api *Client) SetGroupPurposeContext(ctx context.Context, group, purpose st
"purpose": {purpose},
}
- response, err := groupRequest(ctx, api.httpclient, "groups.setPurpose", values, api.debug)
+ response, err := groupRequest(ctx, api.httpclient, "groups.setPurpose", values, api)
if err != nil {
return "", err
}
@@ -368,7 +365,7 @@ func (api *Client) SetGroupTopicContext(ctx context.Context, group, topic string
"topic": {topic},
}
- response, err := groupRequest(ctx, api.httpclient, "groups.setTopic", values, api.debug)
+ response, err := groupRequest(ctx, api.httpclient, "groups.setTopic", values, api)
if err != nil {
return "", err
}