You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-itg/itglue/user-metrics.go

49 lines
1.3 KiB

package itglue
import (
"encoding/json"
"fmt"
)
type UserMetricData struct {
ID string `json:"id"`
Type string `json:"type"`
Attributes struct {
UserID int `json:"user-id"`
OrganizationID int `json:"organization-id"`
Created int `json:"created"`
Viewed int `json:"viewed"`
Edited int `json:"edited"`
Deleted int `json:"deleted"`
Date string `json:"date"`
ResourceType string `json:"resource-type"`
} `json:"attributes"`
}
type UserMetric struct {
Data struct{ UserMetricData } `json:"data"`
Meta struct{ Metadata } `json:"metadata"`
Links struct{ Links } `json:"links"`
}
type UserMetricList struct {
Data []struct{ UserMetricData } `json:"data"`
Meta struct{ Metadata } `json:"metadata"`
Links struct{ Links } `json:"links"`
}
func (itg *ITGAPI) GetUserMetrics() (*UserMetricList, error) {
req := itg.NewRequest("/user_metrics", "GET", nil)
err := req.Do()
if err != nil {
return nil, fmt.Errorf("request failed for %s: %s", req.RestAction, err)
}
userMetrics := &UserMetricList{}
err = json.Unmarshal(req.Body, userMetrics)
if err != nil {
return nil, fmt.Errorf("could not get users: %s", err)
}
return userMetrics, nil
}