summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nlopes/slack/team.go
diff options
context:
space:
mode:
authorPatrick Connolly <patrick.c.connolly@gmail.com>2018-12-02 02:55:35 +0800
committerWim <wim@42.be>2018-12-01 19:55:35 +0100
commite538a4d30459e9da1a021400b5de85894b4efabc (patch)
treeead4f82d5459fe0d3465f7e3656243cd613c07a6 /vendor/github.com/nlopes/slack/team.go
parentf94c2b40a3e8eb45054bda1b71eb6fd3f9bc9e6d (diff)
downloadmatterbridge-msglm-e538a4d30459e9da1a021400b5de85894b4efabc.tar.gz
matterbridge-msglm-e538a4d30459e9da1a021400b5de85894b4efabc.tar.bz2
matterbridge-msglm-e538a4d30459e9da1a021400b5de85894b4efabc.zip
Update nlopes/slack to 4.1-dev (#595)
Diffstat (limited to 'vendor/github.com/nlopes/slack/team.go')
-rw-r--r--vendor/github.com/nlopes/slack/team.go38
1 files changed, 13 insertions, 25 deletions
diff --git a/vendor/github.com/nlopes/slack/team.go b/vendor/github.com/nlopes/slack/team.go
index b6e341eb..1892cf5f 100644
--- a/vendor/github.com/nlopes/slack/team.go
+++ b/vendor/github.com/nlopes/slack/team.go
@@ -2,7 +2,6 @@ package slack
import (
"context"
- "errors"
"net/url"
"strconv"
)
@@ -67,44 +66,33 @@ func NewAccessLogParameters() AccessLogParameters {
}
}
-func teamRequest(ctx context.Context, client HTTPRequester, path string, values url.Values, debug bool) (*TeamResponse, error) {
+func teamRequest(ctx context.Context, client httpClient, path string, values url.Values, d debug) (*TeamResponse, error) {
response := &TeamResponse{}
- err := postSlackMethod(ctx, client, path, values, response, debug)
+ err := postSlackMethod(ctx, client, 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()
}
-func billableInfoRequest(ctx context.Context, client HTTPRequester, path string, values url.Values, debug bool) (map[string]BillingActive, error) {
+func billableInfoRequest(ctx context.Context, client httpClient, path string, values url.Values, d debug) (map[string]BillingActive, error) {
response := &BillableInfoResponse{}
- err := postSlackMethod(ctx, client, path, values, response, debug)
+ err := postSlackMethod(ctx, client, path, values, response, d)
if err != nil {
return nil, err
}
- if !response.Ok {
- return nil, errors.New(response.Error)
- }
-
- return response.BillableInfo, nil
+ return response.BillableInfo, response.Err()
}
-func accessLogsRequest(ctx context.Context, client HTTPRequester, path string, values url.Values, debug bool) (*LoginResponse, error) {
+func accessLogsRequest(ctx context.Context, client httpClient, path string, values url.Values, d debug) (*LoginResponse, error) {
response := &LoginResponse{}
- err := postSlackMethod(ctx, client, path, values, response, debug)
+ err := postSlackMethod(ctx, client, 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()
}
// GetTeamInfo gets the Team Information of the user
@@ -118,7 +106,7 @@ func (api *Client) GetTeamInfoContext(ctx context.Context) (*TeamInfo, error) {
"token": {api.token},
}
- response, err := teamRequest(ctx, api.httpclient, "team.info", values, api.debug)
+ response, err := teamRequest(ctx, api.httpclient, "team.info", values, api)
if err != nil {
return nil, err
}
@@ -142,7 +130,7 @@ func (api *Client) GetAccessLogsContext(ctx context.Context, params AccessLogPar
values.Add("page", strconv.Itoa(params.Page))
}
- response, err := accessLogsRequest(ctx, api.httpclient, "team.accessLogs", values, api.debug)
+ response, err := accessLogsRequest(ctx, api.httpclient, "team.accessLogs", values, api)
if err != nil {
return nil, nil, err
}
@@ -159,7 +147,7 @@ func (api *Client) GetBillableInfoContext(ctx context.Context, user string) (map
"user": {user},
}
- return billableInfoRequest(ctx, api.httpclient, "team.billableInfo", values, api.debug)
+ return billableInfoRequest(ctx, api.httpclient, "team.billableInfo", values, api)
}
// GetBillableInfoForTeam returns the billing_active status of all users on the team.
@@ -173,5 +161,5 @@ func (api *Client) GetBillableInfoForTeamContext(ctx context.Context) (map[strin
"token": {api.token},
}
- return billableInfoRequest(ctx, api.httpclient, "team.billableInfo", values, api.debug)
+ return billableInfoRequest(ctx, api.httpclient, "team.billableInfo", values, api)
}