Documentation
¶
Index ¶
- Variables
- type Chatters
- type GetStreamsParameters
- type GetUsersParameters
- type HelixError
- type HelixResponse
- type HelixStream
- type IDError
- type IDResponse
- type StartCommercialParameters
- type TMIError
- type Token
- type TwitchAPI
- type TwitchAPIHelix
- func (a *TwitchAPIHelix) Authenticate(oauthToken string) error
- func (a *TwitchAPIHelix) Authenticated() bool
- func (a *TwitchAPIHelix) GetStreams(parameters *GetStreamsParameters) ([]HelixStream, error)
- func (a *TwitchAPIHelix) GetUsers(parameters *GetUsersParameters) ([]User, error)
- func (a *TwitchAPIHelix) GetWebhookSubscriptions(after, first string) (result WebhookSubscriptionsResponse, err error)
- func (a *TwitchAPIHelix) RefreshAppAccessToken() (err error)
- func (a *TwitchAPIHelix) WebhookSubscribe(callbackURL string, topic WebhookTopic, twitchUserID string, ...) (result WebhookSubscribeResponse, err error)
- type TwitchAPIID
- func (a *TwitchAPIID) Authenticate(oauthToken string) *TwitchAPIID
- func (a *TwitchAPIID) Authenticated() bool
- func (a *TwitchAPIID) GetAppAccessToken() (Token, error)
- func (a *TwitchAPIID) SetClientSecret(clientSecret string)
- func (a *TwitchAPIID) Token(grantType string) (result Token, err error)
- func (a *TwitchAPIID) Validate() (ValidateResponse, error)
- type TwitchAPITMI
- type TwitchAPIV5
- func (a *TwitchAPIV5) Authenticate(oauthToken string) error
- func (a *TwitchAPIV5) Authenticated() bool
- func (a *TwitchAPIV5) StartCommercial(channelID string, parameters *StartCommercialParameters) (rResult *V5StartCommercialResponse, err error)
- func (a *TwitchAPIV5) UpdateChannel(channelID string, parameters *UpdateChannelParameters) (rResult *V5Channel, err error)
- type UpdateChannelParameters
- func (p *UpdateChannelParameters) ResetGame() *UpdateChannelParameters
- func (p *UpdateChannelParameters) ResetTitle() *UpdateChannelParameters
- func (p *UpdateChannelParameters) SetGame(v string) *UpdateChannelParameters
- func (p *UpdateChannelParameters) SetTitle(v string) *UpdateChannelParameters
- func (p *UpdateChannelParameters) Validate() error
- type User
- type V5Channel
- type V5Error
- type V5StartCommercialResponse
- type ValidateResponse
- type WebhookSubscribeResponse
- type WebhookSubscription
- type WebhookSubscriptionsResponse
- type WebhookTopic
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotAuthenticated is returned by functions that requires user-authentication ErrNotAuthenticated = errors.New("not authenticated") // ErrMissingParameters is returned if parameters are not passed to a function that requires parameters ErrMissingParameters = errors.New("missing required parameters") // ErrCannotPassEmptyStringAsLookupValue is returned if ErrCannotPassEmptyStringAsLookupValue = errors.New("cannot pass empty string as lookup value") // ErrMissingID is returned if the ID class was not initialized properly for the helix api object ErrMissingID = errors.New("missing id class in helix class") // ErrMissingClientSecret is returned if a function requires a client secret to be set but no client secret has been set ErrMissingClientSecret = errors.New("missing client secret") )
var ( ErrGetUsersNoUsers = errors.New("at least one user must be specified") ErrGetUsersTooManyUsers = errors.New("too many users specified") )
var ( // ErrInvalidCommercialLength is returned from StartCommercial if the commercial length parameter is INVALID ErrInvalidCommercialLength = errors.New("invalid commercial length") )
var ( // ErrMissingGameOrTitle is returned from V5's UpdateChannel in case neither a game or title has been passed to the parameters ErrMissingGameOrTitle = errors.New("missing required game or title parameters") )
Functions ¶
This section is empty.
Types ¶
type Chatters ¶
type Chatters struct {
Moderators []string `json:"moderators"`
Staff []string `json:"staff"`
Admins []string `json:"admins"`
GlobalMods []string `json:"global_mods"`
Viewers []string `json:"viewers"`
}
Chatters json to struct
type GetStreamsParameters ¶
type GetStreamsParameters struct {
GameID string
Language string
UserIDs []string
UserLogins []string
}
func NewGetStreamsParameters ¶
func NewGetStreamsParameters() *GetStreamsParameters
func (*GetStreamsParameters) Apply ¶
func (p *GetStreamsParameters) Apply(req *resty.Request)
func (*GetStreamsParameters) SetUserIDs ¶
func (p *GetStreamsParameters) SetUserIDs(v []string) *GetStreamsParameters
func (*GetStreamsParameters) SetUserLogins ¶
func (p *GetStreamsParameters) SetUserLogins(v []string) *GetStreamsParameters
func (*GetStreamsParameters) Validate ¶
func (p *GetStreamsParameters) Validate() error
type GetUsersParameters ¶
func NewGetUsersParameters ¶
func NewGetUsersParameters() *GetUsersParameters
func (*GetUsersParameters) Apply ¶
func (p *GetUsersParameters) Apply(req *resty.Request)
func (*GetUsersParameters) SetUserIDs ¶
func (p *GetUsersParameters) SetUserIDs(v []string) *GetUsersParameters
func (*GetUsersParameters) SetUserLogins ¶
func (p *GetUsersParameters) SetUserLogins(v []string) *GetUsersParameters
func (*GetUsersParameters) Validate ¶
func (p *GetUsersParameters) Validate() error
type HelixError ¶
type HelixResponse ¶
type HelixResponse struct {
Data interface{} `json:"data"`
// TODO: Handle this
Pagination interface{} `json:"pagination"`
}
type HelixStream ¶
type HelixStream struct {
ID string `json:"id"`
UserID string `json:"user_id"`
UserName string `json:"user_name"`
GameID string `json:"game_id"`
CommunityIds []string `json:"community_ids"`
Type string `json:"type"`
Title string `json:"title"`
ViewerCount int `json:"viewer_count"`
StartedAt time.Time `json:"started_at"`
Language string `json:"language"`
ThumbnailURL string `json:"thumbnail_url"`
}
HelixStream json to struct
type IDResponse ¶
type IDResponse struct {
Data interface{} `json:"data"`
// TODO: Handle this
Pagination interface{} `json:"pagination"`
}
type StartCommercialParameters ¶
type StartCommercialParameters struct {
Length int `json:"length"`
}
StartCommercialParameters are parameters sent through to the V5 StartCommercial function
func NewStartCommercialParameters ¶
func NewStartCommercialParameters() *StartCommercialParameters
NewStartCommercialParameters creates a start commercial parameters struct with proper default values
func (*StartCommercialParameters) ResetLength ¶
func (p *StartCommercialParameters) ResetLength() *StartCommercialParameters
ResetLength resets the length of the parameters to its default value (30)
func (*StartCommercialParameters) SetLength ¶
func (p *StartCommercialParameters) SetLength(v int) *StartCommercialParameters
SetLength sets the commercial length to the given value. Note that parameter validity is now checked here, but in the StartCommercial function
func (*StartCommercialParameters) Validate ¶
func (p *StartCommercialParameters) Validate() error
Validate validates the parameters
type TMIError ¶
type TMIError json.RawMessage
type TwitchAPI ¶
type TwitchAPI struct {
// contains filtered or unexported fields
}
TwitchAPI struct
func (*TwitchAPI) Helix ¶
func (a *TwitchAPI) Helix() *TwitchAPIHelix
Helix returns the Helix API object
func (*TwitchAPI) SetClientSecret ¶
SetClientSecret sets the client secret for the ID api
type TwitchAPIHelix ¶
type TwitchAPIHelix struct {
// contains filtered or unexported fields
}
func NewTwitchAPIHelix ¶
func NewTwitchAPIHelix(clientID string, id *TwitchAPIID) *TwitchAPIHelix
func (*TwitchAPIHelix) Authenticate ¶
func (a *TwitchAPIHelix) Authenticate(oauthToken string) error
func (*TwitchAPIHelix) Authenticated ¶
func (a *TwitchAPIHelix) Authenticated() bool
func (*TwitchAPIHelix) GetStreams ¶
func (a *TwitchAPIHelix) GetStreams(parameters *GetStreamsParameters) ([]HelixStream, error)
func (*TwitchAPIHelix) GetUsers ¶
func (a *TwitchAPIHelix) GetUsers(parameters *GetUsersParameters) ([]User, error)
GetUsers request for GET https://api.twitch.tv/helix/users
func (*TwitchAPIHelix) GetWebhookSubscriptions ¶
func (a *TwitchAPIHelix) GetWebhookSubscriptions(after, first string) (result WebhookSubscriptionsResponse, err error)
func (*TwitchAPIHelix) RefreshAppAccessToken ¶
func (a *TwitchAPIHelix) RefreshAppAccessToken() (err error)
func (*TwitchAPIHelix) WebhookSubscribe ¶
func (a *TwitchAPIHelix) WebhookSubscribe(callbackURL string, topic WebhookTopic, twitchUserID string, lease time.Duration, secret string) (result WebhookSubscribeResponse, err error)
type TwitchAPIID ¶
type TwitchAPIID struct {
// contains filtered or unexported fields
}
func NewTwitchAPIID ¶
func NewTwitchAPIID(clientID string) *TwitchAPIID
func (*TwitchAPIID) Authenticate ¶
func (a *TwitchAPIID) Authenticate(oauthToken string) *TwitchAPIID
func (*TwitchAPIID) Authenticated ¶
func (a *TwitchAPIID) Authenticated() bool
func (*TwitchAPIID) GetAppAccessToken ¶
func (a *TwitchAPIID) GetAppAccessToken() (Token, error)
func (*TwitchAPIID) SetClientSecret ¶
func (a *TwitchAPIID) SetClientSecret(clientSecret string)
func (*TwitchAPIID) Validate ¶
func (a *TwitchAPIID) Validate() (ValidateResponse, error)
Validate request for GET https://id.twitch.tv/oauth2/validate
type TwitchAPITMI ¶
type TwitchAPITMI struct {
// contains filtered or unexported fields
}
func NewTwitchAPITMI ¶
func NewTwitchAPITMI(clientID string) *TwitchAPITMI
func (*TwitchAPITMI) GetChatters ¶
func (a *TwitchAPITMI) GetChatters(login string) (Chatters, error)
type TwitchAPIV5 ¶
type TwitchAPIV5 struct {
// contains filtered or unexported fields
}
func NewTwitchAPIV5 ¶
func NewTwitchAPIV5(clientID string) *TwitchAPIV5
func (*TwitchAPIV5) Authenticate ¶
func (a *TwitchAPIV5) Authenticate(oauthToken string) error
func (*TwitchAPIV5) Authenticated ¶
func (a *TwitchAPIV5) Authenticated() bool
func (*TwitchAPIV5) StartCommercial ¶
func (a *TwitchAPIV5) StartCommercial(channelID string, parameters *StartCommercialParameters) (rResult *V5StartCommercialResponse, err error)
StartCommercial request for GET https://dev.twitch.tv/docs/v5/reference/channels#start-channel-commercial
func (*TwitchAPIV5) UpdateChannel ¶
func (a *TwitchAPIV5) UpdateChannel(channelID string, parameters *UpdateChannelParameters) (rResult *V5Channel, err error)
UpdateChannel request for GET https://api.twitch.tv/kraken/channel
type UpdateChannelParameters ¶
type UpdateChannelParameters struct {
Game *string `json:"game,omitempty"`
Title *string `json:"status,omitempty"`
}
UpdateChannelParameters are parameters sent through to the V5 Update Channel API
func NewUpdateChannelParameters ¶
func NewUpdateChannelParameters() *UpdateChannelParameters
NewUpdateChannelParameters is a helper for creating an UpdateChannelParameters struct
func (*UpdateChannelParameters) ResetGame ¶
func (p *UpdateChannelParameters) ResetGame() *UpdateChannelParameters
ResetGame resets the game
func (*UpdateChannelParameters) ResetTitle ¶
func (p *UpdateChannelParameters) ResetTitle() *UpdateChannelParameters
ResetTitle resets the title
func (*UpdateChannelParameters) SetGame ¶
func (p *UpdateChannelParameters) SetGame(v string) *UpdateChannelParameters
SetGame sets the game
func (*UpdateChannelParameters) SetTitle ¶
func (p *UpdateChannelParameters) SetTitle(v string) *UpdateChannelParameters
SetTitle sets the title
func (*UpdateChannelParameters) Validate ¶
func (p *UpdateChannelParameters) Validate() error
Validate validates the given parameters Rule #1: Either Game or Title MUST be set
type User ¶
type User struct {
ID string `json:"id"`
Login string `json:"login"`
DisplayName string `json:"display_name"`
Type string `json:"type"`
BroadcasterType string `json:"broadcaster_type"`
Description string `json:"description"`
ProfileImageURL string `json:"profile_image_url"`
OfflineImageURL string `json:"offline_image_url"`
ViewCount int `json:"view_count"`
Email string `json:"email"`
}
User json to struct (HELIX)
type V5Channel ¶
type V5Channel struct {
ID string `json:"_id"`
BroadcasterLanguage string `json:"broadcaster_language"`
BroadcasterSoftware string `json:"broadcaster_software"`
BroadcasterType string `json:"broadcaster_type"`
CreatedAt string `json:"created_at"`
Description string `json:"description"`
DisplayName string `json:"display_name"`
Followers int `json:"followers"`
Game string `json:"game"`
Language string `json:"language"`
Logo string `json:"logo"`
Mature bool `json:"mature"`
Name string `json:"name"`
Partner bool `json:"partner"`
PrivacyOptionsEnabled bool `json:"privacy_options_enabled"`
PrivateVideo bool `json:"private_video"`
ProfileBanner interface{} `json:"profile_banner"`
ProfileBannerBackgroundColor interface{} `json:"profile_banner_background_color"`
Status string `json:"status"`
UpdatedAt string `json:"updated_at"`
URL string `json:"url"`
VideoBanner interface{} `json:"video_banner"`
Views int `json:"views"`
}
V5Channel is the struct returned from the V5 channel get API
type V5StartCommercialResponse ¶
V5StartCommercialResponse is returned from V5's StartCommercial function The fields indicate how long the commercial will run and in how long another commercial can be run
type ValidateResponse ¶
type WebhookSubscribeResponse ¶
type WebhookSubscribeResponse json.RawMessage
type WebhookSubscription ¶
type WebhookSubscriptionsResponse ¶
type WebhookSubscriptionsResponse struct {
Total int `json:"total"`
Data []WebhookSubscription `json:"data"`
// TODO: Handle this
Pagination interface{} `json:"pagination"`
}
type WebhookTopic ¶
type WebhookTopic int
const ( WebhookTopicFollowers WebhookTopic = iota WebhookTopicStreams WebhookTopicUserChanged )
func (WebhookTopic) String ¶
func (t WebhookTopic) String() string
func (WebhookTopic) URL ¶
func (t WebhookTopic) URL(twitchUserID string) string
Source Files
¶
- err.go
- gotwitch.go
- helix.go
- helix_get_streams.go
- helix_get_users.go
- helix_refresh_app_access_token.go
- helix_webhook.go
- helix_webhook_get_subscriptions.go
- helix_webhook_subscribe.go
- helix_webhook_topic.go
- id.go
- id_get_app_access_token.go
- id_token.go
- id_validate.go
- tmi.go
- tmi_get_chatters.go
- v5.go
- v5_start_commercial.go
- v5_update_channel.go