-
Notifications
You must be signed in to change notification settings - Fork 89
/
channels_points.go
209 lines (178 loc) · 8.92 KB
/
channels_points.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
package helix
type ChannelCustomRewardsParams struct {
BroadcasterID string `query:"broadcaster_id"`
Title string `json:"title"`
Cost int `json:"cost"`
Prompt string `json:"prompt"`
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 UpdateChannelCustomRewardsParams struct {
ID string `query:"id"`
BroadcasterID string `query:"broadcaster_id"`
Title string `json:"title"`
Cost int `json:"cost"`
Prompt string `json:"prompt"`
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 DeleteCustomRewardsParams struct {
BroadcasterID string `query:"broadcaster_id"`
ID string `query:"id"`
}
type GetCustomRewardsParams struct {
BroadcasterID string `query:"broadcaster_id"`
ID string `query:"id"`
OnlyManageableRewards bool `query:"only_manageable_rewards"`
}
type ManyChannelCustomRewards struct {
ChannelCustomRewards []ChannelCustomReward `json:"data"`
}
type ChannelCustomReward struct {
BroadcasterID string `json:"broadcaster_id"`
BroadcasterLogin string `json:"broadcaster_login"`
BroadcasterName string `json:"broadcaster_name"`
ID string `json:"id"`
Title string `json:"title"`
Prompt string `json:"prompt"`
Cost int `json:"cost"`
Image RewardImage `json:"image"`
BackgroundColor string `json:"background_color"`
DefaultImage RewardImage `json:"default_image"`
IsEnabled bool `json:"is_enabled"`
IsUserInputRequired bool `json:"is_user_input_required"`
MaxPerStreamSetting MaxPerStreamSettings `json:"max_per_stream_setting"`
MaxPerUserPerStreamSetting MaxPerUserPerStreamSettings `json:"max_per_user_per_stream_setting"`
GlobalCooldownSetting GlobalCooldownSettings `json:"global_cooldown_setting"`
IsPaused bool `json:"is_paused"`
IsInStock bool `json:"is_in_stock"`
ShouldRedemptionsSkipRequestQueue bool `json:"should_redemptions_skip_request_queue"`
RedemptionsRedeemedCurrentStream int `json:"redemptions_redeemed_current_stream"`
CooldownExpiresAt string `json:"cooldown_expires_at"`
}
type RewardImage struct {
Url1x string `json:"url_1x"`
Url2x string `json:"url_2x"`
Url4x string `json:"url_4x"`
}
type MaxPerUserPerStreamSettings struct {
IsEnabled bool `json:"is_enabled"`
MaxPerUserPerStream int `json:"max_per_user_per_stream"`
}
type MaxPerStreamSettings struct {
IsEnabled bool `json:"is_enabled"`
MaxPerStream int `json:"max_per_stream"`
}
type GlobalCooldownSettings struct {
IsEnabled bool `json:"is_enabled"`
GlobalCooldownSeconds int `json:"global_cooldown_seconds"`
}
type ChannelCustomRewardResponse struct {
ResponseCommon
Data ManyChannelCustomRewards
}
// Response for removing a custom reward
type DeleteCustomRewardsResponse struct {
ResponseCommon
}
type UpdateChannelCustomRewardsRedemptionStatusParams struct {
ID string `query:"id"`
BroadcasterID string `query:"broadcaster_id"`
RewardID string `query:"reward_id"`
Status string `json:"status"`
}
type ChannelCustomRewardsRedemptionResponse struct {
ResponseCommon
Data ManyChannelCustomRewardsRedemptions
}
type ManyChannelCustomRewardsRedemptions struct {
Redemptions []ChannelCustomRewardsRedemption `json:"data"`
}
type ChannelCustomRewardsRedemption struct {
ID string `json:"id"`
BroadcasterID string `json:"broadcaster_id"`
BroadcasterLogin string `json:"broadcaster_login"`
BroadcasterName string `json:"broadcaster_name"`
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 `json:"redeemed_at"`
Reward ChannelCustomReward `json:"reward"`
}
// CreateCustomReward : Creates a Custom Reward on a channel.
// Required scope: channel:manage:redemptions
func (c *Client) CreateCustomReward(params *ChannelCustomRewardsParams) (*ChannelCustomRewardResponse, error) {
resp, err := c.postAsJSON("/channel_points/custom_rewards", &ManyChannelCustomRewards{}, params)
if err != nil {
return nil, err
}
reward := &ChannelCustomRewardResponse{}
resp.HydrateResponseCommon(&reward.ResponseCommon)
reward.Data.ChannelCustomRewards = resp.Data.(*ManyChannelCustomRewards).ChannelCustomRewards
return reward, nil
}
// UpdateCustomReward : Update a Custom Reward on a channel.
// Required scope: channel:manage:redemptions
func (c *Client) UpdateCustomReward(params *UpdateChannelCustomRewardsParams) (*ChannelCustomRewardResponse, error) {
resp, err := c.patchAsJSON("/channel_points/custom_rewards", &ManyChannelCustomRewards{}, params)
if err != nil {
return nil, err
}
reward := &ChannelCustomRewardResponse{}
resp.HydrateResponseCommon(&reward.ResponseCommon)
reward.Data.ChannelCustomRewards = resp.Data.(*ManyChannelCustomRewards).ChannelCustomRewards
return reward, nil
}
// DeleteCustomRewards : Deletes a Custom Rewards on a channel
// Required scope: channel:manage:redemptions
func (c *Client) DeleteCustomRewards(params *DeleteCustomRewardsParams) (*DeleteCustomRewardsResponse, error) {
resp, err := c.delete("/channel_points/custom_rewards", nil, params)
if err != nil {
return nil, err
}
reward := &DeleteCustomRewardsResponse{}
resp.HydrateResponseCommon(&reward.ResponseCommon)
return reward, nil
}
// GetCustomRewards : Get Custom Rewards on a channel
// Required scope: channel:read:redemptions
func (c *Client) GetCustomRewards(params *GetCustomRewardsParams) (*ChannelCustomRewardResponse, error) {
resp, err := c.get("/channel_points/custom_rewards", &ManyChannelCustomRewards{}, params)
if err != nil {
return nil, err
}
rewards := &ChannelCustomRewardResponse{}
resp.HydrateResponseCommon(&rewards.ResponseCommon)
rewards.Data.ChannelCustomRewards = resp.Data.(*ManyChannelCustomRewards).ChannelCustomRewards
return rewards, nil
}
// UpdateChannelCustomRewardsRedemptionStatus : Update a Custom Reward Redemption status on a channel.
// Required scope: channel:manage:redemptions
func (c *Client) UpdateChannelCustomRewardsRedemptionStatus(params *UpdateChannelCustomRewardsRedemptionStatusParams) (*ChannelCustomRewardsRedemptionResponse, error) {
resp, err := c.patchAsJSON("/channel_points/custom_rewards/redemptions", &ManyChannelCustomRewardsRedemptions{}, params)
if err != nil {
return nil, err
}
redemptions := &ChannelCustomRewardsRedemptionResponse{}
resp.HydrateResponseCommon(&redemptions.ResponseCommon)
redemptions.Data.Redemptions = resp.Data.(*ManyChannelCustomRewardsRedemptions).Redemptions
return redemptions, nil
}