forked from nicklaw5/helix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrops.go
51 lines (43 loc) · 1.79 KB
/
drops.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
package helix
type GetDropEntitlementsParams struct {
ID string `query:"id"`
UserID string `query:"user_id"`
GameID string `query:"game_id"`
After string `query:"after"`
First int `query:"first,20"` // Limit 1000
}
type Entitlement struct {
ID string `json:"id"`
BenefitID string `json:"benefit_id"`
Timestamp Time `json:"timestamp"`
UserID string `json:"user_id"`
GameID string `json:"game_id"`
}
type ManyEntitlements struct {
Entitlements []Entitlement `json:"data"`
}
type ManyEntitlementsWithPagination struct {
ManyEntitlements
Pagination `json:"pagination"`
}
type GetDropsEntitlementsResponse struct {
ResponseCommon
Data ManyEntitlementsWithPagination
}
// GetDropsEntitlements returns a list of entitlements, which have been awarded to users by your organization.
// Filtering by UserID returns all of the entitlements related to that specific user.
// Filtering by GameID returns all of the entitlements related to that game.
// Filtering by GameID and UserID returns all of the entitlements related to that game and that user.
// Entitlements are digital items that users are entitled to use. Twitch entitlements are granted based on viewership
// engagement with a content creator, based on the game developers' campaign.
func (c *Client) GetDropsEntitlements(params *GetDropEntitlementsParams) (*GetDropsEntitlementsResponse, error) {
resp, err := c.get("/entitlements/drops", &ManyEntitlementsWithPagination{}, params)
if err != nil {
return nil, err
}
entitlements := &GetDropsEntitlementsResponse{}
resp.HydrateResponseCommon(&entitlements.ResponseCommon)
entitlements.Data.Entitlements = resp.Data.(*ManyEntitlementsWithPagination).Entitlements
entitlements.Data.Pagination = resp.Data.(*ManyEntitlementsWithPagination).Pagination
return entitlements, nil
}