From 81c9c9b922aa2de7327d86f93565a4d0af575faf Mon Sep 17 00:00:00 2001 From: Ilia Uvarov Date: Thu, 11 May 2023 09:23:30 +0400 Subject: [PATCH] Update user.go add GetUserByuserName --- cloud/user.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cloud/user.go b/cloud/user.go index 3453a72e..5ce2fdb8 100644 --- a/cloud/user.go +++ b/cloud/user.go @@ -97,6 +97,21 @@ func (s *UserService) Get(ctx context.Context, accountId string) (*User, *Respon return user, resp, nil } +func (s *UserService) GetByUserName(ctx context.Context, username string) (*User, *Response, error) { + apiEndpoint := fmt.Sprintf("/rest/api/2/user?username=%s", username) + req, err := s.client.NewRequest(ctx, http.MethodGet, apiEndpoint, nil) + if err != nil { + return nil, nil, err + } + + user := new(User) + resp, err := s.client.Do(req, user) + if err != nil { + return nil, resp, NewJiraError(resp, err) + } + return user, resp, nil +} + // GetByAccountID gets user info from Jira // Searching by another parameter that is not accountId is deprecated, // but this method is kept for backwards compatibility