-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Change UpdateUserGroupMembers to accept slice of group members #1172
Copy link
Copy link
Open
Labels
Description
It's really inconvenient api to get members of the group
Lines 271 to 283 in 1edf0c7
| // 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
Lines 285 to 302 in 1edf0c7
| // 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 |
Reactions are currently unavailable