File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 11package client
22
33import (
4- "errors"
54 "fmt"
65 "log"
76)
@@ -234,18 +233,27 @@ func (client *Client) GetAllUsers() (*[]User, error) {
234233
235234func (client * Client ) GetUserByID (userId string ) (* User , error ) {
236235
237- users , err := client .GetAllUsers ()
236+ opts := RequestOptions {
237+ Path : fmt .Sprintf ("/admin/user/id/%s" , userId ),
238+ Method : "GET" ,
239+ }
240+
241+ resp , err := client .RequestAPI (& opts )
242+
238243 if err != nil {
239244 return nil , err
240245 }
241246
242- for _ , user := range * users {
243- if user .ID == userId {
244- return & user , nil
245- }
247+ var user User
248+
249+ err = DecodeResponseInto (resp , & user )
250+
251+ if err != nil {
252+ return nil , err
246253 }
247254
248- return nil , errors .New (fmt .Sprintf ("[ERROR] User with ID %s wasn't found." , userId ))
255+ return & user , nil
256+
249257}
250258
251259func (client * Client ) DeleteUser (userName string ) error {
You can’t perform that action at this time.
0 commit comments