Skip to content

Commit

Permalink
Add migration exchange method (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
kelseymills authored Dec 12, 2023
1 parent d163ae9 commit f675880
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions migration.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit f675880

Please sign in to comment.