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