forked from slack-go/slack
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadmin_conversations.go
More file actions
85 lines (71 loc) · 2.5 KB
/
admin_conversations.go
File metadata and controls
85 lines (71 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package slack
import (
"context"
"net/url"
"strconv"
"strings"
)
// AdminConversationsSetTeamsParams contains arguments for AdminConversationsSetTeams
// method calls.
type AdminConversationsSetTeamsParams struct {
ChannelID string
OrgChannel *bool
TargetTeamIDs []string
TeamID *string
}
// Set the workspaces in an Enterprise Grid organisation that connect to a public or
// private channel.
// See: https://api.slack.com/methods/admin.conversations.setTeams
func (api *Client) AdminConversationsSetTeams(ctx context.Context, params AdminConversationsSetTeamsParams) error {
values := url.Values{
"token": {api.token},
"channel_id": {params.ChannelID},
}
if params.OrgChannel != nil {
values.Add("org_channel", strconv.FormatBool(*params.OrgChannel))
}
if len(params.TargetTeamIDs) > 0 {
values.Add("target_team_ids", strings.Join(params.TargetTeamIDs, ",")) // ["T123", "T456"] - > "T123,T456"
}
if params.TeamID != nil {
values.Add("team_id", *params.TeamID)
}
response := &SlackResponse{}
err := api.postMethod(ctx, "admin.conversations.setTeams", values, response)
if err != nil {
return err
}
return response.Err()
}
// ConversationsConvertToPrivate converts a public channel to a private channel. To do
// this, you must have the admin.conversations:write scope. There are other requirements:
// you should read the Slack documentation for more details.
// See: https://api.slack.com/methods/admin.conversations.convertToPrivate
func (api *Client) AdminConversationsConvertToPrivate(ctx context.Context, channelID string) error {
values := url.Values{
"token": []string{api.token},
"channel_id": []string{channelID},
}
response := &SlackResponse{}
err := api.postMethod(ctx, "admin.conversations.convertToPrivate", values, response)
if err != nil {
return err
}
return response.Err()
}
// ConversationsConvertToPublic converts a private channel to a public channel. To do
// this, you must have the admin.conversations:write scope. There are other requirements:
// you should read the Slack documentation for more details.
// See: https://api.slack.com/methods/admin.conversations.convertToPublic
func (api *Client) AdminConversationsConvertToPublic(ctx context.Context, channelID string) error {
values := url.Values{
"token": []string{api.token},
"channel_id": []string{channelID},
}
response := &SlackResponse{}
err := api.postMethod(ctx, "admin.conversations.convertToPublic", values, response)
if err != nil {
return err
}
return response.Err()
}