summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/slack-go/slack/usergroups.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/slack-go/slack/usergroups.go')
-rw-r--r--vendor/github.com/slack-go/slack/usergroups.go69
1 files changed, 57 insertions, 12 deletions
diff --git a/vendor/github.com/slack-go/slack/usergroups.go b/vendor/github.com/slack-go/slack/usergroups.go
index 9417f817..c5d7a176 100644
--- a/vendor/github.com/slack-go/slack/usergroups.go
+++ b/vendor/github.com/slack-go/slack/usergroups.go
@@ -183,32 +183,77 @@ func (api *Client) GetUserGroupsContext(ctx context.Context, options ...GetUserG
return response.UserGroups, nil
}
+// UpdateUserGroupsOption options for the UpdateUserGroup method call.
+type UpdateUserGroupsOption func(*UpdateUserGroupsParams)
+
+// UpdateUserGroupsOptionName change the name of the User Group (default: empty, so it's no-op)
+func UpdateUserGroupsOptionName(name string) UpdateUserGroupsOption {
+ return func(params *UpdateUserGroupsParams) {
+ params.Name = name
+ }
+}
+
+// UpdateUserGroupsOptionHandle change the handle of the User Group (default: empty, so it's no-op)
+func UpdateUserGroupsOptionHandle(handle string) UpdateUserGroupsOption {
+ return func(params *UpdateUserGroupsParams) {
+ params.Handle = handle
+ }
+}
+
+// UpdateUserGroupsOptionDescription change the description of the User Group. (default: nil, so it's no-op)
+func UpdateUserGroupsOptionDescription(description *string) UpdateUserGroupsOption {
+ return func(params *UpdateUserGroupsParams) {
+ params.Description = description
+ }
+}
+
+// UpdateUserGroupsOptionChannels change the default channels of the User Group. (default: unspecified, so it's no-op)
+func UpdateUserGroupsOptionChannels(channels []string) UpdateUserGroupsOption {
+ return func(params *UpdateUserGroupsParams) {
+ params.Channels = &channels
+ }
+}
+
+// UpdateUserGroupsParams contains arguments for UpdateUserGroup method call
+type UpdateUserGroupsParams struct {
+ Name string
+ Handle string
+ Description *string
+ Channels *[]string
+}
+
// UpdateUserGroup will update an existing user group
-func (api *Client) UpdateUserGroup(userGroup UserGroup) (UserGroup, error) {
- return api.UpdateUserGroupContext(context.Background(), userGroup)
+func (api *Client) UpdateUserGroup(userGroupID string, options ...UpdateUserGroupsOption) (UserGroup, error) {
+ return api.UpdateUserGroupContext(context.Background(), userGroupID, options...)
}
// UpdateUserGroupContext will update an existing user group with a custom context
-func (api *Client) UpdateUserGroupContext(ctx context.Context, userGroup UserGroup) (UserGroup, error) {
+func (api *Client) UpdateUserGroupContext(ctx context.Context, userGroupID string, options ...UpdateUserGroupsOption) (UserGroup, error) {
+ params := UpdateUserGroupsParams{}
+
+ for _, opt := range options {
+ opt(&params)
+ }
+
values := url.Values{
"token": {api.token},
- "usergroup": {userGroup.ID},
+ "usergroup": {userGroupID},
}
- if userGroup.Name != "" {
- values["name"] = []string{userGroup.Name}
+ if params.Name != "" {
+ values["name"] = []string{params.Name}
}
- if userGroup.Handle != "" {
- values["handle"] = []string{userGroup.Handle}
+ if params.Handle != "" {
+ values["handle"] = []string{params.Handle}
}
- if userGroup.Description != "" {
- values["description"] = []string{userGroup.Description}
+ if params.Description != nil {
+ values["description"] = []string{*params.Description}
}
- if len(userGroup.Prefs.Channels) > 0 {
- values["channels"] = []string{strings.Join(userGroup.Prefs.Channels, ",")}
+ if params.Channels != nil {
+ values["channels"] = []string{strings.Join(*params.Channels, ",")}
}
response, err := api.userGroupRequest(ctx, "usergroups.update", values)