It's really inconvenient api to get members of the group
|
// GetUserGroupMembersContext will retrieve the current list of users in a group with a custom context |
|
func (api *Client) GetUserGroupMembersContext(ctx context.Context, userGroup string) ([]string, error) { |
|
values := url.Values{ |
|
"token": {api.token}, |
|
"usergroup": {userGroup}, |
|
} |
|
|
|
response, err := api.userGroupRequest(ctx, "usergroups.users.list", values) |
|
if err != nil { |
|
return []string{}, err |
|
} |
|
return response.Users, nil |
|
} |
And then if I need to perform an update - I need to do extra things
|
// UpdateUserGroupMembers will update the members of an existing user group |
|
func (api *Client) UpdateUserGroupMembers(userGroup string, members string) (UserGroup, error) { |
|
return api.UpdateUserGroupMembersContext(context.Background(), userGroup, members) |
|
} |
|
|
|
// UpdateUserGroupMembersContext will update the members of an existing user group with a custom context |
|
func (api *Client) UpdateUserGroupMembersContext(ctx context.Context, userGroup string, members string) (UserGroup, error) { |
|
values := url.Values{ |
|
"token": {api.token}, |
|
"usergroup": {userGroup}, |
|
"users": {members}, |
|
} |
|
|
|
response, err := api.userGroupRequest(ctx, "usergroups.users.update", values) |
|
if err != nil { |
|
return UserGroup{}, err |
|
} |
|
return response.UserGroup, nil |