diff options
author | Patrick Connolly <patrick.c.connolly@gmail.com> | 2018-12-02 02:55:35 +0800 |
---|---|---|
committer | Wim <wim@42.be> | 2018-12-01 19:55:35 +0100 |
commit | e538a4d30459e9da1a021400b5de85894b4efabc (patch) | |
tree | ead4f82d5459fe0d3465f7e3656243cd613c07a6 /vendor/github.com/nlopes/slack/users.go | |
parent | f94c2b40a3e8eb45054bda1b71eb6fd3f9bc9e6d (diff) | |
download | matterbridge-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/users.go')
-rw-r--r-- | vendor/github.com/nlopes/slack/users.go | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/vendor/github.com/nlopes/slack/users.go b/vendor/github.com/nlopes/slack/users.go index 0dd20db5..aa941a74 100644 --- a/vendor/github.com/nlopes/slack/users.go +++ b/vendor/github.com/nlopes/slack/users.go @@ -189,16 +189,14 @@ func NewUserSetPhotoParams() UserSetPhotoParams { } } -func userRequest(ctx context.Context, client HTTPRequester, path string, values url.Values, debug bool) (*userResponseFull, error) { +func userRequest(ctx context.Context, client httpClient, path string, values url.Values, d debug) (*userResponseFull, error) { response := &userResponseFull{} - 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() } // GetUserPresence will retrieve the current presence status of given user. @@ -213,7 +211,7 @@ func (api *Client) GetUserPresenceContext(ctx context.Context, user string) (*Us "user": {user}, } - response, err := userRequest(ctx, api.httpclient, "users.getPresence", values, api.debug) + response, err := userRequest(ctx, api.httpclient, "users.getPresence", values, api) if err != nil { return nil, err } @@ -232,7 +230,7 @@ func (api *Client) GetUserInfoContext(ctx context.Context, user string) (*User, "user": {user}, } - response, err := userRequest(ctx, api.httpclient, "users.info", values, api.debug) + response, err := userRequest(ctx, api.httpclient, "users.info", values, api) if err != nil { return nil, err } @@ -310,7 +308,7 @@ func (t UserPagination) Next(ctx context.Context) (_ UserPagination, err error) "cursor": {t.previousResp.Cursor}, } - if resp, err = userRequest(ctx, t.c.httpclient, "users.list", values, t.c.debug); err != nil { + if resp, err = userRequest(ctx, t.c.httpclient, "users.list", values, t.c); err != nil { return t, err } @@ -355,7 +353,7 @@ func (api *Client) GetUserByEmailContext(ctx context.Context, email string) (*Us "token": {api.token}, "email": {email}, } - response, err := userRequest(ctx, api.httpclient, "users.lookupByEmail", values, api.debug) + response, err := userRequest(ctx, api.httpclient, "users.lookupByEmail", values, api) if err != nil { return nil, err } @@ -373,7 +371,7 @@ func (api *Client) SetUserAsActiveContext(ctx context.Context) (err error) { "token": {api.token}, } - _, err = userRequest(ctx, api.httpclient, "users.setActive", values, api.debug) + _, err = userRequest(ctx, api.httpclient, "users.setActive", values, api) return err } @@ -389,7 +387,7 @@ func (api *Client) SetUserPresenceContext(ctx context.Context, presence string) "presence": {presence}, } - _, err := userRequest(ctx, api.httpclient, "users.setPresence", values, api.debug) + _, err := userRequest(ctx, api.httpclient, "users.setPresence", values, api) return err } @@ -405,7 +403,7 @@ func (api *Client) GetUserIdentityContext(ctx context.Context) (*UserIdentityRes } response := &UserIdentityResponse{} - err := postForm(ctx, api.httpclient, SLACK_API+"users.identity", values, response, api.debug) + err := postForm(ctx, api.httpclient, APIURL+"users.identity", values, response, api) if err != nil { return nil, err } @@ -436,7 +434,7 @@ func (api *Client) SetUserPhotoContext(ctx context.Context, image string, params values.Add("crop_w", strconv.Itoa(params.CropW)) } - err := postLocalWithMultipartResponse(ctx, api.httpclient, "users.setPhoto", image, "image", values, response, api.debug) + err := postLocalWithMultipartResponse(ctx, api.httpclient, "users.setPhoto", image, "image", values, response, api) if err != nil { return err } @@ -456,7 +454,7 @@ func (api *Client) DeleteUserPhotoContext(ctx context.Context) error { "token": {api.token}, } - err := postForm(ctx, api.httpclient, SLACK_API+"users.deletePhoto", values, response, api.debug) + err := postForm(ctx, api.httpclient, APIURL+"users.deletePhoto", values, response, api) if err != nil { return err } @@ -506,7 +504,7 @@ func (api *Client) SetUserCustomStatusContext(ctx context.Context, statusText, s } response := &userResponseFull{} - if err = postForm(ctx, api.httpclient, SLACK_API+"users.profile.set", values, response, api.debug); err != nil { + if err = postForm(ctx, api.httpclient, APIURL+"users.profile.set", values, response, api); err != nil { return err } @@ -547,7 +545,7 @@ func (api *Client) GetUserProfileContext(ctx context.Context, userID string, inc } resp := &getUserProfileResponse{} - err := postSlackMethod(ctx, api.httpclient, "users.profile.get", values, &resp, api.debug) + err := postSlackMethod(ctx, api.httpclient, "users.profile.get", values, &resp, api) if err != nil { return nil, err } |