76 lines
2.9 KiB
Go
76 lines
2.9 KiB
Go
package channels
|
||
|
||
import (
|
||
"encoding/json"
|
||
"io"
|
||
"net/http"
|
||
"net/url"
|
||
|
||
"go.fifitido.net/twitch/api/types"
|
||
)
|
||
|
||
type ModifyChannelInformationRequest struct {
|
||
// The ID of the game that the user plays. The game is not updated if the ID isn’t a game ID that Twitch recognizes.
|
||
// To unset this field, use “0” or “” (an empty string).
|
||
GameID *string `json:"game_id,omitempty"`
|
||
|
||
// The user’s preferred language. Set the value to an ISO 639-1 two-letter language code (for example, en for English).
|
||
// Set to “other” if the user’s preferred language is not a Twitch supported language.
|
||
// The language isn’t updated if the language code isn’t a Twitch supported language.
|
||
Language *string `json:"language,omitempty"`
|
||
|
||
// The title of the user’s stream. You may not set this field to an empty string.
|
||
Title *string `json:"title,omitempty"`
|
||
|
||
// The number of seconds you want your broadcast buffered before streaming it live. The delay helps ensure fairness during competitive play.
|
||
// Only users with Partner status may set this field. The maximum delay is 900 seconds (15 minutes).
|
||
Delay *int `json:"delay,omitempty"`
|
||
|
||
// A list of channel-defined tags to apply to the channel. To remove all tags from the channel, set tags to an empty array.
|
||
// Tags help identify the content that the channel streams. Learn More: https://help.twitch.tv/s/article/guide-to-tags
|
||
//
|
||
// A channel may specify a maximum of 10 tags.
|
||
// Each tag is limited to a maximum of 25 characters and may not be an empty string or contain spaces or special characters.
|
||
// Tags are case insensitive. For readability, consider using camelCasing or PascalCasing.
|
||
Tags *[]string `json:"tags,omitempty"`
|
||
|
||
// List of labels that should be set as the Channel’s CCLs.
|
||
ContentClassificationLabels []ModifyContentClassificationLabel `json:"content_classification_labels,omitempty"`
|
||
|
||
// Boolean flag indicating if the channel has branded content.
|
||
IsBrandedContent *bool `json:"is_branded_content,omitempty"`
|
||
}
|
||
|
||
type ModifyContentClassificationLabel struct {
|
||
// ID of the Content Classification Labels that must be added/removed from the channel.
|
||
ID types.CCL `json:"id"`
|
||
|
||
// Boolean flag indicating whether the label should be enabled (true) or disabled for the channel.
|
||
IsEnabled bool `json:"is_enabled"`
|
||
}
|
||
|
||
// Updates a channel’s properties.
|
||
//
|
||
// Requires a user access token that includes the channel:manage:broadcast scope.
|
||
func (c *Channels) ModifyChannelInformation(broadcasterID string, req *ModifyChannelInformationRequest) error {
|
||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "channels", RawQuery: "broadcaster_id=" + broadcasterID})
|
||
|
||
r, w := io.Pipe()
|
||
|
||
go func() {
|
||
if err := json.NewEncoder(w).Encode(req); err != nil {
|
||
w.CloseWithError(err)
|
||
} else {
|
||
w.Close()
|
||
}
|
||
}()
|
||
|
||
_, err := c.client.Do(&http.Request{
|
||
Method: http.MethodPatch,
|
||
URL: endpoint,
|
||
Body: r,
|
||
})
|
||
|
||
return err
|
||
}
|