summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nlopes/slack/usergroups.go
diff options
context:
space:
mode:
authorDuco van Amstel <duco.vanamstel@gmail.com>2018-10-07 22:17:46 +0100
committerWim <wim@42.be>2018-10-07 23:17:46 +0200
commit917040b044e349eadc886f9685ada30d164687eb (patch)
treeea063d87a415f89060b376f29a844e4d1ed86363 /vendor/github.com/nlopes/slack/usergroups.go
parent69646a160d8597944c307334901f0acfd32582c5 (diff)
downloadmatterbridge-msglm-917040b044e349eadc886f9685ada30d164687eb.tar.gz
matterbridge-msglm-917040b044e349eadc886f9685ada30d164687eb.tar.bz2
matterbridge-msglm-917040b044e349eadc886f9685ada30d164687eb.zip
Update of nlopes/slack dependency (#511)
Diffstat (limited to 'vendor/github.com/nlopes/slack/usergroups.go')
-rw-r--r--vendor/github.com/nlopes/slack/usergroups.go53
1 files changed, 50 insertions, 3 deletions
diff --git a/vendor/github.com/nlopes/slack/usergroups.go b/vendor/github.com/nlopes/slack/usergroups.go
index 1e2b6442..cc9bc4ca 100644
--- a/vendor/github.com/nlopes/slack/usergroups.go
+++ b/vendor/github.com/nlopes/slack/usergroups.go
@@ -25,6 +25,7 @@ type UserGroup struct {
DeletedBy string `json:"deleted_by"`
Prefs UserGroupPrefs `json:"prefs"`
UserCount int `json:"user_count"`
+ Users []string `json:"users"`
}
// UserGroupPrefs contains default channels and groups (private channels)
@@ -121,16 +122,62 @@ func (api *Client) EnableUserGroupContext(ctx context.Context, userGroup string)
return response.UserGroup, nil
}
+// GetUserGroupsOption options for the GetUserGroups method call.
+type GetUserGroupsOption func(*GetUserGroupsParams)
+
+// GetUserGroupsOptionIncludeCount include the number of users in each User Group (default: false)
+func GetUserGroupsOptionIncludeCount(b bool) GetUserGroupsOption {
+ return func(params *GetUserGroupsParams) {
+ params.IncludeCount = b
+ }
+}
+
+// GetUserGroupsOptionIncludeDisabled include disabled User Groups (default: false)
+func GetUserGroupsOptionIncludeDisabled(b bool) GetUserGroupsOption {
+ return func(params *GetUserGroupsParams) {
+ params.IncludeDisabled = b
+ }
+}
+
+// GetUserGroupsOptionIncludeUsers include the list of users for each User Group (default: false)
+func GetUserGroupsOptionIncludeUsers(b bool) GetUserGroupsOption {
+ return func(params *GetUserGroupsParams) {
+ params.IncludeUsers = b
+ }
+}
+
+// GetUserGroupsParams contains arguments for GetUserGroups method call
+type GetUserGroupsParams struct {
+ IncludeCount bool
+ IncludeDisabled bool
+ IncludeUsers bool
+}
+
// GetUserGroups returns a list of user groups for the team
-func (api *Client) GetUserGroups() ([]UserGroup, error) {
- return api.GetUserGroupsContext(context.Background())
+func (api *Client) GetUserGroups(options ...GetUserGroupsOption) ([]UserGroup, error) {
+ return api.GetUserGroupsContext(context.Background(), options...)
}
// GetUserGroupsContext returns a list of user groups for the team with a custom context
-func (api *Client) GetUserGroupsContext(ctx context.Context) ([]UserGroup, error) {
+func (api *Client) GetUserGroupsContext(ctx context.Context, options ...GetUserGroupsOption) ([]UserGroup, error) {
+ params := GetUserGroupsParams{}
+
+ for _, opt := range options {
+ opt(&params)
+ }
+
values := url.Values{
"token": {api.token},
}
+ if params.IncludeCount {
+ values.Add("include_count", "true")
+ }
+ if params.IncludeDisabled {
+ values.Add("include_disabled", "true")
+ }
+ if params.IncludeUsers {
+ values.Add("include_users", "true")
+ }
response, err := userGroupRequest(ctx, api.httpclient, "usergroups.list", values, api.debug)
if err != nil {