Skip to content

Commit

Permalink
Moved to use the new /api/admin/user/id/<user_ID> endpoint - availabl…
Browse files Browse the repository at this point in the history
…e in 1.0.184
  • Loading branch information
simonbronner committed Jul 21, 2021
1 parent aaab4ef commit 4bfea96
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions client/user.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package client

import (
"errors"
"fmt"
"log"
)
Expand Down Expand Up @@ -234,18 +233,27 @@ func (client *Client) GetAllUsers() (*[]User, error) {

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

users, err := client.GetAllUsers()
opts := RequestOptions{
Path: fmt.Sprintf("/admin/user/id/%s", userId),
Method: "GET",
}

resp, err := client.RequestAPI(&opts)

if err != nil {
return nil, err
}

for _, user := range *users {
if user.ID == userId {
return &user, nil
}
var user User

err = DecodeResponseInto(resp, &user)

if err != nil {
return nil, err
}

return nil, errors.New(fmt.Sprintf("[ERROR] User with ID %s wasn't found.", userId))
return &user, nil

}

func (client *Client) DeleteUser(userName string) error {
Expand Down

0 comments on commit 4bfea96

Please sign in to comment.