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/auth.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/auth.go')
-rw-r--r-- | vendor/github.com/nlopes/slack/auth.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/vendor/github.com/nlopes/slack/auth.go b/vendor/github.com/nlopes/slack/auth.go new file mode 100644 index 00000000..f8fe1f9d --- /dev/null +++ b/vendor/github.com/nlopes/slack/auth.go @@ -0,0 +1,40 @@ +package slack + +import ( + "context" + "net/url" +) + +// AuthRevokeResponse contains our Auth response from the auth.revoke endpoint +type AuthRevokeResponse struct { + SlackResponse // Contains the "ok", and "Error", if any + Revoked bool `json:"revoked,omitempty"` +} + +// authRequest sends the actual request, and unmarshals the response +func authRequest(ctx context.Context, client httpClient, path string, values url.Values, d debug) (*AuthRevokeResponse, error) { + response := &AuthRevokeResponse{} + err := postSlackMethod(ctx, client, path, values, response, d) + if err != nil { + return nil, err + } + + return response, response.Err() +} + +// SendAuthRevoke will send a revocation for our token +func (api *Client) SendAuthRevoke(token string) (*AuthRevokeResponse, error) { + return api.SendAuthRevokeContext(context.Background(), token) +} + +// SendAuthRevokeContext will retrieve the satus from api.test +func (api *Client) SendAuthRevokeContext(ctx context.Context, token string) (*AuthRevokeResponse, error) { + if token == "" { + token = api.token + } + values := url.Values{ + "token": {token}, + } + + return authRequest(ctx, api.httpclient, "auth.revoke", values, api) +} |