User returns a user for the ID/username provided.
(ctx context.Context, userIdent string)
| 983 | |
| 984 | // User returns a user for the ID/username provided. |
| 985 | func (c *Client) User(ctx context.Context, userIdent string) (User, error) { |
| 986 | res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/users/%s", userIdent), nil) |
| 987 | if err != nil { |
| 988 | return User{}, err |
| 989 | } |
| 990 | defer res.Body.Close() |
| 991 | if res.StatusCode != http.StatusOK { |
| 992 | return User{}, ReadBodyAsError(res) |
| 993 | } |
| 994 | var user User |
| 995 | return user, json.NewDecoder(res.Body).Decode(&user) |
| 996 | } |
| 997 | |
| 998 | // UserQuietHoursSchedule returns the quiet hours settings for the user. This |
| 999 | // endpoint only exists in enterprise editions. |