Update nlopes/slack to 4.1-dev (#595)

This commit is contained in:
Patrick Connolly
2018-12-02 02:55:35 +08:00
committed by Wim
parent f94c2b40a3
commit e538a4d304
37 changed files with 694 additions and 534 deletions

View File

@@ -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)
}