go-twitch/api/eventsub/models.go

141 lines
8.5 KiB
Go

package eventsub
import "time"
type Condition map[string]any
type Subscription struct {
ID string `json:"id"`
Status string `json:"status"`
Type string `json:"type"`
Version string `json:"version"`
Condition Condition `json:"condition"`
CreatedAt time.Time `json:"created_at"`
Transport *Transport `json:"transport"`
Cost int `json:"cost"`
}
type Status string
const (
StatusEnabled = "enabled"
StatusWebhookCallbackVerificationPending = "webhook_callback_verification_pending"
StatusWebhookCallbackVerificationFailed = "webhook_callback_verification_failed"
NotificationFailuresExceeded = "notification_failures_exceeded"
AuthorizationRevoked = "authorization_revoked"
ModeratorRemoved = "moderator_removed"
USerRemoved = "user_removed"
VersionRemoved = "version_removed"
BetaMaintenance = "beta_maintenance"
WebsocketDisconnected = "websocket_disconnected"
WebsocketFailedPingPong = "websocket_failed_ping_pong"
WebsocketReceivedInboundTraffic = "websocket_received_inbound_traffic"
WebsocketConnectionUnused = "websocket_connection_unused"
WebsocketInternalError = "websocket_internal_error"
WebsocketNetworkTimeout = "websocket_network_timeout"
WebsocketnetworkError = "websocket_network_error"
)
type Transport struct {
Method string `json:"method"`
Callback *string `json:"callback,omitempty"`
Secret *string `json:"secret,omitempty"`
SessionID *string `json:"session_id,omitempty"`
ConduitID *string `json:"conduit_id,omitempty"`
}
func WebhookTransport(callback string, secret string) *Transport {
return &Transport{
Method: "webhook",
Callback: &callback,
Secret: &secret,
SessionID: nil,
ConduitID: nil,
}
}
func WebSocketTransport(sessionID string) *Transport {
return &Transport{
Method: "websocket",
Callback: nil,
Secret: nil,
SessionID: &sessionID,
ConduitID: nil,
}
}
func ConduitTransport(conduitID string) *Transport {
return &Transport{
Method: "websocket",
Callback: nil,
Secret: nil,
SessionID: nil,
ConduitID: &conduitID,
}
}
type SubscriptionType struct {
Name string `json:"type"`
Version string `json:"version"`
}
var (
ChannelUpdate = SubscriptionType{Name: "channel.update", Version: "2"}
ChannelFollow = SubscriptionType{Name: "channel.follow", Version: "2"}
ChannelAdBreakBegin = SubscriptionType{Name: "channel.ad_break_begin", Version: "1"}
ChannelChatClear = SubscriptionType{Name: "channel.chat.clear", Version: "1"}
ChannelChatClearUserMessages = SubscriptionType{Name: "channel.chat.clear_user_messages", Version: "1"}
ChannelChatMessage = SubscriptionType{Name: "channel.chat.message", Version: "1"}
ChannelChatMessageDelete = SubscriptionType{Name: "channel.chat.message_delete", Version: "1"}
ChannelChatNotification = SubscriptionType{Name: "channel.chat.notification", Version: "1"}
ChannelChatSettingsUpdate = SubscriptionType{Name: "channel.chat_settings.update", Version: "beta"}
ChannelSubscribe = SubscriptionType{Name: "channel.subscribe", Version: "1"}
ChannelSubscriptionEnd = SubscriptionType{Name: "channel.subscription.end", Version: "1"}
ChannelSubscriptionGift = SubscriptionType{Name: "channel.subscription.gift", Version: "1"}
ChannelSubscriptionMessage = SubscriptionType{Name: "channel.subscription.message", Version: "1"}
ChannelCheer = SubscriptionType{Name: "channel.cheer", Version: "1"}
ChannelRaid = SubscriptionType{Name: "channel.raid", Version: "1"}
ChannelBan = SubscriptionType{Name: "channel.ban", Version: "1"}
ChannelUnban = SubscriptionType{Name: "channel.unban", Version: "1"}
ChannelModeratorAdd = SubscriptionType{Name: "channel.moderator.add", Version: "1"}
ChannelModeratorRemove = SubscriptionType{Name: "channel.moderator.remove", Version: "1"}
ChannelGuestStarSessionBegin = SubscriptionType{Name: "channel.guest_star_session.begin", Version: "beta"}
ChannelGuestStarSessionEnd = SubscriptionType{Name: "channel.guest_star_session.end", Version: "beta"}
ChannelGuestStarGuestUpdate = SubscriptionType{Name: "channel.guest_star_guest.update", Version: "beta"}
ChannelGuestStarSettingsUpdate = SubscriptionType{Name: "channel.guest_star_settings.update", Version: "beta"}
ChannelPointsCustomRewardAdd = SubscriptionType{Name: "channel.channel_points_custom_reward.add", Version: "1"}
ChannelPointsCustomRewardUpdate = SubscriptionType{Name: "channel.channel_points_custom_reward.update", Version: "1"}
ChannelPointsCustomRewardRemove = SubscriptionType{Name: "channel.channel_points_custom_reward.remove", Version: "1"}
ChannelPointsCustomRewardRedemptionAdd = SubscriptionType{Name: "channel.channel_points_custom_reward_redemption.add", Version: "1"}
ChannelPointsCustomRewardRedemptionUpdate = SubscriptionType{Name: "channel.channel_points_custom_reward_redemption.update", Version: "1"}
ChannelPollBegin = SubscriptionType{Name: "channel.poll.begin", Version: "1"}
ChannelPollProgress = SubscriptionType{Name: "channel.poll.progress", Version: "1"}
ChannelPollEnd = SubscriptionType{Name: "channel.poll.end", Version: "1"}
ChannelPredictionBegin = SubscriptionType{Name: "channel.prediction.begin", Version: "1"}
ChannelPredictionProgress = SubscriptionType{Name: "channel.prediction.progress", Version: "1"}
ChannelPredictionLock = SubscriptionType{Name: "channel.prediction.lock", Version: "1"}
ChannelPredictionEnd = SubscriptionType{Name: "channel.prediction.end", Version: "1"}
CharityCampaignDonate = SubscriptionType{Name: "channel.charity_campaign.donate", Version: "1"}
CharityCampaignStart = SubscriptionType{Name: "channel.charity_campaign.start", Version: "1"}
CharityCampaignProgress = SubscriptionType{Name: "channel.charity_campaign.progress", Version: "1"}
CharityCampaignStop = SubscriptionType{Name: "channel.charity_campaign.stop", Version: "1"}
ConduitShardDisabled = SubscriptionType{Name: "conduit.shard.disabled", Version: "1"}
DropEntitlementGrant = SubscriptionType{Name: "drop.entitlement.grant", Version: "1"}
ExtensionBitsTransactionCreate = SubscriptionType{Name: "extension.bits.transaction.create", Version: "1"}
GoalBegin = SubscriptionType{Name: "goal.begin", Version: "1"}
GoalProgress = SubscriptionType{Name: "goal.progress", Version: "1"}
GoalEnd = SubscriptionType{Name: "goal.end", Version: "1"}
HypeTrainBegin = SubscriptionType{Name: "hype_train.begin", Version: "1"}
HypeTrainProgress = SubscriptionType{Name: "hype_train.progress", Version: "1"}
HypeTrainEnd = SubscriptionType{Name: "hype_train.end", Version: "1"}
ShieldModeBegin = SubscriptionType{Name: "shield_mode.begin", Version: "1"}
ShieldModeEnd = SubscriptionType{Name: "shield_mode.end", Version: "1"}
ShoutoutCreate = SubscriptionType{Name: "shoutout.create", Version: "1"}
ShoutoutReceived = SubscriptionType{Name: "shoutout.received", Version: "1"}
StreamOnline = SubscriptionType{Name: "stream.online", Version: "1"}
StreamOffline = SubscriptionType{Name: "stream.offline", Version: "1"}
UserAuthorizationGrant = SubscriptionType{Name: "user.authorization.grant", Version: "1"}
UserAuthorizationRevoke = SubscriptionType{Name: "user.authorization.revoke", Version: "1"}
UserUpdate = SubscriptionType{Name: "user.update", Version: "1"}
)