45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
|
package channels
|
|||
|
|
|||
|
import (
|
|||
|
"encoding/json"
|
|||
|
"net/url"
|
|||
|
"time"
|
|||
|
)
|
|||
|
|
|||
|
type GetChannelEditorsResponse struct {
|
|||
|
// A list of users that are editors for the specified broadcaster. The list is empty if the broadcaster doesn’t have editors.
|
|||
|
Data []ChannelEditor `json:"data"`
|
|||
|
}
|
|||
|
|
|||
|
type ChannelEditor struct {
|
|||
|
// An ID that uniquely identifies a user with editor permissions.
|
|||
|
UserID string `json:"user_id"`
|
|||
|
|
|||
|
// The user’s display name.
|
|||
|
UserName string `json:"user_name"`
|
|||
|
|
|||
|
// The date and time, in RFC3339 format, when the user became one of the broadcaster’s editors.
|
|||
|
CreatedAt time.Time `json:"created_at"`
|
|||
|
}
|
|||
|
|
|||
|
// Gets the broadcaster’s list editors.
|
|||
|
//
|
|||
|
// Requires a user access token that includes the channel:read:editors scope.
|
|||
|
func (c *Channels) GetChannelEditors(broadcasterID string) (*GetChannelEditorsResponse, error) {
|
|||
|
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "channels/editors", RawQuery: "broadcaster_id=" + broadcasterID})
|
|||
|
|
|||
|
resp, err := c.client.Get(endpoint.String())
|
|||
|
if err != nil {
|
|||
|
return nil, err
|
|||
|
}
|
|||
|
|
|||
|
defer resp.Body.Close()
|
|||
|
|
|||
|
var data GetChannelEditorsResponse
|
|||
|
if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
|
|||
|
return nil, err
|
|||
|
}
|
|||
|
|
|||
|
return &data, nil
|
|||
|
}
|