From f675880d158386ab03a18926fafaea7d3dc4b80b Mon Sep 17 00:00:00 2001 From: Kelsey Mills <42537394+kelseymills@users.noreply.github.com> Date: Tue, 12 Dec 2023 14:22:49 +0000 Subject: [PATCH] Add migration exchange method (#24) --- migration.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 migration.go diff --git a/migration.go b/migration.go new file mode 100644 index 000000000..26ae6b2dc --- /dev/null +++ b/migration.go @@ -0,0 +1,35 @@ +package slack + +import ( + "context" + "net/url" +) + +type migrationExchangeResponseFull struct { + TeamID string `json:"team_id"` + EnterpriseID string `json:"enterprise_id"` + UserIDMap map[string]string `json:"user_id_map"` + InvalidUserIDs []string `json:"invalid_user_ids"` + SlackResponse +} + +// MigrationExchange for Enterprise Grid workspaces, map local user IDs to global user IDs +func (api *Client) MigrationExchange(ctx context.Context, teamID string, users []string) (map[string]string, error) { + values := url.Values{ + "users": users, + } + if teamID != "" { + values.Add("team_id", teamID) + } + response := &migrationExchangeResponseFull{} + err := api.getMethod(ctx, "migration.exchange", api.token, values, response) + if err != nil { + return nil, err + } + + if err := response.Err(); err != nil { + return nil, err + } + + return response.UserIDMap, nil +}