-
Notifications
You must be signed in to change notification settings - Fork 89
/
hype_train.go
60 lines (51 loc) · 1.99 KB
/
hype_train.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
package helix
type HypeTrainContribuition struct {
Total int64 `json:"total"`
Type string `json:"type"`
User string `json:"user"`
}
type HypeTrainEvent struct {
ID string `json:"id"`
EventType string `json:"event_type"`
EventTimestamp Time `json:"event_timestamp"`
Version string `json:"version"`
Event HypeTrainEventData `json:"event_data"`
}
type HypeTrainEventData struct {
ID string `json:"id"`
BroadcasterID string `json:"broadcaster_id"`
CooldownEndTime Time `json:"cooldown_end_time"`
ExpiresAt Time `json:"expires_at"`
Goal int64 `json:"goal"`
LastContribution HypeTrainContribuition `json:"last_contribution"`
Level int64 `json:"level"`
StartedAt Time `json:"started_at"`
TopContributions []HypeTrainContribuition `json:"top_contributions"`
Total int64 `json:"total"`
}
type ManyHypeTrainEvents struct {
Events []HypeTrainEvent `json:"data"`
Pagination Pagination `json:"pagination"`
}
type HypeTrainEventsResponse struct {
ResponseCommon
Data ManyHypeTrainEvents
}
type HypeTrainEventsParams struct {
BroadcasterID string `query:"broadcaster_id"`
After string `query:"after"`
First int `query:"first,20"` // Limit 100
ID string `query:"id"`
}
// Required scope: channel:read:hype_train
func (c *Client) GetHypeTrainEvents(params *HypeTrainEventsParams) (*HypeTrainEventsResponse, error) {
resp, err := c.get("/hypetrain/events", &ManyHypeTrainEvents{}, params)
if err != nil {
return nil, err
}
events := &HypeTrainEventsResponse{}
resp.HydrateResponseCommon(&events.ResponseCommon)
events.Data.Events = resp.Data.(*ManyHypeTrainEvents).Events
events.Data.Pagination = resp.Data.(*ManyHypeTrainEvents).Pagination
return events, nil
}