mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-09-16 09:06:19 +02:00
Merge branch 'master' of https://github.com/manute/go-jira into manute-master
* 'master' of https://github.com/manute/go-jira: finding users by email, username or name
This commit is contained in:
19
user.go
19
user.go
@@ -96,3 +96,22 @@ func (s *UserService) GetGroups(username string) (*[]UserGroup, *Response, error
|
||||
}
|
||||
return userGroups, resp, nil
|
||||
}
|
||||
|
||||
// Finds user info from JIRA:
|
||||
// It can find users by email, username or name
|
||||
//
|
||||
// JIRA API docs: https://docs.atlassian.com/jira/REST/cloud/#api/2/user-findUsers
|
||||
func (s *UserService) Find(property string) ([]User, *Response, error) {
|
||||
apiEndpoint := fmt.Sprintf("/rest/api/2/user/search?username=%s", property)
|
||||
req, err := s.client.NewRequest("GET", apiEndpoint, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
users := []User{}
|
||||
resp, err := s.client.Do(req, &users)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
return users, resp, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user