forked from nicklaw5/helix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannels_points.go
130 lines (110 loc) · 5.37 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
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"`
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"`
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
}
// 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
}
// 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
}