Update vendor (slack)

This commit is contained in:
Wim
2017-01-28 00:36:22 +01:00
parent dcccd43427
commit 482fbac68f
8 changed files with 92 additions and 43 deletions

View File

@@ -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)
}