Add Content Classification Labels endpoints to API
This commit is contained in:
parent
e1b6b5ce88
commit
113327bd86
|
@ -7,6 +7,7 @@ import (
|
|||
"go.fifitido.net/twitch/api/ads"
|
||||
"go.fifitido.net/twitch/api/analytics"
|
||||
"go.fifitido.net/twitch/api/bits"
|
||||
"go.fifitido.net/twitch/api/ccls"
|
||||
"go.fifitido.net/twitch/api/channelpoints"
|
||||
"go.fifitido.net/twitch/api/channels"
|
||||
"go.fifitido.net/twitch/api/charity"
|
||||
|
@ -29,6 +30,7 @@ type API struct {
|
|||
Charity *charity.Charity
|
||||
Chat *chat.Chat
|
||||
Conduit *conduit.Conduit
|
||||
CCLS *ccls.CCLS
|
||||
EventSub *eventsub.EventSub
|
||||
}
|
||||
|
||||
|
@ -48,6 +50,7 @@ func New() *API {
|
|||
Charity: charity.New(client, baseUrl),
|
||||
Chat: chat.New(client, baseUrl),
|
||||
Conduit: conduit.New(client, baseUrl),
|
||||
CCLS: ccls.New(client, baseUrl),
|
||||
EventSub: eventsub.New(client, baseUrl),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package ccls
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
type CCLS struct {
|
||||
client *http.Client
|
||||
baseUrl *url.URL
|
||||
}
|
||||
|
||||
func New(client *http.Client, baseUrl *url.URL) *CCLS {
|
||||
return &CCLS{
|
||||
client: client,
|
||||
baseUrl: baseUrl,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package ccls
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/google/go-querystring/query"
|
||||
"go.fifitido.net/twitch/api/types"
|
||||
)
|
||||
|
||||
type GetContentClassificationLabelsParams struct {
|
||||
// Locale for the Content Classification Labels.
|
||||
// You may specify a maximum of 1 locale.
|
||||
// Default: “en-US”
|
||||
Locale *types.Locale `url:"locale,omitempty"`
|
||||
}
|
||||
|
||||
type GetContentClassificationLabelsResponse struct {
|
||||
// A list that contains information about the available content classification labels.
|
||||
Data []ContentClassificationLabelData `json:"data"`
|
||||
}
|
||||
|
||||
type ContentClassificationLabelData struct {
|
||||
// Unique identifier for the CCL.
|
||||
ID ContentClassificationLabel `json:"id"`
|
||||
|
||||
// Localized description of the CCL.
|
||||
Description string `json:"description"`
|
||||
|
||||
// Localized name of the CCL.
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// Gets information about Twitch content classification labels.
|
||||
//
|
||||
// Requires an app access token or user access token.
|
||||
func (c *CCLS) GetContentClassificationLabels(ctx context.Context, params GetContentClassificationLabelsParams) (*GetContentClassificationLabelsResponse, error) {
|
||||
v, _ := query.Values(params)
|
||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "content_classification_labels", RawQuery: v.Encode()})
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res, err := c.client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
var data GetContentClassificationLabelsResponse
|
||||
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &data, nil
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package ccls
|
||||
|
||||
// Content Classification Label
|
||||
type ContentClassificationLabel string
|
||||
|
||||
const (
|
||||
ContentClassificationLabelDrugsIntoxication ContentClassificationLabel = "DrugsIntoxication"
|
||||
ContentClassificationLabelSexualThemes ContentClassificationLabel = "SexualThemes"
|
||||
ContentClassificationLabelViolentGraphic ContentClassificationLabel = "ViolentGraphic"
|
||||
ContentClassificationLabelGambling ContentClassificationLabel = "Gambling"
|
||||
ContentClassificationLabelProfanityVulgarity ContentClassificationLabel = "ProfanityVulgarity"
|
||||
)
|
|
@ -7,7 +7,7 @@ import (
|
|||
"net/url"
|
||||
|
||||
"github.com/google/go-querystring/query"
|
||||
"go.fifitido.net/twitch/api/types"
|
||||
"go.fifitido.net/twitch/api/ccls"
|
||||
)
|
||||
|
||||
type GetChannelInformationParams struct {
|
||||
|
@ -59,7 +59,7 @@ type ChannelInformation struct {
|
|||
Tags []string `json:"tags"`
|
||||
|
||||
// The CCLs applied to the channel.
|
||||
ContentClassficationLabels []types.CCL `json:"content_classification"`
|
||||
ContentClassficationLabels []ccls.ContentClassificationLabel `json:"content_classification"`
|
||||
|
||||
// Boolean flag indicating if the channel has branded content.
|
||||
IsBrandedContent bool `json:"is_branded_content"`
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"go.fifitido.net/twitch/api/types"
|
||||
"go.fifitido.net/twitch/api/ccls"
|
||||
)
|
||||
|
||||
type ModifyChannelInformationRequest struct {
|
||||
|
@ -44,7 +44,7 @@ type ModifyChannelInformationRequest struct {
|
|||
|
||||
type ModifyContentClassificationLabel struct {
|
||||
// ID of the Content Classification Labels that must be added/removed from the channel.
|
||||
ID types.CCL `json:"id"`
|
||||
ID ccls.ContentClassificationLabel `json:"id"`
|
||||
|
||||
// Boolean flag indicating whether the label should be enabled (true) or disabled for the channel.
|
||||
IsEnabled bool `json:"is_enabled"`
|
||||
|
|
|
@ -46,17 +46,6 @@ type DateRange struct {
|
|||
EndedAt time.Time `json:"ended_at"`
|
||||
}
|
||||
|
||||
// Content Classification Label
|
||||
type CCL string
|
||||
|
||||
const (
|
||||
CCLDrugsIntoxication CCL = "DrugsIntoxication"
|
||||
CCLSexualThemes CCL = "SexualThemes"
|
||||
CCLViolentGraphic CCL = "ViolentGraphic"
|
||||
CCLGambling CCL = "Gambling"
|
||||
CCLProfanityVulgarity CCL = "ProfanityVulgarity"
|
||||
)
|
||||
|
||||
// Sort Order
|
||||
type SortOrder string
|
||||
|
||||
|
@ -91,3 +80,36 @@ const (
|
|||
AccentColorOrange AccentColor = "orange"
|
||||
AccentColorPurple AccentColor = "purple"
|
||||
)
|
||||
|
||||
type Locale string
|
||||
|
||||
const (
|
||||
LocaleBgBg = "bg-BG"
|
||||
LocaleCsCz = "cs-CZ"
|
||||
LocaleDaDk = "da-DK"
|
||||
LocaleDeDe = "de-DE"
|
||||
LocaleElGr = "el-GR"
|
||||
LocaleEnGb = "en-GB"
|
||||
LocaleEnUs = "en-US"
|
||||
LocaleEsEs = "es-ES"
|
||||
LocaleEsMx = "es-MX"
|
||||
LocaleFiFi = "fi-FI"
|
||||
LocaleFrFr = "fr-FR"
|
||||
LocaleHuHu = "hu-HU"
|
||||
LocaleItIt = "it-IT"
|
||||
LocaleJaJp = "ja-JP"
|
||||
LocaleKoKr = "ko-KR"
|
||||
LocaleNlNl = "nl-NL"
|
||||
LocalePlPl = "pl-PL"
|
||||
LocalePtBt = "pt-BT"
|
||||
LocalePtPt = "pt-PT"
|
||||
LocaleRoRo = "ro-RO"
|
||||
LocaleRuRu = "ru-RU"
|
||||
LocaleSkSk = "sk-SK"
|
||||
LocaleSvSe = "sv-SE"
|
||||
LocaleThTh = "th-TH"
|
||||
LocaleTrTr = "tr-TR"
|
||||
LocaleViVn = "vi-VN"
|
||||
LocaleZhCn = "zh-CN"
|
||||
LocaleZhTw = "zh-TW"
|
||||
)
|
||||
|
|
11
ptr_types.go
11
ptr_types.go
|
@ -173,3 +173,14 @@ func ToConduitStatus(s *conduit.Status) conduit.Status {
|
|||
}
|
||||
return *s
|
||||
}
|
||||
|
||||
func Locale(s types.Locale) *types.Locale {
|
||||
return &s
|
||||
}
|
||||
|
||||
func ToLocale(s *types.Locale) types.Locale {
|
||||
if s == nil {
|
||||
return ""
|
||||
}
|
||||
return *s
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue