-
Notifications
You must be signed in to change notification settings - Fork 42
/
user.go
35 lines (29 loc) · 922 Bytes
/
user.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package testrail
import "strconv"
// User represents a User
type User struct {
Email string `json:"email"`
ID int `json:"id"`
IsActive bool `json:"is_active"`
Name string `json:"name"`
}
// GetUser returns the user userID
func (c *Client) GetUser(userID int) (User, error) {
returnUser := User{}
err := c.sendRequest("GET", "get_user/"+strconv.Itoa(userID), nil, &returnUser)
return returnUser, err
}
// GetUserByEmail returns the user corresponding to email email
func (c *Client) GetUserByEmail(email string) (User, error) {
returnUser := User{}
err := c.sendRequest("GET", "get_user_by_email&email="+email, nil, &returnUser)
return returnUser, err
}
// GetUsers returns the list of users
func (c *Client) GetUsers() ([]User, error) {
returnUser := struct {
Users []User `json:"users"`
}{}
err := c.sendRequest("GET", "get_users", nil, &returnUser)
return returnUser.Users, err
}