-
Notifications
You must be signed in to change notification settings - Fork 2
/
news.go
60 lines (49 loc) · 1.71 KB
/
news.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
package kettle
import (
"net/http"
"github.com/dghubble/sling"
)
// ISteamNewsService provides a method for accessing news about an app
type ISteamNewsService struct {
sling *sling.Sling
}
func newISteamNewsService(sling *sling.Sling) *ISteamNewsService {
return &ISteamNewsService{
sling: sling.Path("ISteamNews/"),
}
}
// GetNewsForAppParams are the paremeters for ISteamNewsService.GetNewsForApp
type GetNewsForAppParams struct {
AppID int64 `url:"appid"`
MaxLength int `url:"maxlength,omitempty"`
EndDate int64 `url:"enddate,omitempty"`
Count int `url:"count,omitempty"`
FeedName string `url:"feedname,omitempty"`
}
type newsResponse struct {
AppNews appNews `json:"appnews"`
}
type appNews struct {
AppID int64 `json:"appid"`
NewsItems []NewsItem `json:"newsitems"`
}
// NewsItem is news about an app from ISteamNewsService.GetNewsForApp
type NewsItem struct {
GID string `json:"gid"`
Title string `json:"title"`
URL string `json:"url"`
ExternalURL bool `json:"is_external_url"`
Author string `json:"author"`
Contents string `json:"contents"`
FeedLabel string `json:"feedlabel"`
Date int64 `json:"date"`
FeedName string `json:"feedname"`
}
// GetNewsForApp returns the latest of a game specified by its appID.
// https://developer.valvesoftware.com/wiki/Steam_Web_API#GetNewsForApp_.28v0002.29
// https://wiki.teamfortress.com/wiki/WebAPI/GetNewsForApp
func (s *ISteamNewsService) GetNewsForApp(params *GetNewsForAppParams) ([]NewsItem, *http.Response, error) {
response := new(newsResponse)
resp, err := s.sling.New().Get("GetNewsForApp/v2/").QueryStruct(params).ReceiveSuccess(response)
return response.AppNews.NewsItems, resp, err
}