forked from nicklaw5/helix
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bits.go
110 lines (91 loc) · 3.12 KB
/
bits.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package helix
import "time"
type UserBitTotal struct {
UserID string `json:"user_id"`
UserLogin string `json:"user_login"`
UserName string `json:"user_name"`
Rank int `json:"rank"`
Score int `json:"score"`
}
type ManyUserBitTotals struct {
Total int `json:"total"`
DateRange DateRange `json:"date_range"`
UserBitTotals []UserBitTotal `json:"data"`
}
type BitsLeaderboardResponse struct {
ResponseCommon
Data ManyUserBitTotals
}
type BitsLeaderboardParams struct {
Count int `query:"count,10"` // Maximum 100
Period string `query:"period,all"` // "all" (default), "day", "week", "month" and "year"
StartedAt time.Time `query:"started_at"`
UserID string `query:"user_id"`
}
// GetBitsLeaderboard gets a ranked list of Bits leaderboard
// information for an authorized broadcaster.
//
// Required Scope: bits:read
func (c *Client) GetBitsLeaderboard(params *BitsLeaderboardParams) (*BitsLeaderboardResponse, error) {
resp, err := c.get("/bits/leaderboard", &ManyUserBitTotals{}, params)
if err != nil {
return nil, err
}
bits := &BitsLeaderboardResponse{}
resp.HydrateResponseCommon(&bits.ResponseCommon)
bits.Data.Total = resp.Data.(*ManyUserBitTotals).Total
bits.Data.DateRange = resp.Data.(*ManyUserBitTotals).DateRange
bits.Data.UserBitTotals = resp.Data.(*ManyUserBitTotals).UserBitTotals
return bits, nil
}
type CheermotesParams struct {
BroadcasterID string `query:"broadcaster_id"` // optional
}
type TierImages struct {
Image1 string `json:"1"`
Image1_5 string `json:"1.5"`
Image2 string `json:"2"`
Image3 string `json:"3"`
Image4 string `json:"4"`
}
type TierImageTypes struct {
Animated TierImages `json:"animated"`
Static TierImages `json:"static"`
}
type CheermoteTierImages struct {
Dark TierImageTypes `json:"dark"`
Light TierImageTypes `json:"light"`
}
type CheermoteTiers struct {
MinBits uint `json:"min_bits"`
ID string `json:"id"`
Color string `json:"color"`
Images CheermoteTierImages `json:"images"`
CanCheer bool `json:"can_cheer"`
ShowInBitsCard bool `json:"show_in_bits_card"`
}
type Cheermotes struct {
Prefix string `json:"prefix"`
Tiers []CheermoteTiers `json:"tiers"`
Type string `json:"type"` // global_first_party, global_third_party, channel_custom, display_only, sponsored
Order uint `json:"order"`
LastUpdated Time `json:"last_updated"`
IsCharitable bool `json:"is_charitable"`
}
type ManyCheermotes struct {
Cheermotes []Cheermotes `json:"data"`
}
type CheermotesResponse struct {
ResponseCommon
Data ManyCheermotes
}
func (c *Client) GetCheermotes(params *CheermotesParams) (*CheermotesResponse, error) {
resp, err := c.get("/bits/cheermotes", &ManyCheermotes{}, params)
if err != nil {
return nil, err
}
cheermoteResp := &CheermotesResponse{}
resp.HydrateResponseCommon(&cheermoteResp.ResponseCommon)
cheermoteResp.Data.Cheermotes = resp.Data.(*ManyCheermotes).Cheermotes
return cheermoteResp, nil
}