-
Notifications
You must be signed in to change notification settings - Fork 88
/
charity.go
91 lines (76 loc) · 2.96 KB
/
charity.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
package helix
type CharityDonationData struct {
CampaignID string `json:"campaign_id"`
DonationID string `json:"id"`
UserID string `json:"user_id"`
UserName string `json:"user_name"`
UserLogin string `json:"user_login"`
Amount CharityCampaignAmount `json:"amount"`
}
type ManyCharityDonations struct {
Donations []CharityDonationData `json:"data"`
Pagination Pagination `json:"pagination"`
}
type CharityDonationParams struct {
BroadcasterID string `query:"broadcaster_id"`
After string `query:"after"`
First int `query:"first,20"` // Limit 100
}
type CharityDonationsResponse struct {
ResponseCommon
Data ManyCharityDonations
}
type CharityCampaignAmount struct {
Value int64 `json:"value"`
DecimalPlaces int64 `json:"decimal_places"`
Currency string `json:"currency"`
}
type CharityCampaignData struct {
ID string `json:"id"`
BroadcasterID string `json:"broadcaster_id"`
BroadcasterName string `json:"broadcaster_name"`
BroadcasterLogin string `json:"broadcaster_login"`
Name string `json:"charity_name"`
Description string `json:"charity_description"`
LogoUrl string `json:"charity_logo"`
WebsiteUrl string `json:"charity_website"`
TargetAmount CharityCampaignAmount `json:"target_amount"`
CurrentAmount CharityCampaignAmount `json:"current_amount"`
}
type ManyCharityCampaigns struct {
Campaigns []CharityCampaignData `json:"data"`
Pagination Pagination `json:"pagination"`
}
type CharityCampaignsResponse struct {
ResponseCommon
Data ManyCharityCampaigns
}
type CharityCampaignsParams struct {
BroadcasterID string `query:"broadcaster_id"`
After string `query:"after"`
First int `query:"first,20"` // Limit 100
}
// Required scope: channel:read:charity
func (c *Client) GetCharityCampaigns(params *CharityCampaignsParams) (*CharityCampaignsResponse, error) {
resp, err := c.get("/charity/campaigns", &ManyCharityCampaigns{}, params)
if err != nil {
return nil, err
}
events := &CharityCampaignsResponse{}
resp.HydrateResponseCommon(&events.ResponseCommon)
events.Data.Campaigns = resp.Data.(*ManyCharityCampaigns).Campaigns
events.Data.Pagination = resp.Data.(*ManyCharityCampaigns).Pagination
return events, nil
}
// Required scope: channel:read:charity
func (c *Client) GetCharityDonations(params *CharityDonationParams) (*CharityDonationsResponse, error) {
resp, err := c.get("/charity/donations", &ManyCharityDonations{}, params)
if err != nil {
return nil, err
}
events := &CharityDonationsResponse{}
resp.HydrateResponseCommon(&events.ResponseCommon)
events.Data.Donations = resp.Data.(*ManyCharityDonations).Donations
events.Data.Pagination = resp.Data.(*ManyCharityDonations).Pagination
return events, nil
}