Codebase list golang-github-nlopes-slack / 4e50509
Add Client.GetUserByEmail method https://api.slack.com/methods/users.lookupByEmail Suzuki Shunsuke 6 years ago
1 changed file(s) with 18 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
186186 return nil, err
187187 }
188188 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
189207 }
190208
191209 // SetUserAsActive marks the currently authenticated user as active