Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add migration exchange method #24

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading