-
Notifications
You must be signed in to change notification settings - Fork 89
/
ads.go
49 lines (40 loc) · 1.08 KB
/
ads.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
package helix
type AdLengthEnum int
const (
_ AdLengthEnum = iota * 30
AdLen30
AdLen60
AdLen90
AdLen120
AdLen150
AdLen180
)
type StartCommercialParams struct {
BroadcasterID string `query:"broadcaster_id"`
Length AdLengthEnum `query:"length"`
}
type AdDetails struct {
Length AdLengthEnum `json:"length"`
Message string `json:"message"`
RetryAfter int `json:"retry_after"`
}
type ManyAdDetails struct {
AdDetails []AdDetails `json:"data"`
}
type StartCommercialResponse struct {
ResponseCommon
Data ManyAdDetails
}
// StartCommercial starts a commercial on a specified channel
// OAuth Token required
// Requires channel:edit:commercial scope
func (c *Client) StartCommercial(params *StartCommercialParams) (*StartCommercialResponse, error) {
resp, err := c.post("/channels/commercial", &ManyAdDetails{}, params)
if err != nil {
return nil, err
}
commercials := &StartCommercialResponse{}
resp.HydrateResponseCommon(&commercials.ResponseCommon)
commercials.Data.AdDetails = resp.Data.(*ManyAdDetails).AdDetails
return commercials, nil
}