forked from nicklaw5/helix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entitlement_grants.go
41 lines (33 loc) · 1.15 KB
/
entitlement_grants.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
package helix
type entitlementUploadURLRequest struct {
ManifestID string `query:"manifest_id"`
Type string `query:"type"`
}
type EntitlementsUploadURL struct {
URL string `json:"url"`
}
type ManyEntitlementsUploadURLs struct {
URLs []EntitlementsUploadURL `json:"data"`
}
type EntitlementsUploadResponse struct {
ResponseCommon
Data ManyEntitlementsUploadURLs
}
// CreateEntitlementsUploadURL return a URL where you can upload a manifest
// file and notify users that they have an entitlement. Entitlements are digital
// items that users are entitled to use. Twitch entitlements are granted to users
// gratis or as part of a purchase on Twitch.
func (c *Client) CreateEntitlementsUploadURL(manifestID, entitlementType string) (*EntitlementsUploadResponse, error) {
data := &entitlementUploadURLRequest{
ManifestID: manifestID,
Type: entitlementType,
}
resp, err := c.post("/entitlements/upload", &ManyEntitlementsUploadURLs{}, data)
if err != nil {
return nil, err
}
url := &EntitlementsUploadResponse{}
resp.HydrateResponseCommon(&url.ResponseCommon)
url.Data.URLs = resp.Data.(*ManyEntitlementsUploadURLs).URLs
return url, nil
}