summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/slack-go/slack/team.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/slack-go/slack/team.go')
-rw-r--r--vendor/github.com/slack-go/slack/team.go69
1 files changed, 69 insertions, 0 deletions
diff --git a/vendor/github.com/slack-go/slack/team.go b/vendor/github.com/slack-go/slack/team.go
index 029e2b5b..d21a1b64 100644
--- a/vendor/github.com/slack-go/slack/team.go
+++ b/vendor/github.com/slack-go/slack/team.go
@@ -24,6 +24,26 @@ type TeamInfo struct {
Icon map[string]interface{} `json:"icon"`
}
+type TeamProfileResponse struct {
+ Profile TeamProfile `json:"profile"`
+ SlackResponse
+}
+
+type TeamProfile struct {
+ Fields []TeamProfileField `json:"fields"`
+}
+
+type TeamProfileField struct {
+ ID string `json:"id"`
+ Ordering int `json:"ordering"`
+ Label string `json:"label"`
+ Hint string `json:"hint"`
+ Type string `json:"type"`
+ PossibleValues []string `json:"possible_values"`
+ IsHidden bool `json:"is_hidden"`
+ Options map[string]bool `json:"options"`
+}
+
type LoginResponse struct {
Logins []Login `json:"logins"`
Paging `json:"paging"`
@@ -95,11 +115,41 @@ func (api *Client) accessLogsRequest(ctx context.Context, path string, values ur
return response, response.Err()
}
+func (api *Client) teamProfileRequest(ctx context.Context, client httpClient, path string, values url.Values) (*TeamProfileResponse, error) {
+ response := &TeamProfileResponse{}
+ err := api.postMethod(ctx, path, values, response)
+ if err != nil {
+ return nil, err
+ }
+ return response, response.Err()
+}
+
// GetTeamInfo gets the Team Information of the user
func (api *Client) GetTeamInfo() (*TeamInfo, error) {
return api.GetTeamInfoContext(context.Background())
}
+// GetOtherTeamInfoContext gets Team information for any team with a custom context
+func (api *Client) GetOtherTeamInfoContext(ctx context.Context, team string) (*TeamInfo, error) {
+ if team == "" {
+ return api.GetTeamInfoContext(ctx)
+ }
+ values := url.Values{
+ "token": {api.token},
+ }
+ values.Add("team", team)
+ response, err := api.teamRequest(ctx, "team.info", values)
+ if err != nil {
+ return nil, err
+ }
+ return &response.Team, nil
+}
+
+// GetOtherTeamInfo gets Team information for any team
+func (api *Client) GetOtherTeamInfo(team string) (*TeamInfo, error) {
+ return api.GetOtherTeamInfoContext(context.Background(), team)
+}
+
// GetTeamInfoContext gets the Team Information of the user with a custom context
func (api *Client) GetTeamInfoContext(ctx context.Context) (*TeamInfo, error) {
values := url.Values{
@@ -113,6 +163,25 @@ func (api *Client) GetTeamInfoContext(ctx context.Context) (*TeamInfo, error) {
return &response.Team, nil
}
+// GetTeamProfile gets the Team Profile settings of the user
+func (api *Client) GetTeamProfile() (*TeamProfile, error) {
+ return api.GetTeamProfileContext(context.Background())
+}
+
+// GetTeamProfileContext gets the Team Profile settings of the user with a custom context
+func (api *Client) GetTeamProfileContext(ctx context.Context) (*TeamProfile, error) {
+ values := url.Values{
+ "token": {api.token},
+ }
+
+ response, err := api.teamProfileRequest(ctx, api.httpclient, "team.profile.get", values)
+ if err != nil {
+ return nil, err
+ }
+ return &response.Profile, nil
+
+}
+
// GetAccessLogs retrieves a page of logins according to the parameters given
func (api *Client) GetAccessLogs(params AccessLogParameters) ([]Login, *Paging, error) {
return api.GetAccessLogsContext(context.Background(), params)