-
Notifications
You must be signed in to change notification settings - Fork 89
/
goals.go
42 lines (35 loc) · 1.13 KB
/
goals.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
package helix
type Goal struct {
ID string `json:"id"`
BroadcasterID string `json:"broadcaster_id"`
BroadcasterName string `json:"broadcaster_name"`
BroadcasterLogin string `json:"broadcaster_login"`
Type string `json:"type"`
Description string `json:"description"`
CurrentAmount int `json:"current_amount"`
TargetAmount int `json:"target_amount"`
CreatedAt Time `json:"created_at"`
}
type ManyGoals struct {
Goals []Goal `json:"data"`
Pagination Pagination `json:"pagination"`
}
type CreatorGoalsResponse struct {
ResponseCommon
Data ManyGoals
}
type GetCreatorGoalsParams struct {
BroadcasterID string `query:"broadcaster_id"`
}
// Required scope: channel:read:goals
func (c *Client) GetCreatorGoals(payload *GetCreatorGoalsParams) (*CreatorGoalsResponse, error) {
resp, err := c.get("/goals", &ManyGoals{}, payload)
if err != nil {
return nil, err
}
goals := &CreatorGoalsResponse{}
resp.HydrateResponseCommon(&goals.ResponseCommon)
goals.Data.Goals = resp.Data.(*ManyGoals).Goals
goals.Data.Pagination = resp.Data.(*ManyGoals).Pagination
return goals, nil
}