Skip to content

Commit ca99739

Browse files
authored
feat: add API endpoint /migration.exchange to the library (#1453)
2 parents eef4b6c + 07331b5 commit ca99739

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

migration.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package slack
2+
3+
import (
4+
"context"
5+
"net/url"
6+
)
7+
8+
type migrationExchangeResponseFull struct {
9+
TeamID string `json:"team_id"`
10+
ToOld bool `json:"to_old"`
11+
EnterpriseID string `json:"enterprise_id"`
12+
UserIDMap map[string]string `json:"user_id_map"`
13+
InvalidUserIDs []string `json:"invalid_user_ids"`
14+
SlackResponse
15+
}
16+
17+
// MigrationExchange for Enterprise Grid workspaces, map local user IDs to global user IDs
18+
func (api *Client) MigrationExchange(ctx context.Context, teamID string, toOld bool, users []string) (map[string]string, []string, error) {
19+
values := url.Values{
20+
"users": users,
21+
}
22+
if teamID != "" {
23+
values.Add("team_id", teamID)
24+
}
25+
if toOld {
26+
values.Add("to_old", "true")
27+
}
28+
29+
response := &migrationExchangeResponseFull{}
30+
err := api.getMethod(ctx, "migration.exchange", api.token, values, response)
31+
if err != nil {
32+
return nil, nil, err
33+
}
34+
35+
if err := response.Err(); err != nil {
36+
return nil, nil, err
37+
}
38+
39+
return response.UserIDMap, response.InvalidUserIDs, nil
40+
}

0 commit comments

Comments
 (0)