Skip to content

Commit 24ad097

Browse files
committed
Moved to use the new /api/admin/user/id/<user_ID> endpoint - available in 1.0.184
1 parent aaab4ef commit 24ad097

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

client/user.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package client
22

33
import (
4-
"errors"
4+
//"errors"
55
"fmt"
66
"log"
77
)
@@ -234,18 +234,27 @@ func (client *Client) GetAllUsers() (*[]User, error) {
234234

235235
func (client *Client) GetUserByID(userId string) (*User, error) {
236236

237-
users, err := client.GetAllUsers()
237+
opts := RequestOptions{
238+
Path: fmt.Sprintf("/admin/user/id/%s", userId),
239+
Method: "GET",
240+
}
241+
242+
resp, err := client.RequestAPI(&opts)
243+
238244
if err != nil {
239245
return nil, err
240246
}
241247

242-
for _, user := range *users {
243-
if user.ID == userId {
244-
return &user, nil
245-
}
248+
var user User
249+
250+
err = DecodeResponseInto(resp, &user)
251+
252+
if err != nil {
253+
return nil, err
246254
}
247255

248-
return nil, errors.New(fmt.Sprintf("[ERROR] User with ID %s wasn't found.", userId))
256+
return &user, nil
257+
249258
}
250259

251260
func (client *Client) DeleteUser(userName string) error {

0 commit comments

Comments
 (0)