Documentation ¶
Index ¶
- Constants
- func RewardStatusIsCancelled(status string) bool
- func RewardStatusIsFullfilled(status string) bool
- func RewardStatusIsUnfullfilled(status string) bool
- type Client
- type CreateCustomRewardRequest
- type CreateCustomRewardResponse
- type CreateCustomRewardResponseDataItem
- type ErrorResponse
- type HelixClient
- func (c *HelixClient) CreateEventSubSubscription(userID string, webHookUrl string, subType string) (*helix.EventSubSubscriptionsResponse, error)
- func (c *HelixClient) CreateOrUpdateReward(userID string, reward CreateCustomRewardRequest, rewardID string) (*helix.ChannelCustomReward, error)
- func (c *HelixClient) CreatePrediction(params *helix.CreatePredictionParams) (*helix.PredictionsResponse, error)
- func (c *HelixClient) CreateRewardEventSubSubscription(userID, webHookUrl, subType, rewardID string, retry bool) (*helix.EventSubSubscriptionsResponse, error)
- func (c *HelixClient) DeleteReward(userID string, rewardID string) error
- func (c *HelixClient) EndPrediction(params *helix.EndPredictionParams) (*helix.PredictionsResponse, error)
- func (c *HelixClient) GetAllSubscriptions(eventType string) []helix.EventSubSubscription
- func (c *HelixClient) GetEventSubSubscriptions(params *helix.EventSubSubscriptionsParams) (*helix.EventSubSubscriptionsResponse, error)
- func (c *HelixClient) GetPredictions(params *helix.PredictionsParams) (*helix.PredictionsResponse, error)
- func (c *HelixClient) GetUserByUserID(userID string) (UserData, error)
- func (c *HelixClient) GetUserByUsername(username string) (UserData, error)
- func (c *HelixClient) GetUsersByUserIds(userIDs []string) (map[string]UserData, error)
- func (c *HelixClient) GetUsersByUsernames(usernames []string) (map[string]UserData, error)
- func (c *HelixClient) RefreshToken(token store.UserAccessToken) error
- func (c *HelixClient) RemoveEventSubSubscription(id string) (*helix.RemoveEventSubSubscriptionParamsResponse, error)
- func (c *HelixClient) RequestUserAccessToken(code string) (*helix.UserAccessTokenResponse, error)
- func (c *HelixClient) SendChatMessage(channelID string, message string) (*SendChatMessageResponse, error)
- func (c *HelixClient) SetAppAccessToken(ctx context.Context, token helix.AccessCredentials)
- func (c *HelixClient) SetUserAccessToken(token string)
- func (c *HelixClient) StartRefreshTokenRoutine()
- func (c *HelixClient) UpdateRedemptionStatus(broadcasterID, rewardID string, redemptionID string, statusSuccess bool) error
- func (c *HelixClient) ValidateToken(accessToken string) (bool, *helix.ValidateTokenResponse, error)
- type MockHelixClient
- func (m *MockHelixClient) CreateEventSubSubscription(userID string, webHookUrl string, subType string) (*helix.EventSubSubscriptionsResponse, error)
- func (m *MockHelixClient) CreateOrUpdateReward(userID string, reward CreateCustomRewardRequest, rewardID string) (*helix.ChannelCustomReward, error)
- func (m *MockHelixClient) CreatePrediction(params *helix.CreatePredictionParams) (*helix.PredictionsResponse, error)
- func (m *MockHelixClient) CreateRewardEventSubSubscription(userID, webHookUrl, subType, rewardID string, retry bool) (*helix.EventSubSubscriptionsResponse, error)
- func (m *MockHelixClient) DeleteReward(userID string, rewardID string) error
- func (m *MockHelixClient) EndPrediction(params *helix.EndPredictionParams) (*helix.PredictionsResponse, error)
- func (m *MockHelixClient) GetAllSubscriptions(eventType string) []helix.EventSubSubscription
- func (m *MockHelixClient) GetEventSubSubscriptions(params *helix.EventSubSubscriptionsParams) (*helix.EventSubSubscriptionsResponse, error)
- func (m *MockHelixClient) GetPredictions(params *helix.PredictionsParams) (*helix.PredictionsResponse, error)
- func (m *MockHelixClient) GetUserByUserID(userID string) (UserData, error)
- func (m *MockHelixClient) GetUserByUsername(username string) (UserData, error)
- func (m *MockHelixClient) GetUsersByUserIds(userIDs []string) (map[string]UserData, error)
- func (m *MockHelixClient) GetUsersByUsernames(usernames []string) (map[string]UserData, error)
- func (m *MockHelixClient) RefreshToken(token store.UserAccessToken) error
- func (m *MockHelixClient) RemoveEventSubSubscription(id string) (*helix.RemoveEventSubSubscriptionParamsResponse, error)
- func (m *MockHelixClient) RequestUserAccessToken(code string) (*helix.UserAccessTokenResponse, error)
- func (m *MockHelixClient) SendChatMessage(channelID string, message string) (*SendChatMessageResponse, error)
- func (m *MockHelixClient) SetUserAccessToken(token string)
- func (m *MockHelixClient) StartRefreshTokenRoutine()
- func (m *MockHelixClient) UpdateRedemptionStatus(broadcasterID, rewardID string, redemptionID string, statusSuccess bool) error
- func (m *MockHelixClient) ValidateToken(accessToken string) (bool, *helix.ValidateTokenResponse, error)
- type SendChatMessageResponse
- type UpdateRedemptionStatusRequest
- type UpdateRedemptionStatusResponse
- type UserData
Constants ¶
View Source
const TWITCH_API = "https://api.twitch.tv/"
Variables ¶
This section is empty.
Functions ¶
func RewardStatusIsCancelled ¶
Types ¶
type Client ¶
type Client interface { StartRefreshTokenRoutine() RefreshToken(token store.UserAccessToken) error CreateEventSubSubscription(userID string, webHookUrl string, subType string) (*helix.EventSubSubscriptionsResponse, error) CreateRewardEventSubSubscription(userID, webHookUrl, subType, rewardID string, false bool) (*helix.EventSubSubscriptionsResponse, error) RemoveEventSubSubscription(id string) (*helix.RemoveEventSubSubscriptionParamsResponse, error) GetEventSubSubscriptions(params *helix.EventSubSubscriptionsParams) (*helix.EventSubSubscriptionsResponse, error) GetAllSubscriptions(eventType string) []helix.EventSubSubscription GetPredictions(params *helix.PredictionsParams) (*helix.PredictionsResponse, error) EndPrediction(params *helix.EndPredictionParams) (*helix.PredictionsResponse, error) CreatePrediction(params *helix.CreatePredictionParams) (*helix.PredictionsResponse, error) CreateOrUpdateReward(userID string, reward CreateCustomRewardRequest, rewardID string) (*helix.ChannelCustomReward, error) UpdateRedemptionStatus(broadcasterID, rewardID string, redemptionID string, statusSuccess bool) error DeleteReward(userID string, rewardID string) error GetUsersByUserIds(userIDs []string) (map[string]UserData, error) GetUsersByUsernames(usernames []string) (map[string]UserData, error) GetUserByUsername(username string) (UserData, error) GetUserByUserID(userID string) (UserData, error) SetUserAccessToken(token string) ValidateToken(accessToken string) (bool, *helix.ValidateTokenResponse, error) RequestUserAccessToken(code string) (*helix.UserAccessTokenResponse, error) SendChatMessage(channelID string, message string) (*SendChatMessageResponse, error) }
type CreateCustomRewardRequest ¶
type CreateCustomRewardRequest struct { Title string `json:"title"` Prompt string `json:"prompt"` Cost int `json:"cost"` IsEnabled bool `json:"is_enabled"` BackgroundColor string `json:"background_color,omitempty"` IsUserInputRequired bool `json:"is_user_input_required"` IsMaxPerStreamEnabled bool `json:"is_max_per_stream_enabled"` MaxPerStream int `json:"max_per_stream"` IsMaxPerUserPerStreamEnabled bool `json:"is_max_per_user_per_stream_enabled"` MaxPerUserPerStream int `json:"max_per_user_per_stream"` IsGlobalCooldownEnabled bool `json:"is_global_cooldown_enabled"` GlobalCoolDownSeconds int `json:"global_cooldown_seconds"` ShouldRedemptionsSkipRequestQueue bool `json:"should_redemptions_skip_request_queue"` }
type CreateCustomRewardResponse ¶
type CreateCustomRewardResponse struct {
Data []CreateCustomRewardResponseDataItem `json:"data"`
}
type CreateCustomRewardResponseDataItem ¶
type CreateCustomRewardResponseDataItem struct { BroadcasterName string `json:"broadcaster_name"` BroadcasterLogin string `json:"broadcaster_login"` BroadcasterID string `json:"broadcaster_id"` ID string `json:"id"` Image interface{} `json:"image"` BackgroundColor string `json:"background_color"` IsEnabled bool `json:"is_enabled"` Cost int `json:"cost"` Title string `json:"title"` Prompt string `json:"prompt"` IsUserInputRequired bool `json:"is_user_input_required"` MaxPerStreamSetting struct { IsEnabled bool `json:"is_enabled"` MaxPerStream int `json:"max_per_stream"` } `json:"max_per_stream_setting"` MaxPerUserPerStreamSetting struct { IsEnabled bool `json:"is_enabled"` MaxPerUserPerStream int `json:"max_per_user_per_stream"` } `json:"max_per_user_per_stream_setting"` GlobalCooldownSetting struct { IsEnabled bool `json:"is_enabled"` GlobalCooldownSeconds int `json:"global_cooldown_seconds"` } `json:"global_cooldown_setting"` IsPaused bool `json:"is_paused"` IsInStock bool `json:"is_in_stock"` DefaultImage struct { URL1X string `json:"url_1x"` URL2X string `json:"url_2x"` URL4X string `json:"url_4x"` } `json:"default_image"` ShouldRedemptionsSkipRequestQueue bool `json:"should_redemptions_skip_request_queue"` RedemptionsRedeemedCurrentStream interface{} `json:"redemptions_redeemed_current_stream"` CooldownExpiresAt interface{} `json:"cooldown_expires_at"` }
type ErrorResponse ¶
type HelixClient ¶
type HelixClient struct { Client *helix.Client AppAccessToken helix.AccessCredentials // contains filtered or unexported fields }
Client wrapper for helix
func NewClient ¶
func NewClient(cfg *config.Config, db store.Store) *HelixClient
NewClient Create helix client
func (*HelixClient) CreateEventSubSubscription ¶
func (c *HelixClient) CreateEventSubSubscription(userID string, webHookUrl string, subType string) (*helix.EventSubSubscriptionsResponse, error)
func (*HelixClient) CreateOrUpdateReward ¶
func (c *HelixClient) CreateOrUpdateReward(userID string, reward CreateCustomRewardRequest, rewardID string) (*helix.ChannelCustomReward, error)
func (*HelixClient) CreatePrediction ¶
func (c *HelixClient) CreatePrediction(params *helix.CreatePredictionParams) (*helix.PredictionsResponse, error)
func (*HelixClient) CreateRewardEventSubSubscription ¶
func (c *HelixClient) CreateRewardEventSubSubscription(userID, webHookUrl, subType, rewardID string, retry bool) (*helix.EventSubSubscriptionsResponse, error)
func (*HelixClient) DeleteReward ¶
func (c *HelixClient) DeleteReward(userID string, rewardID string) error
func (*HelixClient) EndPrediction ¶
func (c *HelixClient) EndPrediction(params *helix.EndPredictionParams) (*helix.PredictionsResponse, error)
func (*HelixClient) GetAllSubscriptions ¶
func (c *HelixClient) GetAllSubscriptions(eventType string) []helix.EventSubSubscription
func (*HelixClient) GetEventSubSubscriptions ¶
func (c *HelixClient) GetEventSubSubscriptions(params *helix.EventSubSubscriptionsParams) (*helix.EventSubSubscriptionsResponse, error)
func (*HelixClient) GetPredictions ¶
func (c *HelixClient) GetPredictions(params *helix.PredictionsParams) (*helix.PredictionsResponse, error)
func (*HelixClient) GetUserByUserID ¶
func (c *HelixClient) GetUserByUserID(userID string) (UserData, error)
func (*HelixClient) GetUserByUsername ¶
func (c *HelixClient) GetUserByUsername(username string) (UserData, error)
func (*HelixClient) GetUsersByUserIds ¶
func (c *HelixClient) GetUsersByUserIds(userIDs []string) (map[string]UserData, error)
GetUsersByUserIds receive userData for given ids
func (*HelixClient) GetUsersByUsernames ¶
func (c *HelixClient) GetUsersByUsernames(usernames []string) (map[string]UserData, error)
GetUsersByUsernames fetches userdata from helix
func (*HelixClient) RefreshToken ¶
func (c *HelixClient) RefreshToken(token store.UserAccessToken) error
func (*HelixClient) RemoveEventSubSubscription ¶
func (c *HelixClient) RemoveEventSubSubscription(id string) (*helix.RemoveEventSubSubscriptionParamsResponse, error)
func (*HelixClient) RequestUserAccessToken ¶
func (c *HelixClient) RequestUserAccessToken(code string) (*helix.UserAccessTokenResponse, error)
func (*HelixClient) SendChatMessage ¶
func (c *HelixClient) SendChatMessage(channelID string, message string) (*SendChatMessageResponse, error)
func (*HelixClient) SetAppAccessToken ¶
func (c *HelixClient) SetAppAccessToken(ctx context.Context, token helix.AccessCredentials)
func (*HelixClient) SetUserAccessToken ¶
func (c *HelixClient) SetUserAccessToken(token string)
func (*HelixClient) StartRefreshTokenRoutine ¶
func (c *HelixClient) StartRefreshTokenRoutine()
StartRefreshTokenRoutine refresh our token
func (*HelixClient) UpdateRedemptionStatus ¶
func (c *HelixClient) UpdateRedemptionStatus(broadcasterID, rewardID string, redemptionID string, statusSuccess bool) error
func (*HelixClient) ValidateToken ¶
func (c *HelixClient) ValidateToken(accessToken string) (bool, *helix.ValidateTokenResponse, error)
type MockHelixClient ¶
type MockHelixClient struct{}
func NewMockClient ¶
func NewMockClient() *MockHelixClient
func (*MockHelixClient) CreateEventSubSubscription ¶
func (m *MockHelixClient) CreateEventSubSubscription(userID string, webHookUrl string, subType string) (*helix.EventSubSubscriptionsResponse, error)
func (*MockHelixClient) CreateOrUpdateReward ¶
func (m *MockHelixClient) CreateOrUpdateReward(userID string, reward CreateCustomRewardRequest, rewardID string) (*helix.ChannelCustomReward, error)
func (*MockHelixClient) CreatePrediction ¶
func (m *MockHelixClient) CreatePrediction(params *helix.CreatePredictionParams) (*helix.PredictionsResponse, error)
func (*MockHelixClient) CreateRewardEventSubSubscription ¶
func (m *MockHelixClient) CreateRewardEventSubSubscription(userID, webHookUrl, subType, rewardID string, retry bool) (*helix.EventSubSubscriptionsResponse, error)
func (*MockHelixClient) DeleteReward ¶
func (m *MockHelixClient) DeleteReward(userID string, rewardID string) error
func (*MockHelixClient) EndPrediction ¶
func (m *MockHelixClient) EndPrediction(params *helix.EndPredictionParams) (*helix.PredictionsResponse, error)
func (*MockHelixClient) GetAllSubscriptions ¶
func (m *MockHelixClient) GetAllSubscriptions(eventType string) []helix.EventSubSubscription
func (*MockHelixClient) GetEventSubSubscriptions ¶
func (m *MockHelixClient) GetEventSubSubscriptions(params *helix.EventSubSubscriptionsParams) (*helix.EventSubSubscriptionsResponse, error)
func (*MockHelixClient) GetPredictions ¶
func (m *MockHelixClient) GetPredictions(params *helix.PredictionsParams) (*helix.PredictionsResponse, error)
func (*MockHelixClient) GetUserByUserID ¶
func (m *MockHelixClient) GetUserByUserID(userID string) (UserData, error)
func (*MockHelixClient) GetUserByUsername ¶
func (m *MockHelixClient) GetUserByUsername(username string) (UserData, error)
func (*MockHelixClient) GetUsersByUserIds ¶
func (m *MockHelixClient) GetUsersByUserIds(userIDs []string) (map[string]UserData, error)
func (*MockHelixClient) GetUsersByUsernames ¶
func (m *MockHelixClient) GetUsersByUsernames(usernames []string) (map[string]UserData, error)
func (*MockHelixClient) RefreshToken ¶
func (m *MockHelixClient) RefreshToken(token store.UserAccessToken) error
func (*MockHelixClient) RemoveEventSubSubscription ¶
func (m *MockHelixClient) RemoveEventSubSubscription(id string) (*helix.RemoveEventSubSubscriptionParamsResponse, error)
func (*MockHelixClient) RequestUserAccessToken ¶
func (m *MockHelixClient) RequestUserAccessToken(code string) (*helix.UserAccessTokenResponse, error)
func (*MockHelixClient) SendChatMessage ¶
func (m *MockHelixClient) SendChatMessage(channelID string, message string) (*SendChatMessageResponse, error)
func (*MockHelixClient) SetUserAccessToken ¶
func (m *MockHelixClient) SetUserAccessToken(token string)
func (*MockHelixClient) StartRefreshTokenRoutine ¶
func (m *MockHelixClient) StartRefreshTokenRoutine()
func (*MockHelixClient) UpdateRedemptionStatus ¶
func (m *MockHelixClient) UpdateRedemptionStatus(broadcasterID, rewardID string, redemptionID string, statusSuccess bool) error
func (*MockHelixClient) ValidateToken ¶
func (m *MockHelixClient) ValidateToken(accessToken string) (bool, *helix.ValidateTokenResponse, error)
type SendChatMessageResponse ¶
type UpdateRedemptionStatusRequest ¶
type UpdateRedemptionStatusRequest struct {
Status string `json:"status"`
}
type UpdateRedemptionStatusResponse ¶
type UpdateRedemptionStatusResponse struct { Data []struct { BroadcasterName string `json:"broadcaster_name"` BroadcasterLogin string `json:"broadcaster_login"` BroadcasterID string `json:"broadcaster_id"` ID string `json:"id"` UserID string `json:"user_id"` UserName string `json:"user_name"` UserLogin string `json:"user_login"` UserInput string `json:"user_input"` Status string `json:"status"` RedeemedAt time.Time `json:"redeemed_at"` Reward struct { ID string `json:"id"` Title string `json:"title"` Prompt string `json:"prompt"` Cost int `json:"cost"` } `json:"reward"` } `json:"data"` }
type UserData ¶
type UserData 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"` }
UserData exported data from twitch
Click to show internal directories.
Click to hide internal directories.