package moderation import ( "context" "encoding/json" "fmt" "net/http" "net/url" "github.com/google/go-querystring/query" "go.fifitido.net/twitch/api/types" ) type GetVIPsParams struct { // Filters the list for specific VIPs. // To specify more than one user, include the user_id parameter for each user to get. For example, &user_id=1234&user_id=5678. // The maximum number of IDs that you may specify is 100. // Ignores the ID of those users in the list that aren’t VIPs. UserIDs []string `url:"user_id,omitempty"` // The ID of the broadcaster whose list of VIPs you want to get. This ID must match the user ID in the access token. BroadcasterID string `url:"broadcaster_id"` // The maximum number of items to return per page in the response. // The minimum page size is 1 item per page and the maximum is 100 items per page. // The default is 20. First *int `url:"first,omitempty"` // The cursor used to get the next page of results. // The Pagination object in the response contains the cursor’s value. // Read More: https://dev.twitch.tv/docs/api/guide#pagination After *types.Cursor `url:"after,omitempty"` } type GetVIPsResponse struct { // The list of VIPs. The list contains a single object that contains all the VIPs. Data []GetVIPsResponseData `json:"data"` // Contains information about the pagination in the response. // The object is empty if there are no more pages of results. // Read More: https://dev.twitch.tv/docs/api/guide#pagination Pagination types.Pagination `json:"pagination"` } type GetVIPsResponseData struct { // An ID that uniquely identifies the VIP user. UserID string `json:"user_id"` // The user’s display name. UserName string `json:"user_name"` // The user’s login name. UserLogin string `json:"user_login"` } // Gets a list of the broadcaster’s VIPs. // // Requires a user access token that includes the channel:read:vips scope. // If your app also adds and removes VIP status, you can use the channel:manage:vips scope instead. func (m *Moderation) GetVIPs(ctx context.Context, params GetVIPsParams) (*GetVIPsResponse, error) { v, _ := query.Values(params) endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/vips", RawQuery: v.Encode()}) req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil) if err != nil { return nil, err } res, err := m.client.Do(req) if err != nil { return nil, err } defer res.Body.Close() statusOK := res.StatusCode >= 200 && res.StatusCode < 300 if !statusOK { return nil, fmt.Errorf("failed to get VIPs (%d)", res.StatusCode) } var data GetVIPsResponse if err := json.NewDecoder(res.Body).Decode(&data); err != nil { return nil, err } return &data, nil }