File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change 1
1
package client
2
2
3
3
import (
4
- "errors"
4
+ // "errors"
5
5
"fmt"
6
6
"log"
7
7
)
@@ -234,18 +234,27 @@ func (client *Client) GetAllUsers() (*[]User, error) {
234
234
235
235
func (client * Client ) GetUserByID (userId string ) (* User , error ) {
236
236
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
+
238
244
if err != nil {
239
245
return nil , err
240
246
}
241
247
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
246
254
}
247
255
248
- return nil , errors .New (fmt .Sprintf ("[ERROR] User with ID %s wasn't found." , userId ))
256
+ return & user , nil
257
+
249
258
}
250
259
251
260
func (client * Client ) DeleteUser (userName string ) error {
You can’t perform that action at this time.
0 commit comments