-
Notifications
You must be signed in to change notification settings - Fork 4
/
types.go
75 lines (63 loc) · 1.89 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package twitch
import (
"encoding/json"
"time"
)
type MessageMetadata struct {
MessageID string `json:"message_id"`
MessageType string `json:"message_type"`
MessageTimestamp time.Time `json:"message_timestamp"`
}
type PayloadSession struct {
ID string `json:"id"`
Status string `json:"status"`
ConnectedAt time.Time `json:"connected_at"`
KeepaliveTimeoutSeconds int `json:"keepalive_timeout_seconds"`
ReconnectUrl string `json:"reconnect_url"`
}
type SubscriptionTransport struct {
Method string `json:"method"`
SessionID string `json:"session_id"`
}
type SubscriptionRequest struct {
Type EventSubscription `json:"type"`
Version string `json:"version"`
Condition map[string]string `json:"condition"`
Transport SubscriptionTransport `json:"transport"`
}
type PayloadSubscription struct {
SubscriptionRequest
ID string `json:"id"`
Status string `json:"status"`
Cost int `json:"cost"`
CreateAt time.Time `json:"created_at"`
}
type WelcomeMessage struct {
Metadata MessageMetadata `json:"metadata"`
Payload struct {
Session PayloadSession `json:"session"`
} `json:"payload"`
}
type KeepAliveMessage struct {
Metadata MessageMetadata `json:"metadata"`
Payload struct{} `json:"payload"`
}
type NotificationMessage struct {
Metadata MessageMetadata `json:"metadata"`
Payload struct {
Subscription PayloadSubscription `json:"subscription"`
Event *json.RawMessage `json:"event"`
} `json:"payload"`
}
type ReconnectMessage struct {
Metadata MessageMetadata `json:"metadata"`
Payload struct {
Session PayloadSession `json:"session"`
} `json:"payload"`
}
type RevokeMessage struct {
Metadata MessageMetadata `json:"metadata"`
Payload struct {
Subscription PayloadSubscription `json:"subscription"`
} `json:"payload"`
}