diff options
Diffstat (limited to 'vendor/github.com/nlopes/slack/team.go')
-rw-r--r-- | vendor/github.com/nlopes/slack/team.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/vendor/github.com/nlopes/slack/team.go b/vendor/github.com/nlopes/slack/team.go index d4e7899f..61b6a0a1 100644 --- a/vendor/github.com/nlopes/slack/team.go +++ b/vendor/github.com/nlopes/slack/team.go @@ -44,6 +44,16 @@ type Login struct { Region string `json:"region"` } +type BillableInfoResponse struct { + BillableInfo map[string]BillingActive `json:"billable_info"` + SlackResponse + +} + +type BillingActive struct { + BillingActive bool `json:"billing_active"` +} + // AccessLogParameters contains all the parameters necessary (including the optional ones) for a GetAccessLogs() request type AccessLogParameters struct { Count int @@ -73,6 +83,20 @@ func teamRequest(path string, values url.Values, debug bool) (*TeamResponse, err return response, nil } +func billableInfoRequest(path string, values url.Values, debug bool) (map[string]BillingActive, error) { + response := &BillableInfoResponse{} + err := post(path, values, response, debug) + if err != nil { + return nil, err + } + + if !response.Ok { + return nil, errors.New(response.Error) + } + + return response.BillableInfo, nil +} + func accessLogsRequest(path string, values url.Values, debug bool) (*LoginResponse, error) { response := &LoginResponse{} err := post(path, values, response, debug) @@ -117,3 +141,20 @@ func (api *Client) GetAccessLogs(params AccessLogParameters) ([]Login, *Paging, return response.Logins, &response.Paging, nil } +func (api *Client) GetBillableInfo(user string) (map[string]BillingActive, error) { + values := url.Values{ + "token": {api.config.token}, + "user": {user}, + } + + return billableInfoRequest("team.billableInfo", values, api.debug) +} + +// GetBillableInfoForTeam returns the billing_active status of all users on the team. +func (api *Client) GetBillableInfoForTeam() (map[string]BillingActive, error) { + values := url.Values{ + "token": {api.config.token}, + } + + return billableInfoRequest("team.billableInfo", values, api.debug) +} |