Add Client.GetUserByEmail method
https://api.slack.com/methods/users.lookupByEmail
Suzuki Shunsuke
6 years ago
186 | 186 | return nil, err |
187 | 187 | } |
188 | 188 | return response.Members, nil |
189 | } | |
190 | ||
191 | // GetUserByEmail will retrieve the complete user information by email | |
192 | func (api *Client) GetUserByEmail(email string) (*User, error) { | |
193 | return api.GetUserByEmailContext(context.Background(), email) | |
194 | } | |
195 | ||
196 | // GetUserByEmailContext will retrieve the complete user information by email with a custom context | |
197 | func (api *Client) GetUserByEmailContext(ctx context.Context, email string) (*User, error) { | |
198 | values := url.Values{ | |
199 | "token": {api.config.token}, | |
200 | "email": {email}, | |
201 | } | |
202 | response, err := userRequest(ctx, "users.lookupByEmail", values, api.debug) | |
203 | if err != nil { | |
204 | return nil, err | |
205 | } | |
206 | return &response.User, nil | |
189 | 207 | } |
190 | 208 | |
191 | 209 | // SetUserAsActive marks the currently authenticated user as active |